Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumPy Compatibility Issues: np.string_ Error with NumPy 2.0 and numpy._core.numeric Missing in Older Versions #528

Open
yiiiwuuu opened this issue Sep 19, 2024 · 2 comments

Comments

@yiiiwuuu
Copy link

Hello,

I'm encountering compatibility issues with NumPy when running BlueSky.

Problem Description:

  1. Using NumPy 2.0.0.dev0:
    When I have NumPy version 2.0.0.dev0 installed, running BlueSky results in the following error:
    AttributeError: np.string_was removed in the NumPy 2.0 release. Usenp.bytes_ instead.
    This error occurs in glnavdata.py at line 123:
    npwpids = np.array(wptids, dtype=np.string_)

  2. Using Older NumPy Versions (e.g., 1.21.0):
    When I downgrade NumPy to version 1.21.0 or 1.24.0, I receive a different error upon running BlueSky:

Bluesky needs numpy._core.numeric
Install using e.g. pip install numpy._core.numeric
BlueSky normal end.

Environment Information:
Operating System: Windows 11
Python Version: 3.10
BlueSky Version: Installed via pip install bluesky-simulator[full]
NumPy Versions Tried: 2.0.0.dev0, 1.24.0, 1.21.0

Steps to Reproduce:

  1. Install BlueSky and NumPy:
pip install bluesky-simulator[full]
pip install numpy==2.0.0.dev0  # For the first error
# or
pip install numpy==1.21.0      # For the second error
2. Run BlueSky:
bluesky
  1. Observe the respective errors mentioned above.

Questions:

  • Is there a recommended NumPy version that is fully compatible with BlueSky?
  • How can I resolve these conflicting errors when using different NumPy versions?

Additional Notes:

Modifying the source code (e.g., replacing np.string_ with np.bytes_) might be a workaround for the first error, but I'm unsure of the implications.
When using older NumPy versions, the module numpy._core.numeric seems to be missing, leading to the second error.
Any guidance on how to resolve these issues would be greatly appreciated.

Thank you!

@ArsyiAziz
Copy link

You can migrate the code to Numpy 2.0 using Ruff.

  1. First install Ruff: pip install ruff
  2. Then run the following command in the root directory of BlueSky to migrate the code to NumPy 2.0: ruff check --preview --fix --select NPY201 .

@jooste
Copy link
Member

jooste commented Sep 26, 2024

Hi @yiiiwuuu,

NumPy2 compatibility has been fixed in the master version, but has not made its way yet in packaged BlueSky, because we also need to change the python versions supported (it seems that np2 is not available for older versions)

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

No branches or pull requests

3 participants