summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_recfunctions.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-07-01 14:25:21 +0100
committerEric Wieser <wieser.eric@gmail.com>2017-07-01 15:10:06 +0100
commitbdbac02b0bddb265840cc00cc5dec0590c09b093 (patch)
treea33c87b8d62062a9e09e8029f06d960938790561 /numpy/lib/tests/test_recfunctions.py
parentcd761d81b571525ac6c2cca36da6bd270bb8357d (diff)
downloadnumpy-bdbac02b0bddb265840cc00cc5dec0590c09b093.tar.gz
BUG: recfunctions.join_by fails when key is a subdtype
It seems that working with .descr is a generally terrible idea. Instead we introduce `get_fieldspec`, which returns a list of 2-tuples, encapsulating subdtypes. This also means that np.core.test_rational.rational survives a roundtrip - its .descr is 'V8', which ddoesn't survive
Diffstat (limited to 'numpy/lib/tests/test_recfunctions.py')
-rw-r--r--numpy/lib/tests/test_recfunctions.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py
index a5d15cb24..50a85a08e 100644
--- a/numpy/lib/tests/test_recfunctions.py
+++ b/numpy/lib/tests/test_recfunctions.py
@@ -669,6 +669,20 @@ class TestJoinBy(TestCase):
assert_equal(res.dtype, expected_dtype)
+ def test_subarray_key(self):
+ a_dtype = np.dtype([('pos', int, 3), ('f', '<f4')])
+ a = np.array([([1, 1, 1], np.pi), ([1, 2, 3], 0.0)], dtype=a_dtype)
+
+ b_dtype = np.dtype([('pos', int, 3), ('g', '<f4')])
+ b = np.array([([1, 1, 1], 3), ([3, 2, 1], 0.0)], dtype=b_dtype)
+
+ expected_dtype = np.dtype([('pos', int, 3), ('f', '<f4'), ('g', '<f4')])
+ expected = np.array([([1, 1, 1], np.pi, 3)], dtype=expected_dtype)
+
+ res = join_by('pos', a, b)
+ assert_equal(res.dtype, expected_dtype)
+ assert_equal(res, expected)
+
class TestJoinBy2(TestCase):
@classmethod