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

Adjust for NumPy 2.0.0 #140

Closed
khaeru opened this issue Jun 17, 2024 · 1 comment · Fixed by #141
Closed

Adjust for NumPy 2.0.0 #140

khaeru opened this issue Jun 17, 2024 · 1 comment · Fixed by #141
Assignees

Comments

@khaeru
Copy link
Owner

khaeru commented Jun 17, 2024

With the release of NumPy 2.0.0, we see failures of the "pytest" GitHub Actions workflow, like here:

=========================== short test summary info ============================
FAILED genno/tests/compat/test_compat.py::test_import_pyam - AttributeError: `np.string_` was removed in the NumPy 2.0 release. Use `np.bytes_` instead.. Did you mean: 'strings'?
FAILED genno/tests/core/test_computer.py::test_require_compat - AttributeError: `np.string_` was removed in the NumPy 2.0 release. Use `np.bytes_` instead.. Did you mean: 'strings'?
FAILED genno/tests/core/test_exceptions.py::test_computationerror_ipython - KeyError: 'evalue'
FAILED genno/tests/test_operator.py::test_unique_units_from_dim[attrseries] - AssertionError: Regex pattern did not match.
 Regex: "Non-unique units \\['kg', 'km'\\] for .* 'Baz'"
 Input: "Non-unique units [np.str_('kg'), np.str_('km')] for AttrSeries 'Baz'"
FAILED genno/tests/test_operator.py::test_unique_units_from_dim[sparsedataarray] - AssertionError: Regex pattern did not match.
 Regex: "Non-unique units \\['kg', 'km'\\] for .* 'Baz'"
 Input: "Non-unique units [np.str_('kg'), np.str_('km')] for SparseDataArray 'Baz'"
FAILED genno/tests/core/test_quantity.py::TestQuantity::test_ffill[sparsedataarray] - ImportError: numpy.core.multiarray failed to import
ERROR genno/tests/compat/test_pyam.py - AttributeError: `np.string_` was removed in the NumPy 2.0 release. Use `np.bytes_` instead.. Did you mean: 'strings'?
ERROR genno/tests/compat/test_pyam.py - AttributeError: `np.string_` was removed in the NumPy 2.0 release. Use `np.bytes_` instead.. Did you mean: 'strings'?

These appear to be:

  1. "AttributeError: np.string_ was removed" → pandera not compatible with numpy 2.0 unionai-oss/pandera#1656 (duplicate) via ixmp4 and pyam-iamc.
  2. "ImportError: numpy.core.multiarray failed to import" → ImportError: numpy.core.multiarray failed to import with NumPy 2.0.0 pydata/bottleneck#453. This appears to occur only when doing SparseDataArray.ffill().
  3. Others: these fail because np.str_ instead of ordinary Python str are compared.

See also numpy/numpy#26191 for the status of other packages.

Fix for (3):

  • Adjust the code.

Mitigations for (1), (2)—some or all of:

  • Exclude NumPy 2.0.0 from CI.
  • Warn in docs, linking to this issue.
  • Wait for the upstream projects to fix those issues and make new releases.
  • Remove the work-around/mitigation.
@khaeru
Copy link
Owner Author

khaeru commented Aug 9, 2024

  1. "AttributeError: np.string_ was removed" → pandera not compatible with numpy 2.0 unionai-oss/pandera#1656 (duplicate) via ixmp4 and pyam-iamc.
  • The pandera issue was resolved upstream.
  • pyam-iamc 2.2.4 was released with Remove numpy pin IAMconsortium/pyam#871 removing the pin, so it is no longer necessary to override it in the genno CI workflow.

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 a pull request may close this issue.

1 participant