summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-03-23 10:35:38 -0600
committerGitHub <noreply@github.com>2017-03-23 10:35:38 -0600
commit2ad36f67e2b0dc4bff9f582e4bdbf19c38a66868 (patch)
treeaa0f56bccd4dc2badfe809cca3110fe80a236128 /numpy/lib
parent88ef1a6ac0e8df043b044f0aa37bf4b2f18c237e (diff)
parent06c7142f45a27d3e2e4e9ad4a01715e3da11f67b (diff)
downloadpython-numpy-2ad36f67e2b0dc4bff9f582e4bdbf19c38a66868.tar.gz
python-numpy-2ad36f67e2b0dc4bff9f582e4bdbf19c38a66868.tar.bz2
python-numpy-2ad36f67e2b0dc4bff9f582e4bdbf19c38a66868.zip
Merge pull request #8813 from eric-wieser/maint-flatten-dtype
MAINT: tidy up some of npyio
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/_iotools.py5
-rw-r--r--numpy/lib/npyio.py7
2 files changed, 7 insertions, 5 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py
index 67e21aa0c..312a9f02a 100644
--- a/numpy/lib/_iotools.py
+++ b/numpy/lib/_iotools.py
@@ -122,8 +122,9 @@ def flatten_dtype(ndtype, flatten_base=False):
----------
ndtype : dtype
The datatype to collapse
- flatten_base : {False, True}, optional
- Whether to transform a field with a shape into several fields or not.
+ flatten_base : bool, optional
+ If True, transform a field with a shape into several fields. Default is
+ False.
Examples
--------
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 0dee6b333..54a37fbad 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -902,7 +902,8 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
raise ValueError('fname must be a string, file handle, or generator')
X = []
- def flatten_dtype(dt):
+ # not to be confused with the flatten_dtype we import...
+ def flatten_dtype_internal(dt):
"""Unpack a structured data-type, and produce re-packing info."""
if dt.names is None:
# If the dtype is flattened, return.
@@ -922,7 +923,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
packing = []
for field in dt.names:
tp, bytes = dt.fields[field]
- flat_dt, flat_packing = flatten_dtype(tp)
+ flat_dt, flat_packing = flatten_dtype_internal(tp)
types.extend(flat_dt)
# Avoid extra nesting for subarrays
if tp.ndim > 0:
@@ -986,7 +987,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
warnings.warn('loadtxt: Empty input file: "%s"' % fname, stacklevel=2)
N = len(usecols or first_vals)
- dtype_types, packing = flatten_dtype(dtype)
+ dtype_types, packing = flatten_dtype_internal(dtype)
if len(dtype_types) > 1:
# We're dealing with a structured array, each field of
# the dtype matches a column