glumpy icon indicating copy to clipboard operation
glumpy copied to clipboard

Cannot import glumpy with numpy >= 1.24 - np.bool removed from numpy

Open fjansson opened this issue 2 years ago • 5 comments

import glumpy gives

/home/fjansson/.local/lib/python3.10/site-packages/glumpy/gloo/variable.py:82: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.
  gl.GL_BOOL         : ( 1, gl.GL_BOOL,         np.bool),
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fjansson/.local/lib/python3.10/site-packages/glumpy/__init__.py", line 7, in <module>
    from . import app
  File "/home/fjansson/.local/lib/python3.10/site-packages/glumpy/app/__init__.py", line 23, in <module>
    from . console import Console
  File "/home/fjansson/.local/lib/python3.10/site-packages/glumpy/app/console.py", line 7, in <module>
    from glumpy import gl, glm, gloo
  File "/home/fjansson/.local/lib/python3.10/site-packages/glumpy/gloo/__init__.py", line 7, in <module>
    from . program import Program
  File "/home/fjansson/.local/lib/python3.10/site-packages/glumpy/gloo/program.py", line 16, in <module>
    from . variable import gl_typeinfo, Uniform, Attribute
  File "/home/fjansson/.local/lib/python3.10/site-packages/glumpy/gloo/variable.py", line 82, in <module>
    gl.GL_BOOL         : ( 1, gl.GL_BOOL,         np.bool),
  File "/usr/lib/python3.10/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'bool'. Did you mean: 'bool_'?

I have numpy 1.24.1 and glumpy 1.2.0, Python 3.10.9.

The reason is probably that numpy removed np.bool and other such type aliases in release 1.24.0, they have been deprecated for some time, see https://github.com/numpy/numpy/releases/tag/v1.24.0 . The file glumpy/gloo/variable.py uses many such aliases.

Here is documentation of the deprecations and what to replace the types with: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations .

fjansson avatar Feb 06 '23 19:02 fjansson

A fix has been proposed and I just merged it. Can you try?

rougier avatar Feb 14 '23 10:02 rougier

I installed the latest commit using pip, and it works. Thank you!

pip install -U git+https://github.com/glumpy/glumpy@54a7eab7c08fb

The only slight weirdness I found is the version numbering: pip said Successfully installed glumpy-1.1.1 and glumpy.__version__ returns 1.0.6.

fjansson avatar Feb 15 '23 20:02 fjansson

Oh, I need to bump the internal version number. Do you want to make a PR?

rougier avatar Feb 27 '23 14:02 rougier

I don't think I'd do a very useful job with the version - I don't know where the version number is set, and also not what to set it to... perhaps just bump it for the next release?

fjansson avatar Feb 27 '23 15:02 fjansson

I've found the line.

rougier avatar Feb 27 '23 16:02 rougier