Skip to content

Commit

Permalink
Use relative imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews committed Jan 20, 2022
1 parent 609a362 commit f39c7fb
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 48 deletions.
4 changes: 2 additions & 2 deletions flopy/discretization/unstructuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def plot(self, **kwargs):
lc : matplotlib.collections.LineCollection
"""
from flopy.plot import PlotMapView
from ..plot import PlotMapView

layer = 0
if "layer" in kwargs:
Expand Down Expand Up @@ -837,7 +837,7 @@ def ncpl_from_ihc(ihc, iac):
number of cells per plottable layer
"""
from flopy.utils.gridgen import get_ia_from_iac
from ..utils.gridgen import get_ia_from_iac

valid = False
ia = get_ia_from_iac(iac)
Expand Down
2 changes: 1 addition & 1 deletion flopy/discretization/vertexgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def plot(self, **kwargs):
lc : matplotlib.collections.LineCollection
"""
from flopy.plot import PlotMapView
from ..plot import PlotMapView

mm = PlotMapView(modelgrid=self)
return mm.plot_grid(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion flopy/export/shapefile_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def get_spatialreference(epsg, text="esriwkt"):
url : str
"""
from flopy.utils.flopy_io import get_url_text
from ..utils.flopy_io import get_url_text

epsg_categories = (
"epsg",
Expand Down
8 changes: 4 additions & 4 deletions flopy/export/vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import os
import warnings
import numpy as np
from flopy.datbase import DataType, DataInterface
from flopy.utils import Util3d
from ..datbase import DataType, DataInterface
from ..utils import Util3d

from ..utils import import_optional_dependency

Expand Down Expand Up @@ -1836,7 +1836,7 @@ def export_heads(
if vtk_grid_type != "auto":
warnings.warn("vtk_grid_type is deprecated, setting to binary")

from flopy.utils import HeadFile
from ..utils import HeadFile

if not os.path.exists(otfolder):
os.mkdir(otfolder)
Expand Down Expand Up @@ -1926,7 +1926,7 @@ def export_cbc(
if vtk_grid_type != "auto":
warnings.warn("vtk_grid_type is deprecated, setting to binary")

from flopy.utils import CellBudgetFile
from ..utils import CellBudgetFile

if not os.path.exists(otfolder):
os.mkdir(otfolder)
Expand Down
4 changes: 2 additions & 2 deletions flopy/mbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from subprocess import Popen, PIPE, STDOUT
import copy
import numpy as np
from flopy import utils, discretization
from . import utils, discretization
from .version import __version__
from .discretization.grid import Grid

Expand Down Expand Up @@ -1584,7 +1584,7 @@ def plot(self, SelPackList=None, **kwargs):
>>> ml.plot()
"""
from flopy.plot import PlotUtilities
from .plot import PlotUtilities

axes = PlotUtilities._plot_model_helper(
self, SelPackList=SelPackList, **kwargs
Expand Down
2 changes: 1 addition & 1 deletion flopy/mf6/data/mfdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def _tas_info(tas_str):
return None, None

def export(self, f, **kwargs):
from flopy.export import utils
from ...export import utils

if (
self.data_type == DataType.array2d
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/data/mfdataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ def plot(
Empty list is returned if filename_base is not None. Otherwise
a list of matplotlib.pyplot.axis is returned.
"""
from flopy.plot import PlotUtilities
from ...plot import PlotUtilities

if not self.plottable:
raise TypeError(
Expand Down Expand Up @@ -1902,7 +1902,7 @@ def plot(
Empty list is returned if filename_base is not None. Otherwise
a list of matplotlib.pyplot.axis is returned.
"""
from flopy.plot.plotutil import PlotUtilities
from ...plot.plotutil import PlotUtilities

if not self.plottable:
raise TypeError("Simulation level packages are not plottable")
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/data/mfdatalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ def plot(
Empty list is returned if filename_base is not None. Otherwise
a list of matplotlib.pyplot.axis is returned.
"""
from flopy.plot import PlotUtilities
from ...plot import PlotUtilities

if not self.plottable:
raise TypeError("Simulation level packages are not plottable")
Expand Down Expand Up @@ -1930,7 +1930,7 @@ def plot(
Empty list is returned if filename_base is not None. Otherwise
a list of matplotlib.pyplot.axis is returned.
"""
from flopy.plot import PlotUtilities
from ...plot import PlotUtilities

if not self.plottable:
raise TypeError("Simulation level packages are not plottable")
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/data/mfdatascalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def plot(self, filename_base=None, file_extension=None, **kwargs):
Returns:
axes: list matplotlib.axes object
"""
from flopy.plot.plotutil import PlotUtilities
from ...plot.plotutil import PlotUtilities

if not self.plottable:
raise TypeError("Scalar values are not plottable")
Expand Down Expand Up @@ -967,7 +967,7 @@ def plot(
Empty list is returned if filename_base is not None. Otherwise
a list of matplotlib.pyplot.axis is returned.
"""
from flopy.plot.plotutil import PlotUtilities
from ...plot.plotutil import PlotUtilities

if not self.plottable:
raise TypeError("Simulation level packages are not plottable")
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/mfmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..discretization.vertexgrid import VertexGrid
from ..discretization.unstructuredgrid import UnstructuredGrid
from ..discretization.grid import Grid
from flopy.discretization.modeltime import ModelTime
from ..discretization.modeltime import ModelTime
from ..mbase import ModelInterface
from .utils.mfenums import DiscretizationType
from .data import mfstructure
Expand Down Expand Up @@ -1871,7 +1871,7 @@ def plot(self, SelPackList=None, **kwargs):
Empty list is returned if filename_base is not None. Otherwise
a list of matplotlib.pyplot.axis are returned.
"""
from flopy.plot.plotutil import PlotUtilities
from ..plot.plotutil import PlotUtilities

axes = PlotUtilities._plot_model_helper(
self, SelPackList=SelPackList, **kwargs
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/mfpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2868,7 +2868,7 @@ def export(self, f, **kwargs):
None or Netcdf object
"""
from flopy import export
from .. import export

return export.utils.package_export(f, self, **kwargs)

Expand Down Expand Up @@ -2903,7 +2903,7 @@ def plot(self, **kwargs):
a list of matplotlib.pyplot.axis are returned.
"""
from flopy.plot.plotutil import PlotUtilities
from ..plot.plotutil import PlotUtilities

if not self.plottable:
raise TypeError("Simulation level packages are not plottable")
Expand Down
2 changes: 1 addition & 1 deletion flopy/mf6/modflow/mfsimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2456,7 +2456,7 @@ def plot(self, model_list=None, SelPackList=None, **kwargs):
matplotlib.pyplot.axes objects
"""
from flopy.plot.plotutil import PlotUtilities
from ...plot.plotutil import PlotUtilities

axes = PlotUtilities._plot_simulation_helper(
self, model_list=model_list, SelPackList=SelPackList, **kwargs
Expand Down
1 change: 1 addition & 0 deletions flopy/mf6/utils/createpackages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import textwrap
from enum import Enum
# keep below as absolute imports
from flopy.mf6.data import mfstructure, mfdatautil
from flopy.utils import datautil

Expand Down
2 changes: 1 addition & 1 deletion flopy/modflow/mf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ..discretization.structuredgrid import StructuredGrid
from ..discretization.unstructuredgrid import UnstructuredGrid
from ..discretization.grid import Grid
from flopy.discretization.modeltime import ModelTime
from ..discretization.modeltime import ModelTime
from .mfpar import ModflowPar


Expand Down
18 changes: 9 additions & 9 deletions flopy/modflow/mfsfr2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2061,8 +2061,8 @@ def write_file(self, filename=None):

def export(self, f, **kwargs):
if isinstance(f, str) and f.lower().endswith(".shp"):
from flopy.utils.geometry import Polygon
from flopy.export.shapefile_utils import recarray2shp
from ..utils.geometry import Polygon
from ..export.shapefile_utils import recarray2shp

geoms = []
for ix, i in enumerate(self.reach_data.i):
Expand All @@ -2072,7 +2072,7 @@ def export(self, f, **kwargs):
geoms.append(Polygon(verts))
recarray2shp(self.reach_data, geoms, shpname=f, **kwargs)
else:
from flopy import export
from .. import export

return export.utils.package_export(f, self, **kwargs)

Expand All @@ -2083,8 +2083,8 @@ def export_linkages(self, f, **kwargs):
reaches can be used to filter for the longest connections in a GIS.
"""
from flopy.utils.geometry import LineString
from flopy.export.shapefile_utils import recarray2shp
from ..utils.geometry import LineString
from ..export.shapefile_utils import recarray2shp

rd = self.reach_data.copy()
m = self.parent
Expand Down Expand Up @@ -2126,8 +2126,8 @@ def export_outlets(self, f, **kwargs):
the model (outset=0).
"""
from flopy.utils.geometry import Point
from flopy.export.shapefile_utils import recarray2shp
from ..utils.geometry import Point
from ..export.shapefile_utils import recarray2shp

rd = self.reach_data
if np.min(rd.outreach) == np.max(rd.outreach):
Expand Down Expand Up @@ -2160,8 +2160,8 @@ def export_transient_variable(self, f, varname, **kwargs):
Variable in SFR Package dataset 6a (see SFR package documentation)
"""
from flopy.utils.geometry import Point
from flopy.export.shapefile_utils import recarray2shp
from ..utils.geometry import Point
from ..export.shapefile_utils import recarray2shp

rd = self.reach_data
if np.min(rd.outreach) == np.max(rd.outreach):
Expand Down
2 changes: 1 addition & 1 deletion flopy/mt3d/mt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .mtsft import Mt3dSft
from .mtlkt import Mt3dLkt
from ..discretization.structuredgrid import StructuredGrid
from flopy.discretization.modeltime import ModelTime
from ..discretization.modeltime import ModelTime


class Mt3dList(Package):
Expand Down
6 changes: 3 additions & 3 deletions flopy/pakbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,13 @@ def export(self, f, **kwargs):
None or Netcdf object
"""
from flopy import export
from . import export

return export.utils.package_export(f, self, **kwargs)

def _generate_heading(self):
"""Generate heading."""
from flopy import __version__
from . import __version__

parent = self.parent
self.heading = (
Expand Down Expand Up @@ -821,7 +821,7 @@ def plot(self, **kwargs):
>>> ml.dis.plot()
"""
from flopy.plot import PlotUtilities
from .plot import PlotUtilities

if not self.plottable:
raise TypeError(f"Package {self.name} is not plottable")
Expand Down
2 changes: 1 addition & 1 deletion flopy/seawat/swt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .swtvdf import SeawatVdf
from .swtvsc import SeawatVsc
from ..discretization.structuredgrid import StructuredGrid
from flopy.discretization.modeltime import ModelTime
from ..discretization.modeltime import ModelTime


class SeawatList(Package):
Expand Down
2 changes: 1 addition & 1 deletion flopy/utils/datafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def plot(
).transpose()
).transpose()

from flopy.plot.plotutil import PlotUtilities
from ..plot.plotutil import PlotUtilities

return PlotUtilities._plot_array_helper(
plotarray,
Expand Down
12 changes: 6 additions & 6 deletions flopy/utils/util_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def plottable(self):
return True

def export(self, f, **kwargs):
from flopy import export
from .. import export

return export.utils.array3d_export(f, self, **kwargs)

Expand Down Expand Up @@ -726,7 +726,7 @@ def plot(
>>> ml.lpf.hk.plot()
"""
from flopy.plot import PlotUtilities
from ..plot import PlotUtilities

axes = PlotUtilities._plot_util3d_helper(
self,
Expand Down Expand Up @@ -1530,7 +1530,7 @@ def plot(
>>> ml.rch.rech.plot()
"""
from flopy.plot import PlotUtilities
from ..plot import PlotUtilities

axes = PlotUtilities._plot_transient2d_helper(
self,
Expand Down Expand Up @@ -1586,7 +1586,7 @@ def array(self):
return arr

def export(self, f, **kwargs):
from flopy import export
from .. import export

return export.utils.transient2d_export(f, self, **kwargs)

Expand Down Expand Up @@ -1984,7 +1984,7 @@ def plot(
>>> ml.dis.top.plot()
"""
from flopy.plot import PlotUtilities
from ..plot import PlotUtilities

axes = PlotUtilities._plot_util2d_helper(
self,
Expand All @@ -1997,7 +1997,7 @@ def plot(
return axes

def export(self, f, **kwargs):
from flopy import export
from .. import export

return export.utils.array2d_export(f, self, **kwargs)

Expand Down
4 changes: 2 additions & 2 deletions flopy/utils/util_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_empty(self, ncell=0):
return d

def export(self, f, **kwargs):
from flopy import export
from .. import export

return export.utils.mflist_export(f, self, **kwargs)

Expand Down Expand Up @@ -943,7 +943,7 @@ def plot(
"""

from flopy.plot import PlotUtilities
from ..plot import PlotUtilities

axes = PlotUtilities._plot_mflist_helper(
self,
Expand Down
Loading

0 comments on commit f39c7fb

Please sign in to comment.