vectors
vectors copied to clipboard
reduce function not available in python 3
Several functions (magnitude, dot, etc) fail because reduce
has been removed from the core library. To use it, one needs to add:
from functools import reduce
to the header
This appears to work in python 2.7 as well, so it appears that it would do no harm.
Could you test it? Make a pull request and I will merge it :)
I can run through the examples on the readme page using python 2.7 and 3.6 but it wouldn't be exhaustive. Do you have a test suite? If not, would you object to starting one? And, if no objections, do you have a preference wrt. test harnesses (unittest / pytest / ...)?
It turns out that that line was added to the code in a June 15 commit. What needs to happen is the version number needs to be bumped in setup.py
and you need to push a new version to pypi.
I also faced this issue while doing dot product:
File "/usr/local/lib/python3.6/dist-packages/vectors/vectors.py", line 76, in dot
return (reduce(lambda x, y: x+y,
NameError: name 'reduce' is not defined
I am using python 3.6.9.
For now I have manually added the from functools import reduce
to vectors.py and it works.
It would be really helpful if you could implement the last changes suggested by @hsolbrig.
Can I +1 the note about reduce .. that fixes the issue.