summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorpierregm <pierregm@localhost>2009-02-14 22:42:29 +0000
committerpierregm <pierregm@localhost>2009-02-14 22:42:29 +0000
commitb4b2d63b15f694ff9fc469f366af5b9a2e3653fc (patch)
tree177820b790222e983fa0672e6f5e071c011aac53 /numpy/lib/tests
parentc1877cb6d2f56a817fcbc046820abcc338302d3f (diff)
downloadnumpy-b4b2d63b15f694ff9fc469f366af5b9a2e3653fc.tar.gz
* genfromtxt : fixed case when using explicit converters and explicit dtype.
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test__iotools.py8
-rw-r--r--numpy/lib/tests/test_io.py13
2 files changed, 19 insertions, 2 deletions
diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py
index bb1483186..2cb8461c3 100644
--- a/numpy/lib/tests/test__iotools.py
+++ b/numpy/lib/tests/test__iotools.py
@@ -142,6 +142,14 @@ class TestStringConverter(TestCase):
assert_equal(test, date(2009, 01, 01))
test = convert('')
assert_equal(test, date(2000, 01, 01))
+ #
+ def test_string_to_object(self):
+ "Make sure that string-to-object functions are properly recognized"
+ from datetime import date
+ import time
+ conv = StringConverter(lambda s: date(*(time.strptime(s)[:3])))
+ assert_equal(conv._mapper[-2][0](0), 0j)
+ assert(hasattr(conv, 'default'))
#-------------------------------------------------------------------------------
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 03d4f42e6..935773134 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -573,7 +573,7 @@ M 33 21.99
def test_dtype_with_object(self):
- "Test using an explicit dtype qith an object"
+ "Test using an explicit dtype with an object"
from datetime import date
import time
data = """
@@ -598,7 +598,16 @@ M 33 21.99
else:
errmsg = "Nested dtype involving objects should be supported."
raise AssertionError(errmsg)
-
+
+
+ def test_userconverters_with_explicit_dtype(self):
+ "Test user_converters w/ explicit (standard) dtype"
+ data = StringIO.StringIO('skip,skip,2001-01-01,1.0,skip')
+ test = np.genfromtxt(data, delimiter=",", names=None, dtype=float,
+ usecols=(2, 3), converters={2: str})
+ control = np.array([('2001-01-01', 1.)],
+ dtype=[('', '|S10'), ('', float)])
+ assert_equal(test, control)
def test_spacedelimiter(self):