Skip to content

Commit

Permalink
refactor(rtd): refactor functions to hide private functions (#989)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs authored Sep 3, 2020
1 parent bcb68a6 commit 9983191
Show file tree
Hide file tree
Showing 68 changed files with 582 additions and 445 deletions.
3 changes: 2 additions & 1 deletion flopy/discretization/structuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,8 @@ def get_cell_vertices(self, i, j):
used in the Shapefile export utilities
:param i: (int) cell row number
:param j: (int) cell column number
:return: list of x,y cell vertices
Returns
------- list of x,y cell vertices
"""
self._copy_cache = False
cell_verts = [
Expand Down
3 changes: 2 additions & 1 deletion flopy/discretization/unstructuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ def get_cell_vertices(self, cellid):
Method to get a set of cell vertices for a single cell
used in the Shapefile export utilities
:param cellid: (int) cellid number
:return: list of x,y cell vertices
Returns
------- list of x,y cell vertices
"""
self._copy_cache = False
cell_vert = list(zip(self.xvertices[cellid], self.yvertices[cellid]))
Expand Down
3 changes: 2 additions & 1 deletion flopy/discretization/vertexgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def get_cell_vertices(self, cellid):
Method to get a set of cell vertices for a single cell
used in the Shapefile export utilities
:param cellid: (int) cellid number
:return: list of x,y cell vertices
Returns
------- list of x,y cell vertices
"""
self._copy_cache = False
cell_verts = list(zip(self.xvertices[cellid], self.yvertices[cellid]))
Expand Down
8 changes: 4 additions & 4 deletions flopy/modflow/mfag.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ def __init__(

# setup the package parent class
if unitnumber is None:
unitnumber = ModflowAg.defaultunit()
unitnumber = ModflowAg._defaultunit()

if filenames is None:
filenames = [None]
elif isinstance(filenames, str):
filenames = [filenames]

name = [ModflowAg.ftype()]
name = [ModflowAg._ftype()]
units = [unitnumber]
extra = [""]

Expand Down Expand Up @@ -903,11 +903,11 @@ def load(cls, f, model, nper=0, ext_unit_dict=None):
)

@staticmethod
def defaultunit():
def _defaultunit():
return 69

@staticmethod
def ftype():
def _ftype():
return "AG"

@property
Expand Down
10 changes: 5 additions & 5 deletions flopy/modflow/mfbas.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ class ModflowBas(Package):
"""

@staticmethod
def ftype():
def _ftype():
return "BAS6"

@staticmethod
def defaultunit():
def _defaultunit():
return 13

def __init__(
Expand All @@ -109,7 +109,7 @@ def __init__(
"""

if unitnumber is None:
unitnumber = ModflowBas.defaultunit()
unitnumber = ModflowBas._defaultunit()

# set filenames
if filenames is None:
Expand All @@ -118,7 +118,7 @@ def __init__(
filenames = [filenames]

# Fill namefile items
name = [ModflowBas.ftype()]
name = [ModflowBas._ftype()]
units = [unitnumber]
extra = [""]

Expand Down Expand Up @@ -394,7 +394,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True, **kwargs):
filenames = [None]
if ext_unit_dict is not None:
unitnumber, filenames[0] = model.get_ext_dict_attr(
ext_unit_dict, filetype=ModflowBas.ftype()
ext_unit_dict, filetype=ModflowBas._ftype()
)

# create bas object and return
Expand Down
12 changes: 6 additions & 6 deletions flopy/modflow/mfbcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(
):

if unitnumber is None:
unitnumber = ModflowBcf.defaultunit()
unitnumber = ModflowBcf._defaultunit()

# set filenames
if filenames is None:
Expand All @@ -130,13 +130,13 @@ def __init__(
if ipakcb is not None:
fname = filenames[1]
model.add_output_file(
ipakcb, fname=fname, package=ModflowBcf.ftype()
ipakcb, fname=fname, package=ModflowBcf._ftype()
)
else:
ipakcb = 0

# Fill namefile items
name = [ModflowBcf.ftype()]
name = [ModflowBcf._ftype()]
units = [unitnumber]
extra = [""]

Expand Down Expand Up @@ -520,7 +520,7 @@ def load(cls, f, model, ext_unit_dict=None):
filenames = [None, None]
if ext_unit_dict is not None:
unitnumber, filenames[0] = model.get_ext_dict_attr(
ext_unit_dict, filetype=ModflowBcf.ftype()
ext_unit_dict, filetype=ModflowBcf._ftype()
)
if ipakcb > 0:
iu, filenames[1] = model.get_ext_dict_attr(
Expand Down Expand Up @@ -554,9 +554,9 @@ def load(cls, f, model, ext_unit_dict=None):
return bcf

@staticmethod
def ftype():
def _ftype():
return "BCF6"

@staticmethod
def defaultunit():
def _defaultunit():
return 15
8 changes: 4 additions & 4 deletions flopy/modflow/mfbct.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def __init__(

# set default unit number of one is not specified
if unitnumber is None:
unitnumber = ModflowBct.defaultunit()
unitnumber = ModflowBct._defaultunit()

# Call ancestor's init to set self.parent, extension, name and unit
# number
Package.__init__(
self, model, extension, ModflowBct.ftype(), unitnumber
self, model, extension, ModflowBct._ftype(), unitnumber
)

self.url = "bct.htm"
Expand Down Expand Up @@ -168,9 +168,9 @@ def write_file(self):
return

@staticmethod
def ftype():
def _ftype():
return "BCT"

@staticmethod
def defaultunit():
def _defaultunit():
return 35
22 changes: 15 additions & 7 deletions flopy/modflow/mfchd.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(

# set default unit number if one is not specified
if unitnumber is None:
unitnumber = ModflowChd.defaultunit()
unitnumber = ModflowChd._defaultunit()

# set filenames
if filenames is None:
Expand All @@ -124,7 +124,7 @@ def __init__(
filenames = [filenames]

# Fill namefile items
name = [ModflowChd.ftype()]
name = [ModflowChd._ftype()]
units = [unitnumber]
extra = [""]

Expand Down Expand Up @@ -163,8 +163,16 @@ def __init__(
self.options = options
self.parent.add_package(self)

def ncells(self):
# Returns the maximum number of cells that have recharge (developed for MT3DMS SSM package)
def _ncells(self):
"""Maximum number of cells that have constant heads (developed for
MT3DMS SSM package).
Returns
-------
ncells: int
maximum number of chd cells
"""
return self.stress_period_data.mxact

def write_file(self):
Expand Down Expand Up @@ -222,7 +230,7 @@ def get_default_dtype(structured=True):
return dtype

@staticmethod
def get_sfac_columns():
def _get_sfac_columns():
return ["shead", "ehead"]

@classmethod
Expand Down Expand Up @@ -274,9 +282,9 @@ def load(cls, f, model, nper=None, ext_unit_dict=None, check=True):
)

@staticmethod
def ftype():
def _ftype():
return "CHD"

@staticmethod
def defaultunit():
def _defaultunit():
return 24
10 changes: 5 additions & 5 deletions flopy/modflow/mfde4.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(

# set default unit number of one is not specified
if unitnumber is None:
unitnumber = ModflowDe4.defaultunit()
unitnumber = ModflowDe4._defaultunit()

# set filenames
if filenames is None:
Expand All @@ -144,7 +144,7 @@ def __init__(
filenames = [filenames]

# Fill namefile items
name = [ModflowDe4.ftype()]
name = [ModflowDe4._ftype()]
units = [unitnumber]
extra = [""]

Expand Down Expand Up @@ -310,7 +310,7 @@ def load(cls, f, model, ext_unit_dict=None):
filenames = [None]
if ext_unit_dict is not None:
unitnumber, filenames[0] = model.get_ext_dict_attr(
ext_unit_dict, filetype=ModflowDe4.ftype()
ext_unit_dict, filetype=ModflowDe4._ftype()
)

de4 = cls(
Expand All @@ -330,9 +330,9 @@ def load(cls, f, model, ext_unit_dict=None):
return de4

@staticmethod
def ftype():
def _ftype():
return "DE4"

@staticmethod
def defaultunit():
def _defaultunit():
return 28
10 changes: 5 additions & 5 deletions flopy/modflow/mfdis.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __init__(

# set default unit number of one is not specified
if unitnumber is None:
unitnumber = ModflowDis.defaultunit()
unitnumber = ModflowDis._defaultunit()

# set filenames
if filenames is None:
Expand All @@ -158,7 +158,7 @@ def __init__(
filenames = [filenames]

# Fill namefile items
name = [ModflowDis.ftype()]
name = [ModflowDis._ftype()]
units = [unitnumber]
extra = [""]

Expand Down Expand Up @@ -1024,7 +1024,7 @@ def load(cls, f, model, ext_unit_dict=None, check=True):
filenames = [None]
if ext_unit_dict is not None:
unitnumber, filenames[0] = model.get_ext_dict_attr(
ext_unit_dict, filetype=ModflowDis.ftype()
ext_unit_dict, filetype=ModflowDis._ftype()
)

# create dis object instance
Expand Down Expand Up @@ -1063,11 +1063,11 @@ def load(cls, f, model, ext_unit_dict=None, check=True):
return dis

@staticmethod
def ftype():
def _ftype():
return "DIS"

@staticmethod
def defaultunit():
def _defaultunit():
return 11


Expand Down
10 changes: 5 additions & 5 deletions flopy/modflow/mfdisu.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def __init__(

# set default unit number of one is not specified
if unitnumber is None:
unitnumber = ModflowDisU.defaultunit()
unitnumber = ModflowDisU._defaultunit()

# set filenames
if filenames is None:
Expand All @@ -240,7 +240,7 @@ def __init__(
filenames = [filenames]

# Fill namefile items
name = [ModflowDisU.ftype()]
name = [ModflowDisU._ftype()]
units = [unitnumber]
extra = [""]

Expand Down Expand Up @@ -794,7 +794,7 @@ def load(cls, f, model, ext_unit_dict=None, check=False):
filenames = [None]
if ext_unit_dict is not None:
unitnumber, filenames[0] = model.get_ext_dict_attr(
ext_unit_dict, filetype=ModflowDisU.ftype()
ext_unit_dict, filetype=ModflowDisU._ftype()
)

# create dis object instance
Expand Down Expand Up @@ -920,11 +920,11 @@ def write_file(self):
return

@staticmethod
def ftype():
def _ftype():
return "DISU"

@staticmethod
def defaultunit():
def _defaultunit():
return 11

# def get_node_coordinates(self):
Expand Down
Loading

0 comments on commit 9983191

Please sign in to comment.