summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Haldane <ealloc@gmail.com>2018-02-09 03:45:28 +0100
committerGitHub <noreply@github.com>2018-02-09 03:45:28 +0100
commitb429be3d3904278d19b7bd4bf37431d8cc6ded1c (patch)
treeb0c956abd74f931ea8dab10c7b2dc110229dbe02
parent7b467455101fb35df5423b4ec859d31f0d0306b0 (diff)
parent33c423ea243ab0c8c261382a4098ebb081312939 (diff)
downloadnumpy-b429be3d3904278d19b7bd4bf37431d8cc6ded1c.tar.gz
Merge pull request #10543 from charris/warn-malformed-data
DEP: Issue FutureWarning when malformed records detected.
-rw-r--r--numpy/core/records.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/numpy/core/records.py b/numpy/core/records.py
index fdda21205..612d39322 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -38,6 +38,7 @@ from __future__ import division, absolute_import, print_function
import sys
import os
+import warnings
from . import numeric as sb
from . import numerictypes as nt
@@ -677,7 +678,7 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None,
try:
retval = sb.array(recList, dtype=descr)
- except TypeError: # list of lists instead of list of tuples
+ except (TypeError, ValueError):
if (shape is None or shape == 0):
shape = len(recList)
if isinstance(shape, (int, long)):
@@ -687,6 +688,12 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None,
_array = recarray(shape, descr)
for k in range(_array.size):
_array[k] = tuple(recList[k])
+ # list of lists instead of list of tuples ?
+ # 2018-02-07, 1.14.1
+ warnings.warn(
+ "fromrecords expected a list of tuples, may have received a list "
+ "of lists instead. In the future that will raise an error",
+ FutureWarning, stacklevel=2)
return _array
else:
if shape is not None and retval.shape != shape: