kdavies4 / natu

Natural units in Python
http://kdavies4.github.io/natu/
Other
33 stars 5 forks source link

missing functools import #38

Open spmcv opened 5 years ago

spmcv commented 5 years ago

Originally posted by @MinhHaDuong in https://github.com/kdavies4/natu/issues/28#issuecomment-322365432 :

Closing, there is a from functools import wraps, reduce in core.py

Appears to be an issue again. No reduce import in core.py. Install source is PyPi.

from natu.units import N
print(repr(1.0 * N))
Traceback (most recent call last):
  File "~/.pyenv/versions/scientific/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-9b28d8840f52>", line 1, in <module>
    print(repr(1 * N))
  File "~/.pyenv/versions/scientific/lib/python3.7/site-packages/natu/core.py", line 823, in __repr__
    return format(self, 'g')
  File "~/.pyenv/versions/scientific/lib/python3.7/site-packages/natu/core.py", line 357, in wrapped
    unit = unitspace(**display_unit)
  File "~/.pyenv/versions/scientific/lib/python3.7/site-packages/natu/core.py", line 1374, in __call__
    return reduce(lambda x, y: x * y, factors)
NameError: name 'reduce' is not defined

Although it appears to be in master:

from functools import wraps, reduce
smcveigh-phunware commented 5 years ago

PyPi version v0.1.1 definitely out of sync with master.