summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2014-08-27 15:52:24 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2014-08-27 15:52:24 +0200
commit0210cca2e10199dabc81b64fca2085ab62645b7f (patch)
tree961185f1c1a0f0ea2a2142937c22370c5b17b7ff /numpy/lib/tests/test_io.py
parent145422826e34e880eb16a85bea6cee01cb83556f (diff)
parent709a06d0e9db862a8dd519db13724a4c59de7d69 (diff)
downloadnumpy-0210cca2e10199dabc81b64fca2085ab62645b7f.tar.gz
Merge pull request #5006 from dhomeier/ioconv_usecols
BUG: fix genfromtxt check of converters when using usecols
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 40a229d14..4038d6a7f 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -1085,6 +1085,21 @@ M 33 21.99
control = np.array([2009., 23., 46],)
assert_equal(test, control)
+ def test_dtype_with_converters_and_usecols(self):
+ dstr = "1,5,-1,1:1\n2,8,-1,1:n\n3,3,-2,m:n\n"
+ dmap = {'1:1':0, '1:n':1, 'm:1':2, 'm:n':3}
+ dtyp = [('E1','i4'),('E2','i4'),('E3','i2'),('N', 'i1')]
+ conv = {0: int, 1: int, 2: int, 3: lambda r: dmap[r.decode()]}
+ test = np.recfromcsv(TextIO(dstr,), dtype=dtyp, delimiter=',',
+ names=None, converters=conv)
+ control = np.rec.array([[1,5,-1,0], [2,8,-1,1], [3,3,-2,3]], dtype=dtyp)
+ assert_equal(test, control)
+ dtyp = [('E1','i4'),('E2','i4'),('N', 'i1')]
+ test = np.recfromcsv(TextIO(dstr,), dtype=dtyp, delimiter=',',
+ usecols=(0,1,3), names=None, converters=conv)
+ control = np.rec.array([[1,5,0], [2,8,1], [3,3,3]], dtype=dtyp)
+ assert_equal(test, control)
+
def test_dtype_with_object(self):
"Test using an explicit dtype with an object"
from datetime import date