diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-07-01 13:05:15 +0100 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-07-01 13:08:27 +0100 |
commit | cd761d81b571525ac6c2cca36da6bd270bb8357d (patch) | |
tree | 7c09e715b6929bb75a2d6624ed2027773f7bd27a /numpy/lib/tests/test_recfunctions.py | |
parent | 49e10732433c26d7c781e00a415fa33dada6ac90 (diff) | |
download | numpy-cd761d81b571525ac6c2cca36da6bd270bb8357d.tar.gz |
BUG: recfunctions.join_by fails for colliding values with different dtypes
Fixes #9338
Diffstat (limited to 'numpy/lib/tests/test_recfunctions.py')
-rw-r--r-- | numpy/lib/tests/test_recfunctions.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py index e9cfa4993..a5d15cb24 100644 --- a/numpy/lib/tests/test_recfunctions.py +++ b/numpy/lib/tests/test_recfunctions.py @@ -656,6 +656,19 @@ class TestJoinBy(TestCase): b = np.ones(3, dtype=[('c', 'u1'), ('b', 'f4'), ('a', 'i4')]) assert_raises(ValueError, join_by, ['a', 'b', 'b'], a, b) + def test_same_name_different_dtypes(self): + # gh-9338 + a_dtype = np.dtype([('key', 'S10'), ('value', '<f4')]) + b_dtype = np.dtype([('key', 'S10'), ('value', '<f8')]) + expected_dtype = np.dtype([ + ('key', '|S10'), ('value1', '<f4'), ('value2', '<f8')]) + + a = np.array([('Sarah', 8.0), ('John', 6.0)], dtype=a_dtype) + b = np.array([('Sarah', 10.0), ('John', 7.0)], dtype=b_dtype) + res = join_by('key', a, b) + + assert_equal(res.dtype, expected_dtype) + class TestJoinBy2(TestCase): @classmethod |