Skip to content

Commit

Permalink
refactor(imports): add function to import optional packages
Browse files Browse the repository at this point in the history
matplotlib is now a FloPy requirement.

Closes modflowpy#1257
  • Loading branch information
jdhughes-usgs committed Oct 13, 2021
1 parent 5113cfd commit c6723f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/flopy_method_dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ Additional dependencies to use optional FloPy helper methods are listed below.
| `Raster().sample_polygon()` in `flopy.utils.Raster` | **shapely** |
| `Raster().crop()` in `flopy.utils.Raster` | **shapely** |
| `.array_at_verts()` in `flopy.discretization.structuredgrid` `StructuredGrid` class | **scipy.interpolate** |
| `get_sciencebase_xml_metadata()` in `flopy.export.metadata` `acdd` class | **defusedxml** |
| `flopy.utils.geospatial_utils` `GeoSpatialUtil` class | **geojson** |
| `flopy.utils.geospatial_utils` `GeoSpatialCollection` class | **geojson** |
| `flopy.export.vtk` `Vtk` class | **vtk** |
2 changes: 1 addition & 1 deletion flopy/utils/gridintersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def __init__(self, mfgrid, method=None, rtree=True):
if self.rtree:
strtree = import_optional_dependency(
"shapely.strtree",
extra="STRTree requires shapely",
error_message="STRTree requires shapely",
)
self.strtree = strtree.STRtree(self._get_gridshapes())

Expand Down
4 changes: 2 additions & 2 deletions flopy/utils/utl_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

from .parse_version import Version

# Update install.rst when updating versions!
# Update docs/flopy_method_dependencies.md when updating versions!

VERSIONS = {
"shapefile": "2.0.0",
Expand Down Expand Up @@ -104,7 +104,7 @@ def import_optional_dependency(
* silent: Same as "ignore" except warning message is not written to
the screen.
min_version : str, default None
Specify a minimum version that is different from the global pandas
Specify a minimum version that is different from the global FloPy
minimum version required.
Returns
-------
Expand Down

0 comments on commit c6723f4

Please sign in to comment.