diff options
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_io.py | 10 | ||||
-rw-r--r-- | numpy/lib/tests/test_recfunctions.py | 23 |
2 files changed, 27 insertions, 6 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index a85b01909..04497dee8 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -381,6 +381,15 @@ class TestLoadTxt(TestCase): dtype=dt) assert_array_equal(x, a) + def test_3d_shaped_dtype(self): + c = StringIO("aaaa 1.0 8.0 1 2 3 4 5 6 7 8 9 10 11 12") + dt = np.dtype([('name', 'S4'), ('x', float), ('y', float), + ('block', int, (2, 2, 3))]) + x = np.loadtxt(c, dtype=dt) + a = np.array([('aaaa', 1.0, 8.0, [[[1, 2, 3], [4, 5, 6]],[[7, 8, 9], [10, 11, 12]]])], + dtype=dt) + assert_array_equal(x, a) + def test_empty_file(self): c = StringIO() assert_raises(IOError, np.loadtxt, c) @@ -884,7 +893,6 @@ M 33 21.99 dtype=dt) assert_array_equal(x, a) - def test_withmissing(self): data = StringIO('A,B\n0,1\n2,N/A') kwargs = dict(delimiter=",", missing_values="N/A", names=True) diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py index 0a22e2a34..14af43a59 100644 --- a/numpy/lib/tests/test_recfunctions.py +++ b/numpy/lib/tests/test_recfunctions.py @@ -540,13 +540,17 @@ class TestStackArrays(TestCase): class TestJoinBy(TestCase): + def setUp(self): + self.a = np.array(zip(np.arange(10), np.arange(50, 60), + np.arange(100, 110)), + dtype=[('a', int), ('b', int), ('c', int)]) + self.b = np.array(zip(np.arange(5, 15), np.arange(65, 75), + np.arange(100, 110)), + dtype=[('a', int), ('b', int), ('d', int)]) # - def test_base(self): + def test_inner_join(self): "Basic test of join_by" - a = np.array(zip(np.arange(10), np.arange(50, 60), np.arange(100, 110)), - dtype=[('a', int), ('b', int), ('c', int)]) - b = np.array(zip(np.arange(5, 15), np.arange(65, 75), np.arange(100, 110)), - dtype=[('a', int), ('b', int), ('d', int)]) + a, b = self.a, self.b # test = join_by('a', a, b, jointype='inner') control = np.array([(5, 55, 65, 105, 100), (6, 56, 66, 106, 101), @@ -555,6 +559,9 @@ class TestJoinBy(TestCase): dtype=[('a', int), ('b1', int), ('b2', int), ('c', int), ('d', int)]) assert_equal(test, control) + + def test_join(self): + a, b = self.a, self.b # test = join_by(('a', 'b'), a, b) control = np.array([(5, 55, 105, 100), (6, 56, 106, 101), @@ -562,6 +569,9 @@ class TestJoinBy(TestCase): (9, 59, 109, 104)], dtype=[('a', int), ('b', int), ('c', int), ('d', int)]) + + def test_outer_join(self): + a, b = self.a, self.b # test = join_by(('a', 'b'), a, b, 'outer') control = ma.array([(0, 50, 100, -1), (1, 51, 101, -1), @@ -587,6 +597,9 @@ class TestJoinBy(TestCase): dtype=[('a', int), ('b', int), ('c', int), ('d', int)]) assert_equal(test, control) + + def test_leftouter_join(self): + a, b = self.a, self.b # test = join_by(('a', 'b'), a, b, 'leftouter') control = ma.array([(0, 50, 100, -1), (1, 51, 101, -1), |