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

Method test_failed_len_sequence

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

Source from the content-addressed store, hash-verified

1106 np.array(C()) == list(C())
1107
1108 def test_failed_len_sequence(self):
1109 # gh-7393
1110 class A:
1111 def __init__(self, data):
1112 self._data = data
1113 def __getitem__(self, item):
1114 return type(self)(self._data[item])
1115 def __len__(self):
1116 return len(self._data)
1117
1118 # len(d) should give 3, but len(d[0]) will fail
1119 d = A([1,2,3])
1120 assert_equal(len(np.array(d)), 3)
1121
1122 def test_array_too_big(self):
1123 # Test that array creation succeeds for arrays addressable by intp

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
AClass · 0.70

Tested by

no test coverage detected