Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc5f21e

Browse files
authored
Merge pull request #27261 from seberg/test-27249
TST: Add regression test for missing descr in array-interface
2 parents 16d6996 + b81da1d commit dc5f21e

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)