summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-07-31 14:30:10 -0600
committerCharles Harris <charlesr.harris@gmail.com>2014-07-31 14:30:10 -0600
commitae7c942ced535fb39384aefeb8d32df92fb15988 (patch)
treed06ae19daed6c32522e3a06fb27afb4490302d0d /numpy/lib/npyio.py
parent2ad538899928c249af456d93f250ebbd7535dcff (diff)
parent01b0d7e82211b581aaff925e3ccc36cff9ac1895 (diff)
downloadnumpy-ae7c942ced535fb39384aefeb8d32df92fb15988.tar.gz
Merge pull request #4929 from juliantaylor/charris-pep8-numpy-lib
Charris pep8 numpy lib
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r--numpy/lib/npyio.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 42a539f78..0e49dd31c 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -33,7 +33,8 @@ loads = pickle.loads
__all__ = [
'savetxt', 'loadtxt', 'genfromtxt', 'ndfromtxt', 'mafromtxt',
'recfromtxt', 'recfromcsv', 'load', 'loads', 'save', 'savez',
- 'savez_compressed', 'packbits', 'unpackbits', 'fromregex', 'DataSource']
+ 'savez_compressed', 'packbits', 'unpackbits', 'fromregex', 'DataSource'
+ ]
def seek_gzip_factory(f):
@@ -111,6 +112,7 @@ class BagObj(object):
"Doesn't matter what you want, you're gonna get this"
"""
+
def __init__(self, obj):
# Use weakref to make NpzFile objects collectable by refcount
self._obj = weakref.proxy(obj)
@@ -184,6 +186,7 @@ class NpzFile(object):
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
"""
+
def __init__(self, fid, own_fid=False):
# Import is postponed to here since zipfile depends on gzip, an
# optional component of the so-called standard library.
@@ -866,7 +869,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
# Verify that the array has at least dimensions `ndmin`.
# Check correctness of the values of `ndmin`
- if not ndmin in [0, 1, 2]:
+ if ndmin not in [0, 1, 2]:
raise ValueError('Illegal value of ndmin keyword: %s' % ndmin)
# Tweak the size and shape of the arrays - remove extraneous dimensions
if X.ndim > ndmin:
@@ -1390,7 +1393,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
first_line = next(fhd)
if names is True:
if comments in first_line:
- first_line = asbytes('').join(first_line.split(comments)[1:])
+ first_line = (
+ asbytes('').join(first_line.split(comments)[1:]))
first_values = split_line(first_line)
except StopIteration:
# return an empty array if the datafile is empty
@@ -1595,7 +1599,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
# Make sure we have the corrected keys in user_converters...
user_converters.update(uc_update)
- miss_chars = [_.missing_values for _ in converters]
+ # Fixme: possible error as following variable never used.
+ #miss_chars = [_.missing_values for _ in converters]
# Initialize the output lists ...
# ... rows
@@ -1686,23 +1691,17 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
if usemask:
masks = masks[:-skip_footer]
-
# Convert each value according to the converter:
# We want to modify the list in place to avoid creating a new one...
- #
- # if loose:
- # conversionfuncs = [conv._loose_call for conv in converters]
- # else:
- # conversionfuncs = [conv._strict_call for conv in converters]
- # for (i, vals) in enumerate(rows):
- # rows[i] = tuple([convert(val)
- # for (convert, val) in zip(conversionfuncs, vals)])
if loose:
- rows = list(zip(*[[converter._loose_call(_r) for _r in map(itemgetter(i), rows)]
- for (i, converter) in enumerate(converters)]))
+ rows = list(
+ zip(*[[conv._loose_call(_r) for _r in map(itemgetter(i), rows)]
+ for (i, conv) in enumerate(converters)]))
else:
- rows = list(zip(*[[converter._strict_call(_r) for _r in map(itemgetter(i), rows)]
- for (i, converter) in enumerate(converters)]))
+ rows = list(
+ zip(*[[conv._strict_call(_r) for _r in map(itemgetter(i), rows)]
+ for (i, conv) in enumerate(converters)]))
+
# Reset the dtype
data = rows
if dtype is None:
@@ -1764,7 +1763,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
if user_converters:
ishomogeneous = True
descr = []
- for (i, ttype) in enumerate([conv.type for conv in converters]):
+ for i, ttype in enumerate([conv.type for conv in converters]):
# Keep the dtype of the current converter
if i in user_converters:
ishomogeneous &= (ttype == dtype.type)