vectors icon indicating copy to clipboard operation
vectors copied to clipboard

reduce function not available in python 3

Open hsolbrig opened this issue 7 years ago • 5 comments

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.

hsolbrig avatar Dec 14 '17 23:12 hsolbrig

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

allelos avatar Jan 05 '18 10:01 allelos

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 avatar Jan 05 '18 15:01 hsolbrig

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.

hsolbrig avatar Jan 05 '18 17:01 hsolbrig

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.

Sudhanshu-Dubey14 avatar Aug 01 '19 19:08 Sudhanshu-Dubey14

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

sandinak avatar Apr 04 '20 19:04 sandinak