Skip to content

Commit b81da1d

Browse files
committed
TST: Add regression test for missing descr in array-interface
This adds a simple regression test for the missing descr for numpygh-27249.
1 parent 16d6996 commit b81da1d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

numpy/_core/tests/test_array_coercion.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,17 @@ def __getitem__(self):
762762
with pytest.raises(error):
763763
np.array(BadSequence())
764764

765+
def test_array_interface_descr_optional(self):
766+
# The descr should be optional regresion test for gh-27249
767+
arr = np.ones(10, dtype="V10")
768+
iface = arr.__array_interface__
769+
iface.pop("descr")
770+
771+
class MyClass:
772+
__array_interface__ = iface
773+
774+
assert_array_equal(np.asarray(MyClass), arr)
775+
765776

766777
class TestAsArray:
767778
"""Test expected behaviors of ``asarray``."""

0 commit comments

Comments
 (0)