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

Class MyIter

numpy/core/tests/test_numeric.py:1252–1259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1250 data = data * 100 # make sure we realloc a bit
1251
1252 class MyIter:
1253 # Class/example from gh-15789
1254 def __length_hint__(self):
1255 # only required to be an estimate, this is legal
1256 return length_hint # 0 or 1
1257
1258 def __iter__(self):
1259 return iter(data)
1260
1261 res = np.fromiter(MyIter(), dtype=dtype)
1262 expected = np.array(data, dtype=dtype)

Callers 2

test_empty_resultMethod · 0.85

Calls

no outgoing calls

Tested by 2

test_empty_resultMethod · 0.68