beartype / numerary

A pure-Python codified rant aspiring to a world where numbers and types can work together.
https://posita.github.io/numerary/latest/
Other
39 stars 1 forks source link

AttributeError: module 'numpy' has no attribute 'float128'. Did you mean: 'float16'? #12

Closed copperfield42 closed 2 years ago

copperfield42 commented 2 years ago

after just coming across this library, I just pip installed it and the first thing I come across is

>>> import numerary
Traceback (most recent call last):
  File "<pyshell#35>", line 1, in <module>
    import numerary
  File "C:\Python3.10.5\lib\site-packages\numerary\__init__.py", line 13, in <module>
    from .types import *  # noqa: F401,F403
  File "C:\Python3.10.5\lib\site-packages\numerary\types.py", line 1712, in <module>
    numpy.float128,
  File "C:\Python3.10.5\lib\site-packages\numpy\__init__.py", line 315, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float128'. Did you mean: 'float16'?
>>> 

versions: python: 3.10.5 numpy: 1.22.4

posita commented 2 years ago

Hi @copperfield42! Thanks for the report! I should have a fix out shortly. Are you running on Windows by any chance? What do the following give for you?

python -VV
python -c 'import sys ; print(sys.platform)'
copperfield42 commented 2 years ago

yes, I use windows.

Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] win32

posita commented 2 years ago

Thanks again, @copperfield42. Can you try to see if my fix addresses your issue? You can try it out with pip install 'git+https://github.com/posita/numerary@posita/0/fix-numpy'. I should be able to cut a release in a few hours, but that will allow you to verify the fix before that.

copperfield42 commented 2 years ago

meanwhile I fixed like this: commented the problem line and try-except the float128

    for t in (
        numpy.float16,
        numpy.float32,
        numpy.float64,
        #numpy.float128,
    ):
        SupportsFloorCeil.includes(t)
        SupportsIntegralOps.excludes(t)
        SupportsIntegralPow.excludes(t)
    try:
        t = numpy.float128
        SupportsFloorCeil.includes(t)
        SupportsIntegralOps.excludes(t)
        SupportsIntegralPow.excludes(t)
    except AttributeError:
        pass

and that solve it.


I will try your fix in a bit and tell you

copperfield42 commented 2 years ago

that pip command give me

> pip install "git+https://github.com/posita/numerary@posita/0/fix-numpy"
Collecting git+https://github.com/posita/numerary@posita/0/fix-numpy
  Cloning https://github.com/posita/numerary (to revision posita/0/fix-numpy) to c:\users\thecnomacvzla\appdata\local\temp\pip-req-build-l_iw0x15
  ERROR: Error [WinError 2] El sistema no puede encontrar el archivo especificado while executing command git version
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

>
posita commented 2 years ago

Ah. Okay, so that's not an option for you. Given that your commented line addresses the issue on your platform, I'm pretty sure my fix will also work for you, but I'll need to cut a new release. Give me a bit, and I should have something soon.

posita commented 2 years ago

@copperfield42, I believe @v0.4.2 should address this issue for you, but please reopen if it does not. pip install --upgrade 'numerary>=0.4.2' should update the version you have.