Skip to content

Fix deprecated np.int aliases in bundled groupy library#1

Open
markfricker wants to merge 1 commit intoNanoscopyAI:mainfrom
markfricker:fix/numpy-int-deprecation
Open

Fix deprecated np.int aliases in bundled groupy library#1
markfricker wants to merge 1 commit intoNanoscopyAI:mainfrom
markfricker:fix/numpy-int-deprecation

Conversation

@markfricker
Copy link
Copy Markdown

NumPy 1.24 (December 2022) removed the np.int, np.float, np.complex and related aliases for built-in Python types. Any user running nERdy+ with a current NumPy version encounters an AttributeError on import, making the package completely unusable.

Changes (all in nERdy+/groupy/garray/):

  • C4_array.py, D4_array.py, Z2_array.py, p4_array.py, p4m_array.py:
    dtype=np.int → dtype=np.int64
    .astype(np.int) → .astype(np.int64)
    == np.int / != np.int → == np.int64 / != np.int64

  • matrix_garray.py (additional Windows/platform fix): data.dtype != np.int64 → not np.issubdtype(data.dtype, np.integer) np.int64 is the native integer type on Linux/Mac but Windows NumPy uses np.int32 for default integer arrays, so the strict dtype equality check raised a spurious ValueError on Windows.

Tested with NumPy 1.26, PyTorch 2.10 (CUDA 12.6), Python 3.12 on Windows 11. CPU and GPU inference both confirmed working.

Ref: https://numpy.org/doc/stable/release/1.24-notes.html
#expired-deprecations

NumPy 1.24 (December 2022) removed the np.int, np.float, np.complex
and related aliases for built-in Python types.  Any user running
nERdy+ with a current NumPy version encounters an AttributeError on
import, making the package completely unusable.

Changes (all in nERdy+/groupy/garray/):
- C4_array.py, D4_array.py, Z2_array.py, p4_array.py, p4m_array.py:
    dtype=np.int   → dtype=np.int64
    .astype(np.int) → .astype(np.int64)
    == np.int / != np.int → == np.int64 / != np.int64

- matrix_garray.py (additional Windows/platform fix):
    data.dtype != np.int64
    → not np.issubdtype(data.dtype, np.integer)
  np.int64 is the native integer type on Linux/Mac but Windows NumPy
  uses np.int32 for default integer arrays, so the strict dtype
  equality check raised a spurious ValueError on Windows.

Tested with NumPy 1.26, PyTorch 2.10 (CUDA 12.6), Python 3.12
on Windows 11.  CPU and GPU inference both confirmed working.

Ref: https://numpy.org/doc/stable/release/1.24-notes.html
     #expired-deprecations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant