equinor / ert

ERT - Ensemble based Reservoir Tool - is designed for running ensembles of dynamical models such as reservoir models, in order to do sensitivity analysis and data assimilation. ERT supports data assimilation using the Ensemble Smoother (ES), Ensemble Smoother with Multiple Data Assimilation (ES-MDA) and Iterative Ensemble Smoother (IES).
https://ert.readthedocs.io/en/latest/
GNU General Public License v3.0
99 stars 104 forks source link

Add NPY to ruff rules with some numpy 2 support #8145

Closed larsevj closed 3 weeks ago

larsevj commented 1 month ago

When applicable

eivindjahren commented 1 month ago

We quite often use np.float32, so I am not sure if this is correctly typed.

larsevj commented 1 month ago

I will check if it is possible to be more spesific, np.float_ is in any case just a deprecated alias for np.float64 -> np.double

codecov-commenter commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.61%. Comparing base (091a179) to head (823a6b6). Report is 11 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #8145 +/- ## ========================================== + Coverage 86.57% 86.61% +0.04% ========================================== Files 383 384 +1 Lines 23783 23831 +48 Branches 622 619 -3 ========================================== + Hits 20589 20641 +52 + Misses 3113 3109 -4 Partials 81 81 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

eivindjahren commented 1 month ago

If it should work with both 32-bit and 64-bit there is np.floating.

larsevj commented 1 month ago

np.floating[Any] does not seem to work with python3.8, so a bit unsure what do to about the more general instances.

eivindjahren commented 1 month ago

You can use from __future__ import annotations to have the types only be interpreted when mypy runs. mypy runs using python 3.12.

larsevj commented 3 weeks ago

I believe trying to figure out which function/variable is allowed/might be float32 vs float64 is a bigger task and might better have its own issue(?). This change (PR) will only bring into light the fact that we might not have typed hint correctly before?