summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartingoodson <martingoodson@gmail.com>2012-07-10 16:31:03 +0200
committerRalf Gommers <ralf.gommers@googlemail.com>2012-07-10 21:42:28 +0200
commit1a70875974aecec81de1866ad9847d511d420f65 (patch)
tree0147033be702763b62c4983a9bc3bcee5b923204
parent436a28f4ea4d596c59e85745eac7446f7e18903f (diff)
downloadnumpy-1a70875974aecec81de1866ad9847d511d420f65.tar.gz
BUG: make genfromtxt work with comments=None. Closes Github issue 329.
-rw-r--r--numpy/lib/npyio.py3
-rw-r--r--numpy/lib/tests/test_io.py8
2 files changed, 7 insertions, 4 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index b1e891f77..b63003f80 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -1291,7 +1291,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
"""
# Py3 data conversions to bytes, for convenience
- comments = asbytes(comments)
+ if comments is not None:
+ comments = asbytes(comments)
if isinstance(delimiter, unicode):
delimiter = asbytes(delimiter)
if isinstance(missing, unicode):
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index c539c040a..aeda7663c 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -1426,8 +1426,6 @@ M 33 21.99
usecols=("A", "C", "E"), names=True)
assert_equal(test.dtype.names, ctrl_names)
-
-
def test_fixed_width_names(self):
"Test fix-width w/ names"
data = " A B C\n 0 1 2.3\n 45 67 9."
@@ -1451,6 +1449,11 @@ M 33 21.99
test = np.ndfromtxt(StringIO(data), **kwargs)
assert_equal(test, ctrl)
+ def test_comments_is_none(self):
+ # Github issue 329 (None was previously being converted to 'None').
+ test = np.genfromtxt(StringIO("test1,testNonetherestofthedata"),
+ dtype=None, comments=None, delimiter=',')
+ assert_equal(test[1], asbytes('testNonetherestofthedata'))
def test_recfromtxt(self):
#
@@ -1471,7 +1474,6 @@ M 33 21.99
assert_equal(test.mask, control.mask)
assert_equal(test.A, [0, 2])
-
def test_recfromcsv(self):
#
data = StringIO('A,B\n0,1\n2,3')