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

Release 3.9.0 #2397

Merged
merged 45 commits into from
Dec 20, 2024
Merged

Release 3.9.0 #2397

merged 45 commits into from
Dec 20, 2024

Conversation

github-actions[bot]
Copy link
Contributor

FloPy 3.9.0

The release can be approved by merging this pull request into master. This will trigger a final job to publish the release to PyPI.

wpbonelli and others added 30 commits October 3, 2024 11:55
…rossSection (#2318)

* Feat(plot_centers): add plot_centers support to PlotMapView and PlotCrossSection

fixes and updates included with feature:

* filter very short/small intersection segments from cross-sectional plotting routine
* sort and assure vertex order is correct for intersected cross-sectional segments
* improve geometry.project_point_onto_xc_line() calculation routine.
* update reproject_modpath_to_crosssection()

* linting

* fix filter_line_segments(), catch and filter single vertex intersections

* add testing for plot_centers()

* add projctr attribute to PlotCrossSection for testing purposes

* lint autotests
* Fix(ZoneFile6.load): Add split statement to input read

* downgrade setup-micromamba to v1

Based on mamba issue discussion #3475
* remove nan masking from standard scipy resampling methods
* allow extrapolate_edges kwarg to be applied to nearest neighbor resampling
* drop support for python 3.8 since it's now EOL
* python 3.13 does not support VTK yet
…2324)

First steps toward shrinking the inheritance hierarchy. Components (simulation/model/package) now have a PackageContainer instead of being one. APIs which are clearly public remain the same. Visibility is tweaked for a few methods which were previously "private" (leading underscore) but seem user-facing. A number of methods which seem internal-only and/or are redundant with other APIs are deprecated.
The CI test step was suppressing errors, I think because we ran coverage immediately after. Move coverage to a subsequent step. This reveals a few failing tests which are not addressed in this changeset.
Fix tests whose failures were suppressed before #2335:

* skip snapshot on mac for test_mp7.py::test_mp7_output, mp7 results differ slightly for some reason
* fix the venv bin/lib directory names on Windows in test_generate_classes.py
…as (#2340)

This PR exposes the porosity parameter of Modpath7Bas in Modpath7's convenience method, create_mp7. This idea is raised in #2339.
…2314)

Addresses the issue raised in discussion #2309.

fix(MFPandasTransientList.masked_4D_arrays_itr): allow re-use of preceding spd data if empty (mf6)

    * generalize setting of array shape for different grid types
    * re-use preceding spd array data
    * update relevant test

fix(MfList.masked_4d_arrays): allow re-use of preceding spd data if empty (non-mf6)

    * generalize setting of array shape for different grid types
    * re-use preceding spd array data

fix(model_attributes_to_shapefile): fix exporting of transientlist if disu

    * create separate case for disu
    * update relevant test

test(masked_4D_arrays): add tests

    * compare mf6 and non-mf6 shp export (riv data)

refactor(MFTransientList): re-use masked_4D_arrays_itr implementation
refactor(model_attributes_to_shapefile): remove bare except
refactor(model_attributes_to_shapefile): skip transientlist if empty
refactor(model_attributes_to_shapefile): skip transientlist if all elements are of object type

    * if package has timeseries data, transientlist elements are all of object type

refactor(mflist_export): skip mflist if all elements are of object type

    * if package has timeseries data, mflist elements are all of object type

fix(mfUsgDisU): return ncpl as integer
refactor(model_attributes_to_shapefile): use first recarray kper to check transientlist
refactor(mflist_export): use first recarray kper to check mflist
Python 3.13 was recently released, which works fine with most of flopy's functionality.

VTK and PyVista do not yet support Python 3.13 from PyPI, as specified with conditional expressions. Pymetis is not yet available for 3.13 from conda-forge. Thus testing has been removed for now. For reference, use this doc to try and install Python and packages for 3.13.

Nevertheless, local testing on linux works with this PR for PyPI using pip install -e .[test,optional] which installs everything except VTK and PyVista.
This PR addresses #2344 and does the following:

    * Add DeprecationWarning when method != "vertex"
    * Remove all Shapely<2.0 code
    * Remove warnings filters for older numpy versions
    * Mark methods/tests that should be removed when method="structured" is officially removed
    * Ensure full test suite is maintained after removal of structured tests.
    * Move raster tests to a separate file.
    * Add option to return intersection results as (Geo)DataFrame
    * Allow plotting options to take as input GeoDataFrame (bit unnecessary as they have their own plotting logic) and improve plotting results.
    * Add plot_intersection_result() to plot result + modelgrid (optional).
    * Update example notebook.

Note: Tests for 3D point intersections above/inside grid are deactivated. This is not yet working for method="vertex". Will probably be added in a separate PR.
Fix #2342:

    * fix typo in shapely.multilinestrings
    * fix issue with np.apply_along_axis
    * consider geometry collections when computing overlaps
    * add test for vertex mode
    * add inactive test for structured mode (not yet working)

Notes:

    * np.apply_along_axis was reducing result from multiple GeometryCollections to a single MultiLineString causing duplication of shapes in the intersection result.
    * structured support will be dropped in future releases (see #2344)
* update(Mf6Splitter): added split_multi_model method
* split_multi_model method allows splitting of connected GWF-GWT models
* update exchange remapping for GWT support
* add testing for split_multi_model()
*  update to MFScalarTranient remapping
Deprecate the MF6 check mechanism. The sense after discussion is that the checks have limited utility at the moment, a few relevance/correctness issues, and see little use. Consider either reworking/replacing them in 3.x in a backwards-compatible way, or removing them and making the .check() methods on simulation model/package base classes no-ops, pending a 4.x rework.  Deprecating should help to determine if anyone is relying on them while we investigate how deeply they are woven into the existing framework.
This PR refactors the codebase with Ruff's pyupgrade check, based on pyupgrade. Not all suggestions are applied, and some manual edits were applied in addition to the affected code. Removing target-version from the ruff options allows this to be automatically evaluated from pyproject.toml.

The rules that were applied include:

- UP004 (useless-object-inheritance)
- UP006 (non-pep585-annotation) - see PEP 585 for details; this was not applied to get_modflow.py to maintain it's compatibility for older Python versions in stand-alone mode
- UP018 (native-literals)
- UP034 (extraneous-parentheses)
- UP035 (deprecated-import)

Meanwhile, these rules were somewhat ignored:

- UP031,UP032: related to upgrading to f-strings. Ignored since these could involve much more string and message related refactoring to adjacent code. However, a few upgraded f-strings are upgraded where it looks simple, and in user-facing docs.
- UP015: for redundant file modes. Kept default file modes (e.g. open(..., "r") to keep it more clear, e.g. when a file pointer object is left open for reading (and then closed many lines further down, as is often done with legacy flopy code)
Codacy began detecting a "severe" pylint E1126 invalid sequence index violation in #2362.

The issue pre-existed that PR, I think the format changes just revealed it. We could just ignore it in the web UI but this is probably worth coming back to, to appease linters and type checkers and to make the code easier to reason about.

Relatedly, there is work ongoing to make ruff work with codacy, so hopefully in future we can use ruff ignore syntax for things like this if/when needed
The codebase currently has a line length limit of 79 (via #954) as suggested in PEP 8 (which is related to a 80 char limit of decades old IBM punch cards and terminals). However, longer line lengths are generally encouraged for modern Python development, which is a language that commonly has four-space indents needed to define logic structures, thus requiring more horizontal space than other programming languages.

Black has a default of 88, which is the same default for Ruff. Is this the ideal length for the flopy codebase? Not sure, but a quick scan of the suggested changes look much better.

Despite the size of this PR, it was quickly automated using these ruff commands (including quick fixes to ISC001):

ruff format
ruff check --select ISC001 --fix
ruff format

There are no functional changes in this PR, thus the code "runs the same". As such, .git-blame-ignore-revs can be amended to ignore these changes with (e.g.) GitHub's blame view (this would be a follow-up PR).
This refactor resolves long line checks. See ruff check code E501 for more.
Clear some "noise" when using GitHub's "blame view" UI tool to see changes in code history for individual files.

These commits are chosen as they are mostly style-related changes rather than code refactors (minor refactors are OK):

- de38a5b
- 675d12b
- 2912b1d
- 5d4324d
- 16b84e8
- b142b08
- 12a3bcd
Add configuration for codespell, to check spelling, with suggested changes. Also add this check to the "Lint" job, and fix a few outstanding typos since last done with #2160.
wpbonelli and others added 15 commits November 15, 2024 07:11
This is a minor refactor to resolve F821 for undefined name.

As with other checks, "flopy/mf6/**/*.py" is ignored (which currently has several F821 issues).
Creates visualizations of the import statements in the code.
See DEVELOPER.md on how to use it
This PR applies the automated "unsafe fix" suggestions from ruff check C4 for comprehensions. All of the changes look like good simplifications.
…2375)

The flopy.mf6.utils.reference module contains spatial reference classes similar to those deprecated/removed in #1914#1892, and #1200. These are not in use anywhere in the codebase. The flopy.discretization module can/should be used instead.

---------

Co-authored-by: Mike Taves <mwtoews@gmail.com>
Apply Ruff-specific rule (RUF) checks 

* RUF002, RUFF003: ambiguous Unicode character
* RUF013: implicit optional
* RUF100: unused noqa
* RUF015: unnecessary iterable allocation for first element, i.e. use next()
Refactor some multi-line statements. This was mostly automated by temporarily toggling this control in pyproject.toml:

[tool.ruff.format]
skip-magic-trailing-comma = true

then selecting some commits that condense multi-line statements to single, while rejecting other statements that are better represented over multiple lines. There was no exact rule-of-thumb for the process, except to try and maintain the same style in surrounding code blocks. Class constructors or instantiations of some classes with many parameters are kept as multi-line.

Note that while there are over 2300 fewer lines with this changeset, there are no functional changes.
…rs (#2380)

Fix a recent CI failure that uses the latest VTK package (9.4.0). The tests are changed from simple counting number of lines to checking attributes in the XML file using built-in XML tools, which should be more robust.

Binary wheels for vtk are now available for Python 3.13, so the conditional installs are removed for vtk and pyvista.
Close #2382. Also remove the need for tdis in the reversal methods by inferring period length etc from data headers.
The setup.py file was converted to a setuptools wrapper with #1678. This file is not used in this project, and modern pip/setuptools don't look for it anymore, so it can be cleaned up.
First step towards #1872. Use pooch for data access. This is ugly, but it makes notebooks runnable (provided exes and python environment) out of the box. Local files will be used if detected, otherwise downloaded, following the pattern in the mf6 example models.

An eventual models API could hide all the details of model access.

Also mention the optional dependencies requirement on the tutorials and examples gallery pages.
@wpbonelli wpbonelli marked this pull request as ready for review December 20, 2024 02:22
@wpbonelli wpbonelli merged commit 0820544 into master Dec 20, 2024
1 check passed
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 this pull request may close these issues.

8 participants