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

Method test_empty_result

numpy/core/tests/test_numeric.py:1266–1276  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1264 assert_array_equal(res, expected)
1265
1266 def test_empty_result(self):
1267 class MyIter:
1268 def __length_hint__(self):
1269 return 10
1270
1271 def __iter__(self):
1272 return iter([]) # actual iterator is empty.
1273
1274 res = np.fromiter(MyIter(), dtype="d")
1275 assert res.shape == (0,)
1276 assert res.dtype == "d"
1277
1278 def test_too_few_items(self):
1279 msg = "iterator too short: Expected 10 but iterator had only 3 items."

Callers

nothing calls this directly

Calls 1

MyIterClass · 0.85

Tested by

no test coverage detected