allelos / vectors

A simple vector toolkit dealing with points and vectors in the 3-dimensional space.
MIT License
23 stars 15 forks source link

reduce function not available in python 3 #8

Open hsolbrig opened 6 years ago

hsolbrig commented 6 years ago

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.

allelos commented 6 years ago

Could you test it? Make a pull request and I will merge it :)

hsolbrig commented 6 years ago

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 / ...)?

hsolbrig commented 6 years ago

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.

Sudhanshu-Dubey14 commented 5 years ago

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.

sandinak commented 4 years ago

Can I +1 the note about reduce .. that fixes the issue.