oemof / oemof-tabular

Load oemof energy systems from tabular data sources.
https://oemof-tabular.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
7 stars 5 forks source link

AttributeError occurs during pytest in /tests #178

Open miriabeh opened 3 months ago

miriabeh commented 3 months ago

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 commented 3 months ago

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 commented 2 months ago

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 commented 2 months ago

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 https://github.com/oemof/oemof-tabular/issues/179.

SabineHaas commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

As predicted, not all tests run without failing.

These are the Errors: ErrorsOemoefTabular

MaGering commented 2 months ago

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

SabineHaas commented 2 months ago

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

MaGering commented 2 months ago

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

SabineHaas commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

I did a quick fix https://github.com/oemof/oemof-tabular/pull/181