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

AttributeError occurs during pytest in /tests #178

Open
miriabeh opened this issue Jul 15, 2024 · 12 comments
Open

AttributeError occurs during pytest in /tests #178

miriabeh opened this issue Jul 15, 2024 · 12 comments

Comments

@miriabeh
Copy link

running pytest in tests creates an ErrorMessage:
AttributeError: np.float_ was removed in the NumPy 2.0 release. Use np.float64 instead.. Did you mean: 'float16'?

temporary solution:
install a different numpy version, that is of version <2.0.0
pip install 'numpy<2.0.0'

@SabineHaas
Copy link
Member

I cannot reproduce the error. Which version of oemof.tabular do you have installed? When I run pytest with the up-to-date dev branch I don't get any error.

@miriabeh
Copy link
Author

I reinstalled Anaconda3-2024.06-1-Linux-x86_64.sh and the version of oemof-tabular is 0.0.5. I did clone the repo shortly before trying pytest. The environment was created with conda create –name oemof-tabular 'python=3.9‘, pip install oemof.tabular and pip install pytest only.

@MaGering
Copy link
Contributor

MaGering commented Jul 30, 2024

I cannot reproduce the error. Which version of oemof.tabular do you have installed? When I run pytest with the up-to-date dev branch I don't get any error.

Hi @SabineHaas ! If I install via pip install -e . I do not get further errors except for this:

========================================================================================================== short test summary info ===========================================================================================================
ERROR tests/test_constraints.py - AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.
ERROR tests/test_examples.py - AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.
ERROR tests/test_multi_period_constraints.py - AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.
ERROR tests/test_oemof_tabular.py - AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.
ERROR tests/test_postprocessing.py - AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 5 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================================= 5 errors in 1.36s ==============================================================================================================

Here as @miriabeh mentions pip install 'numpy<2.0.0' solves the problem. So a fix on dev should be done right?

And afterwards dev should be released as a hot fix for the main branch, which fails checks right now due to #179.

@SabineHaas
Copy link
Member

SabineHaas commented Jul 31, 2024

I've just checked: numpy is not a requirement of oemof.tabular (see setup.py). First thing would be to check which package it comes with. The fix would have to be done there.
You can use pipdeptree for that.

@MaGering
Copy link
Contributor

MaGering commented Jul 31, 2024

Yes that's true. It comes with oemof.solph. Compare these two:

https://github.com/oemof/oemof-solph/blob/v0.5.2.dev1/setup.py (our current dependency - numpy not fixed)
https://github.com/oemof/oemof-solph/blob/v0.5.3a2/pyproject.toml (potential fututre dependency - numpy < 2.0.0)

@miriabeh could you please create a branch on oemof.tabular locally with a modified setup.py which installs oemof.solph v0.5.3a2 and run all tests? I fear the tests will fail due to the progress in oemof.solph and there will be work for us oemof.tabular developers. The alternative for the transition would be my suggestion to fix numpy here and note that we did this because of the pyomo bug and it needs to be reverted once the bug is fixed in that repo.

@miriabeh
Copy link
Author

miriabeh commented Aug 13, 2024

As predicted, not all tests run without failing.

These are the Errors:
ErrorsOemoefTabular

@MaGering
Copy link
Contributor

@SabineHaas what do you think? Should there be a quick fix on dev before the next release?

@SabineHaas
Copy link
Member

Yes, for the a release the tests should pass in my opinion.
Are these failing tests connected to the numpy issue?

@MaGering
Copy link
Contributor

Last time I checked on dev fixing numpy the tests have passed.

@SabineHaas
Copy link
Member

SabineHaas commented Aug 14, 2024

Ah sorry, I haven't missed the messages above: @miriabeh has updated to another solph version which is probably why the tests are failing.
As there is a newer version of solph I would rather go for v0.5.3, what do you think @MaGering ?

Edit: alternatively we could try a fix in tabular. If we add a numpy requirement after the solph requirement, this should work, as well, I think.

@MaGering
Copy link
Contributor

I guess the newer solph version will also have tests failing because of the progress happened there. We will need to integrate it in our code. I mean it has to be done sooner or later. If you have the capacities it would be nice. But if not, the quick fix with numpy will surely do it for now. But in my opinion it is important that the latest tabular version works. :)

@SabineHaas
Copy link
Member

I did a quick fix #181

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