from natu.units import m
import natu.math as math
x = (r * m for r in range(10))
y = math.fsum(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Ian\AppData\Local\conda\conda\envs\sandpit\lib\site-packages\natu-0.1.2-py3.6.egg\natu\_decorators.py", line 248, in wrapped
return merge(func(map(value, x)), x[0])
TypeError: 'generator' object is not subscriptable
Inside the decorator homogeneous_copy_props_iter() there are two problems:
assert_homogeneous(*x) exhausts the generator.
merge(func(map(value, x)), x[0]) tries to reference an element by index.
I don't think the correct fix is to realise the generator as a list because most of the reason generators are used is so that the entire sequence does not have to be held in memory in one go.
You can't use math.fsum() with a generator:
Inside the decorator
homogeneous_copy_props_iter()
there are two problems:assert_homogeneous(*x)
exhausts the generator.merge(func(map(value, x)), x[0])
tries to reference an element by index.I don't think the correct fix is to realise the generator as a list because most of the reason generators are used is so that the entire sequence does not have to be held in memory in one go.