-
Notifications
You must be signed in to change notification settings - Fork 318
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
chore: switch to ruff, numpy compat fixes, ignore known test warnings #2124
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2124 +/- ##
=========================================
- Coverage 73.1% 73.1% -0.1%
=========================================
Files 259 259
Lines 59513 59511 -2
=========================================
- Hits 43517 43514 -3
- Misses 15996 15997 +1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes all seem good to me. I like the cleanup of the bool comparisons and removal of unnecessary f-strings.
Ruff will do "safe" cleanups like those automatically with |
The docs for `np.where()` (https://numpy.org/doc/stable/reference/generated/numpy.where.html) suggest to prefer `nonzero()` over `where()` without `x` and `y` arguments. In the spirit of defensive programming I included `np.asarray(cond)` even where `cond` is already an array. This PR also fixes a bug I introduced in the model splitter in modflowpy#2124: while E711 (https://www.flake8rules.com/rules/E711.html) dictates comparisons to `None` should use identity rather than equality, this rule should not be applied to NumPy array selection conditions as it will change the semantics: ```shell >>> a = np.array([None, None]) >>> a[a != None] array([], dtype=object) >>> a[a is not None] array([[None, None]], dtype=object) ``` Unrelatedly, mark `test_mt3d.py::test_mfnwt_keat_uzf()` slow, it should not be included in smoke tests.
The docs for `np.where()` (https://numpy.org/doc/stable/reference/generated/numpy.where.html) suggest to prefer `nonzero()` over `where()` without `x` and `y` arguments. In the spirit of defensive programming I included `np.asarray(cond)` even where `cond` is already an array. This PR also fixes a bug I introduced in the model splitter in modflowpy#2124: while E711 (https://www.flake8rules.com/rules/E711.html) dictates comparisons to `None` should use identity rather than equality, this rule should not be applied to NumPy array selection conditions as it will change the semantics: ```shell >>> a = np.array([None, None]) >>> a[a != None] array([], dtype=object) >>> a[a is not None] array([[None, None]], dtype=object) ``` Unrelatedly, mark `test_mt3d.py::test_mfnwt_keat_uzf()` slow, it should not be included in smoke tests.
The docs for `np.where()` (https://numpy.org/doc/stable/reference/generated/numpy.where.html) suggest to prefer `nonzero()` over `where()` without `x` and `y` arguments. In the spirit of defensive programming I included `np.asarray(cond)` even where `cond` is already an array. This PR also fixes a bug I introduced in the model splitter in #2124: while E711 (https://www.flake8rules.com/rules/E711.html) dictates comparisons to `None` should use identity rather than equality, this rule should not be applied to NumPy array selection conditions as it will change the semantics: >>> a = np.array([None, None]) >>> a[a != None] array([], dtype=object) >>> a[a is not None] array([[None, None]], dtype=object) Unrelatedly, mark `test_mt3d.py::test_mfnwt_keat_uzf()` slow, it should not be included in smoke tests (this was causing the optional dependency CI tests to fail due to timeout). And clean up some unused imports in `conftest.py`.
pyproject.toml
ruff check --select NPY201
as suggested here, replace deprecated syntaxnp.float_
->np.float64
np.NaN
->np.nan