Skip to content

Commit

Permalink
Merge pull request #253 from r-barnes/richard2
Browse files Browse the repository at this point in the history
Add additional type annotations
  • Loading branch information
Andrew Moodie authored Jun 1, 2022
2 parents a5b72b5 + 0418d2e commit a73389d
Show file tree
Hide file tree
Showing 21 changed files with 288 additions and 275 deletions.
11 changes: 6 additions & 5 deletions docs/source/_resources/joss/figures/figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@
from pyDeltaRCM.shared_tools import sec_in_day, day_in_yr

import netCDF4 as nc
from typing import List

# everything relative to this file
_dir = os.path.realpath(os.path.dirname(__file__))
_dir: str = os.path.realpath(os.path.dirname(__file__))


if __name__ == '__main__':

# get script input argument
_arg = sys.argv
_arg: List[str] = sys.argv
if len(_arg) == 3:
_input_flag = sys.argv[1].strip('-')
_input_flag: str = sys.argv[1].strip('-')
elif len(_arg) == 2:
_input_flag = sys.argv[1].strip('-')
_input_flag: str = sys.argv[1].strip('-')
else:
raise ValueError('No arguments supplied.')

# parameter choices for scaling
If = 10 / day_in_yr # intermittency factor for year-scaling
If: float = 10 / day_in_yr # intermittency factor for year-scaling

# if running the computation
if _input_flag == 'compute':
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pyplots/guides/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


# define a function to fill in the walks of given idx
def _plot_idxs_walks_to_step(delta_inds, _step, _idxs, _ax):
def _plot_idxs_walks_to_step(delta_inds, _step, _idxs, _ax) -> None:
for i in range(len(_idxs)):
iidx = _idxs[i]
walk = delta_inds[iidx, :]
Expand Down
3 changes: 2 additions & 1 deletion docs/source/pyplots/modeltime/one_year_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np

import _base
from typing import Dict

fig, ax = plt.subplots()
plt.subplots_adjust(left=0.2)
Expand All @@ -14,7 +15,7 @@
ax.set_xlabel('calendar day')
ax.set_ylim(0.9, 3.1)

bbox = dict(boxstyle="round", fc="0.8")
bbox: Dict[str, str] = dict(boxstyle="round", fc="0.8")
_cs0 = "angle,angleA=-10,angleB=-60,rad=10"
ax.annotate('start event', xy=(95, 1.1), xytext=(0, 1.4),
bbox=bbox, arrowprops=dict(arrowstyle="->", connectionstyle=_cs0))
Expand Down
6 changes: 3 additions & 3 deletions docs/source/pyplots/sed_tools/sediment_weights_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

class SedimentWeightingCalculator(pyDeltaRCM.DeltaModel):

def __init__(self, input_file=None, **kwargs):
def __init__(self, input_file=None, **kwargs) -> None:

# inherit from base model
super().__init__(input_file, **kwargs)

def get_sediment_weight_array(self):
def get_sediment_weight_array(self) -> None:
sand_weights = np.zeros((self.L, self.W, 9))
mud_weights = np.zeros((self.L, self.W, 9))

Expand Down Expand Up @@ -75,7 +75,7 @@ def get_sediment_weight_array(self):


NPLOT = 5
hdr = NPLOT // 2
hdr: int = NPLOT // 2

# fig, ax = plt.subplots()
fig = plt.figure(constrained_layout=False, figsize=(6, 9))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


# define a function to fill in the walks of given idx
def _plot_idxs_walks_to_step(delta_inds, _step, _idxs, _ax):
def _plot_idxs_walks_to_step(delta_inds, _step, _idxs, _ax) -> None:
for i in range(len(_idxs)):
walk = delta_inds[_idxs[i], :]
walk = walk[:_step]
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pyplots/water_tools/run_water_iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


# define a function to fill in the walks of given idx
def _plot_idxs_walks_to_step(delta_inds, _step, _idxs, _ax):
def _plot_idxs_walks_to_step(delta_inds, _step, _idxs, _ax) -> None:
for i in range(len(_idxs)):
iidx = _idxs[i]
walk = delta_inds[iidx, :]
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pyplots/water_tools/water_weights_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


NPLOT = 5
hdr = NPLOT // 2
hdr: int = NPLOT // 2

# fig, ax = plt.subplots()
fig = plt.figure(constrained_layout=False, figsize=(6, 9))
Expand Down
2 changes: 1 addition & 1 deletion pyDeltaRCM/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from .shared_tools import _get_version

__all__ = ['DeltaModel', 'Preprocessor']
__version__ = _get_version()
__version__: str = _get_version()
10 changes: 5 additions & 5 deletions pyDeltaRCM/debug_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _get_attribute(self, attribute):
shp=_attr_shape))
return _attr

def show_attribute(self, attribute, **kwargs):
def show_attribute(self, attribute: str, **kwargs) -> None:
"""Show an attribute over the model domain.
Show any attribute of the :obj:`~pyDeltaRCM.model.DeltaModel` class
Expand Down Expand Up @@ -80,7 +80,7 @@ def show_attribute(self, attribute, **kwargs):
_attr = self._get_attribute(attribute)
plot_domain(_attr, **kwargs)

def show_ind(self, ind, *args, **kwargs):
def show_ind(self, ind, *args, **kwargs) -> None:
"""Show points within the model domain.
Show the location of points (indices) within the model domain. Can
Expand Down Expand Up @@ -200,7 +200,7 @@ def show_line(self, ind, *args, multiline: bool = False, nozeros: bool = False,
return lines


def plot_domain(attr, ax=None, grid: bool = True, block: bool = False, label=None, **kwargs):
def plot_domain(attr, ax=None, grid: bool = True, block: bool = False, label=None, **kwargs) -> None:
"""Plot the model domain.
Public function to plot *any* 2d grid with helper display utils.
Expand Down Expand Up @@ -263,7 +263,7 @@ def plot_domain(attr, ax=None, grid: bool = True, block: bool = False, label=Non
plt.show()


def plot_ind(_ind, *args, shape=None, **kwargs):
def plot_ind(_ind, *args, shape=None, **kwargs) -> None:
"""Plot points within the model domain.
.. todo:: write a complete docstring with parameters etc.
Expand Down Expand Up @@ -305,7 +305,7 @@ def plot_ind(_ind, *args, shape=None, **kwargs):
plt.show()


def plot_line(_ind, *args, shape=None, nozeros=False, **kwargs):
def plot_line(_ind, *args, shape=None, nozeros: bool = False, **kwargs):
"""Plot a line within the model domain.
Method called by :obj:`show_line`.
Expand Down
Loading

0 comments on commit a73389d

Please sign in to comment.