Skip to content

Commit a5e4adf

Browse files
committed
TST: Test new reduce promoter rule for string addition
1 parent 9d49b0d commit a5e4adf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

numpy/_core/tests/test_stringdtype.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,15 @@ def test_add_promoter(string_list):
746746
assert_array_equal(arr + op, rresult)
747747

748748

749+
def test_add_promoter_reduce():
750+
# Exact TypeError could change, but ensure StringDtype doesn't match
751+
with pytest.raises(TypeError, match="the resolved dtypes are not"):
752+
np.add.reduce(np.array(["a", "b"], dtype="U"))
753+
754+
# On the other hand, using `dtype=T` in the *ufunc* should work.
755+
np.add.reduce(np.array(["a", "b"], dtype="U"), dtype=np.dtypes.StringDType)
756+
757+
749758
@pytest.mark.parametrize("use_out", [True, False])
750759
@pytest.mark.parametrize("other", [2, [2, 1, 3, 4, 1, 3]])
751760
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)