MCPcopy Create free account
hub / github.com/numpy/numpy / test_false_len_sequence

Method test_false_len_sequence

numpy/core/tests/test_multiarray.py:1081–1090  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1079 assert_equal(d.dtype, np.dtype(object))
1080
1081 def test_false_len_sequence(self):
1082 # gh-7264, segfault for this example
1083 class C:
1084 def __getitem__(self, i):
1085 raise IndexError
1086 def __len__(self):
1087 return 42
1088
1089 a = np.array(C()) # segfault?
1090 assert_equal(len(a), 0)
1091
1092 def test_false_len_iterable(self):
1093 # Special case where a bad __getitem__ makes us fall back on __iter__:

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected