Skip to content

Commit 5c6a84c

Browse files
committed
Fix the word 'brief' in README; add some basic type annotations to the tests
Ignore .vscode settings directory
1 parent 929ce08 commit 5c6a84c

25 files changed

+563
-543
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ target/
9999
# SublimeText docs
100100
*.sublime-*
101101

102+
# VSCode settings directory
103+
.vscode/
104+
102105
# temp folder
103106
temp/
104107

README.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ pyDeltaRCM
1010

1111
.. image:: https://github.com/DeltaRCM/pyDeltaRCM/actions/workflows/build.yml/badge.svg
1212
:target: https://github.com/DeltaRCM/pyDeltaRCM/actions
13-
13+
1414
.. image:: https://codecov.io/gh/DeltaRCM/pyDeltaRCM/branch/develop/graph/badge.svg
1515
:target: https://codecov.io/gh/DeltaRCM/pyDeltaRCM
1616

1717
.. image:: https://app.codacy.com/project/badge/Grade/1c137d0227914741a9ba09f0b00a49a7
18-
:target: https://www.codacy.com/gh/DeltaRCM/pyDeltaRCM?utm_source=github.com&utm_medium=referral&utm_content=DeltaRCM/pyDeltaRCM&utm_campaign=Badge_Grade
19-
18+
:target: https://www.codacy.com/gh/DeltaRCM/pyDeltaRCM?utm_source=github.com&utm_medium=referral&utm_content=DeltaRCM/pyDeltaRCM&utm_campaign=Badge_Grade
19+
2020

2121

2222

@@ -25,7 +25,7 @@ pyDeltaRCM
2525

2626

2727
.. figure:: https://deltarcm.org/pyDeltaRCM/_images/cover.png
28-
28+
2929
Weighted random walks for 20 water parcels, in a *pyDeltaRCM* model run with default parameters.
3030

3131

@@ -54,7 +54,7 @@ Executing the model
5454

5555
We recommend you check out our `pyDeltaRCM in 10 minutes tutorial <https://deltarcm.org/pyDeltaRCM/guides/10min.html>`_, which is part of our documentation.
5656

57-
Beyond that breif tutorial, we have a comprehensive `User Documentation <https://deltarcm.org/pyDeltaRCM/index.html#user-documentation>`_ and `Developer Documentation <https://deltarcm.org/pyDeltaRCM/index.html#developer-documentation>`_ to check out.
57+
Beyond that brief tutorial, we have a comprehensive `User Documentation <https://deltarcm.org/pyDeltaRCM/index.html#user-documentation>`_ and `Developer Documentation <https://deltarcm.org/pyDeltaRCM/index.html#developer-documentation>`_ to check out.
5858

5959

6060
Additional notes

pyDeltaRCM/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
def __version__():
2+
def __version__() -> str:
33
"""
44
Private version declaration, gets assigned to pyDeltaRCM.__version__
55
during import

pyDeltaRCM/debug_tools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def show_ind(self, ind, *args, **kwargs):
118118
else:
119119
plot_ind(ind, shape=_shape, *args, **kwargs)
120120

121-
def show_line(self, ind, *args, multiline=False, nozeros=False, **kwargs):
121+
def show_line(self, ind, *args, multiline: bool = False, nozeros: bool = False, **kwargs):
122122
"""Show line within the model domain.
123123
124124
Show the location of lines (a series of connected indices) within the
@@ -200,7 +200,7 @@ def show_line(self, ind, *args, multiline=False, nozeros=False, **kwargs):
200200
return lines
201201

202202

203-
def plot_domain(attr, ax=None, grid=True, block=False, label=None, **kwargs):
203+
def plot_domain(attr, ax=None, grid: bool = True, block: bool = False, label=None, **kwargs):
204204
"""Plot the model domain.
205205
206206
Public function to plot *any* 2d grid with helper display utils.

pyDeltaRCM/init_tools.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
class init_tools(abc.ABC):
2525

26-
def init_output_infrastructure(self):
26+
def init_output_infrastructure(self) -> None:
2727
"""Initialize the output infrastructure (folder and save lists).
2828
2929
This method is the first called in the initialization of the
@@ -42,7 +42,7 @@ def init_output_infrastructure(self):
4242
self._save_var_list = dict() # dict of variables to save
4343
self._save_var_list['meta'] = dict() # set up meta dict
4444

45-
def init_logger(self):
45+
def init_logger(self) -> None:
4646
"""Initialize a logger.
4747
4848
The logger is initialized regardless of the value of ``self.verbose``.
@@ -73,7 +73,7 @@ def init_logger(self):
7373
self.log_info('Platform: {}'.format(platform.platform()),
7474
verbosity=0) # log the os
7575

76-
def import_files(self, kwargs_dict={}):
76+
def import_files(self, kwargs_dict={}) -> None:
7777
"""Import the input files.
7878
7979
This method handles the parsing and validation of any options supplied
@@ -181,7 +181,7 @@ def import_files(self, kwargs_dict={}):
181181
else:
182182
self._netcdf_coords = ('time', 'x', 'y')
183183

184-
def process_input_to_model(self):
184+
def process_input_to_model(self) -> None:
185185
"""Process input file to model variables.
186186
187187
Loop through the items specified in the model configuration and apply
@@ -210,7 +210,7 @@ def process_input_to_model(self):
210210
var=k, val=v)
211211
self.log_info(_msg, verbosity=0)
212212

213-
def determine_random_seed(self):
213+
def determine_random_seed(self) -> None:
214214
"""Set the random seed if given.
215215
216216
If a random seed is specified, set the seed to this value.
@@ -227,7 +227,7 @@ def determine_random_seed(self):
227227
_msg = 'Random seed is: %s ' % str(self._seed)
228228
self.log_info(_msg, verbosity=0)
229229

230-
def create_other_variables(self):
230+
def create_other_variables(self) -> None:
231231
"""Model implementation variables.
232232
233233
Creates variables for model implementation, from specified boundary
@@ -282,7 +282,7 @@ def create_other_variables(self):
282282

283283
self._is_finalized = False
284284

285-
def set_constants(self):
285+
def set_constants(self) -> None:
286286
"""Set the model constants.
287287
288288
Configure constants, including coordinates and distances, as well as
@@ -342,7 +342,7 @@ def set_constants(self):
342342
[1, 0, 1],
343343
[1, 1, 1]]).astype(np.int64)
344344

345-
def create_boundary_conditions(self):
345+
def create_boundary_conditions(self) -> None:
346346
"""Create model boundary conditions
347347
348348
This method is run during model initialization to determine the
@@ -415,7 +415,7 @@ def create_boundary_conditions(self):
415415
self.diffusion_multiplier = (self._dt / self.N_crossdiff * self._alpha
416416
* 0.5 / self._dx**2)
417417

418-
def create_domain(self):
418+
def create_domain(self) -> None:
419419
"""Create the model domain.
420420
421421
This method initializes the model domain, including coordinate arrays,
@@ -521,7 +521,7 @@ def create_domain(self):
521521
self.inlet = np.array(np.unique(np.where(self.cell_type == 1)[1]))
522522
self.eta[:] = self.stage - self.depth
523523

524-
def init_sediment_routers(self):
524+
def init_sediment_routers(self) -> None:
525525
"""Initialize the sediment router object here.
526526
527527
These are preinitialized because the "boxing" for jitted functions is
@@ -555,7 +555,7 @@ def init_sediment_routers(self):
555555
self._beta, self.stepmax,
556556
self.theta_sand)
557557

558-
def init_output_file(self):
558+
def init_output_file(self) -> None:
559559
"""Creates a netCDF file to store output grids.
560560
561561
Fills with default variables.
@@ -679,7 +679,7 @@ def _create_meta_variable(varname, varvalue, varunits,
679679
_msg = 'Output netCDF file created'
680680
self.log_info(_msg, verbosity=2)
681681

682-
def init_subsidence(self):
682+
def init_subsidence(self) -> None:
683683
"""Initialize subsidence pattern.
684684
685685
Initializes patterns of subsidence if toggle_subsidence is True
@@ -702,7 +702,7 @@ def init_subsidence(self):
702702

703703
self.sigma = self.subsidence_mask * self._subsidence_rate * self.dt
704704

705-
def init_metadata_list(self):
705+
def init_metadata_list(self) -> None:
706706
"""Populate the list of metadata information.
707707
708708
Sets up the dictionary object for the standard metadata.

pyDeltaRCM/iteration_tools.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class iteration_tools(abc.ABC):
2323
these operations largely occur when saving and updating the model.
2424
"""
2525

26-
def solve_water_and_sediment_timestep(self):
26+
def solve_water_and_sediment_timestep(self) -> None:
2727
"""Run water and sediment operations for one timestep.
2828
2929
The first operation called by :meth:`update`, this method iterates the
@@ -48,7 +48,7 @@ def solve_water_and_sediment_timestep(self):
4848
self.route_sediment()
4949
self.hook_after_route_sediment()
5050

51-
def run_one_timestep(self):
51+
def run_one_timestep(self) -> None:
5252
"""Deprecated, since v1.3.1. Use :obj:`solve_water_and_sediment_timestep`."""
5353
_msg = ('`run_one_timestep` and `hook_run_one_timestep` are '
5454
'deprecated and have been replaced with '
@@ -87,7 +87,7 @@ def apply_subsidence(self):
8787

8888
self.eta[:] = self.eta - self.sigma
8989

90-
def finalize_timestep(self):
90+
def finalize_timestep(self) -> None:
9191
"""Finalize timestep.
9292
9393
Clean up after sediment routing. This includes a correction for
@@ -117,7 +117,7 @@ def finalize_timestep(self):
117117

118118
self.H_SL = self._H_SL + self._SLR * self._dt
119119

120-
def log_info(self, message, verbosity=0):
120+
def log_info(self, message: str, verbosity: int = 0) -> None:
121121
"""Log message dependent on verbosity settings.
122122
123123
Parameters
@@ -132,7 +132,7 @@ def log_info(self, message, verbosity=0):
132132
if self._verbose >= verbosity:
133133
self.logger.info(message)
134134

135-
def log_model_time(self):
135+
def log_model_time(self) -> None:
136136
"""Log the time of the model.
137137
138138
Reports the time to the log file, and depending on verbosity, will
@@ -144,7 +144,7 @@ def log_model_time(self):
144144
if self._verbose > 0:
145145
print(_timemsg)
146146

147-
def output_data(self):
147+
def output_data(self) -> None:
148148
"""Output grids and figures if needed.
149149
150150
"""
@@ -155,7 +155,7 @@ def output_data(self):
155155
self._save_iter += int(1)
156156
self._save_time_since_data = 0
157157

158-
def output_checkpoint(self):
158+
def output_checkpoint(self) -> None:
159159
"""Output checkpoint if needed.
160160
161161
Save checkpoint data (including rng state) so that the model can be
@@ -186,7 +186,7 @@ def output_checkpoint(self):
186186

187187
self._save_time_since_checkpoint = 0
188188

189-
def compute_sand_frac(self):
189+
def compute_sand_frac(self) -> None:
190190
"""Compute the sand fraction as a continous updating data field.
191191
192192
Parameters
@@ -235,7 +235,7 @@ def compute_sand_frac(self):
235235
self.sand_frac[whr_agg] = mixture
236236
self.active_layer[whr_agg] = mixture
237237

238-
def save_grids_and_figs(self):
238+
def save_grids_and_figs(self) -> None:
239239
"""Save grids and figures.
240240
241241
Save grids and/or plots of specified variables (``eta``, `discharge``,
@@ -330,7 +330,7 @@ def save_grids_and_figs(self):
330330

331331
self.output_netcdf.sync()
332332

333-
def make_figure(self, var, timestep):
333+
def make_figure(self, var, timestep) -> None:
334334
"""Create a figure.
335335
336336
Parameters
@@ -362,7 +362,7 @@ def make_figure(self, var, timestep):
362362
return fig
363363

364364
def save_figure(self, fig, directory, filename_root,
365-
timestep, ext='.png', close=True):
365+
timestep, ext: str = '.png', close: bool = True) -> None:
366366
"""Save a figure.
367367
368368
Parameters
@@ -396,7 +396,7 @@ def save_figure(self, fig, directory, filename_root,
396396
if close:
397397
plt.close()
398398

399-
def save_grids(self, var_name, var, ts):
399+
def save_grids(self, var_name: str, var: np.ndarray, ts: int) -> None:
400400
"""Save a grid into an existing netCDF file.
401401
402402
File should already be open (by :meth:`init_output_grid`) as
@@ -427,7 +427,7 @@ def save_grids(self, var_name, var, ts):
427427
self.logger.error(_msg)
428428
raise Exception(e)
429429

430-
def save_the_checkpoint(self):
430+
def save_the_checkpoint(self) -> None:
431431
"""Save checkpoint files.
432432
433433
Saves the grids to a .npz file so that the model can be

0 commit comments

Comments
 (0)