diff options
author | pierregm <pierregm@localhost> | 2009-02-02 05:20:17 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2009-02-02 05:20:17 +0000 |
commit | f278427bb52fdfdc524d1da4032777ca5290e49e (patch) | |
tree | be3542eb760eee87294e083af574d9600b5f9264 /numpy/lib/tests/test_recfunctions.py | |
parent | d3e84d6b104ee2d95e46ffd65d461f5351755a46 (diff) | |
download | numpy-f278427bb52fdfdc524d1da4032777ca5290e49e.tar.gz |
* Added a 'autoconvert' option to stack_arrays.
* Fixed 'stack_arrays' to work with fields with titles.
Diffstat (limited to 'numpy/lib/tests/test_recfunctions.py')
-rw-r--r-- | numpy/lib/tests/test_recfunctions.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py index 1a405090d..f7a72071c 100644 --- a/numpy/lib/tests/test_recfunctions.py +++ b/numpy/lib/tests/test_recfunctions.py @@ -485,7 +485,6 @@ class TestStackArrays(TestCase): assert_equal(test.mask, control.mask) - # def test_defaults(self): "Test defaults: no exception raised if keys of defaults are not fields." (_, _, _, z) = self.data @@ -503,6 +502,37 @@ class TestStackArrays(TestCase): assert_equal(test.mask, control.mask) + def test_autoconversion(self): + "Tests autoconversion" + adtype = [('A', int), ('B', bool), ('C', float)] + a = ma.array([(1, 2, 3)], mask=[(0, 1, 0)], dtype=adtype) + bdtype = [('A', int), ('B', float), ('C', float)] + b = ma.array([(4, 5, 6)], dtype=bdtype) + control = ma.array([(1, 2, 3), (4, 5, 6)], mask=[(0, 1, 0), (0, 0, 0)], + dtype=bdtype) + test = stack_arrays((a, b), autoconvert=True) + assert_equal(test, control) + assert_equal(test.mask, control.mask) + try: + test = stack_arrays((a, b), autoconvert=False) + except TypeError: + pass + else: + raise AssertionError + + + def test_checktitles(self): + "Test using titles in the field names" + adtype = [(('a', 'A'), int), (('b', 'B'), bool), (('c', 'C'), float)] + a = ma.array([(1, 2, 3)], mask=[(0, 1, 0)], dtype=adtype) + bdtype = [(('a', 'A'), int), (('b', 'B'), bool), (('c', 'C'), float)] + b = ma.array([(4, 5, 6)], dtype=bdtype) + test = stack_arrays((a, b)) + control = ma.array([(1, 2, 3), (4, 5, 6)], mask=[(0, 1, 0), (0, 0, 0)], + dtype=bdtype) + assert_equal(test, control) + assert_equal(test.mask, control.mask) + class TestJoinBy(TestCase): # |