Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 6, 2024
1 parent 449f0bb commit 65ddd27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class ConcentrationTrackerForDiffusion(Component):
This component requires a soil flux field calculated by a hillslope diffusion
component. This component is implemented by applying a start_tracking() method
immediately before every diffusion step and a stop_tracking(dt) method
immediately after every diffusion step. These methods are applied instead of
immediately before every diffusion step and a stop_tracking(dt) method
immediately after every diffusion step. These methods are applied instead of
the typical run_one_step(dt) method. See the docstring examples below.
Currently, this component will only work if coupled with the
Currently, this component will only work if coupled with the
:class:`~.DepthDependentDiffuser` or the :class:`~.DepthDependentTaylorDiffuser`
(without the dynamic timestep option).
Expand Down Expand Up @@ -274,7 +274,7 @@ def __init__(

# get reference to inputs
self._soil__depth = self._grid.at_node["soil__depth"]
#self._soil__depth_old = self._soil__depth.copy()
# self._soil__depth_old = self._soil__depth.copy()
self._soil_prod_rate = self._grid.at_node["soil_production__rate"]
self._flux = self._grid.at_link["soil__flux"]

Expand Down Expand Up @@ -335,10 +335,10 @@ def conc_w(self, new_val):
self._conc_w = new_val

def copy_old_soil_depth(self):
"""Store a copy of soil depth. This is used as the old soil depth when
calculating changes in concentration.
"""Store a copy of soil depth. This is used as the old soil depth when
calculating changes in concentration.
"""

self._soil__depth_old = self._soil__depth.copy()

def calc_concentration(self, dt):
Expand Down Expand Up @@ -400,11 +400,11 @@ def start_tracking(self):
"""

self.copy_old_soil_depth()

def stop_tracking(self, dt):
"""Calculate changes in concentration that have occurred in the timestep
since tracking was started. This method must be called after running the
sediment flux component that changes physical properties of bedrock,
sediment flux component that changes physical properties of bedrock,
soil, and/or topography.
Parameters
Expand All @@ -414,7 +414,7 @@ def stop_tracking(self, dt):
"""

self.calc_concentration(dt)

def run_one_step(self):
"""run_one_step is not implemented for this component."""
raise NotImplementedError("run_one_step()")
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from landlab import RasterModelGrid
from landlab.components import ConcentrationTrackerForDiffusion


class TestInputParameters:
"""Test input field errors"""

Expand Down Expand Up @@ -265,7 +266,7 @@ def test_concentration_from_weathering_without_conc_w(self):

ct.start_tracking()
ct.stop_tracking(1)

# Node 7 should have the same concentration as before.
# Node 8 should have half its previous concentration.
expected = np.asarray(
Expand Down Expand Up @@ -411,9 +412,11 @@ def test_mass_balance_with_one_boundary_open(self):
)

assert_allclose(total_mass_before, total_mass_after + total_mass_leaving)



# %%


class TestFieldCopy:
"""Test that copied field is a copy, but not a reference."""

Expand All @@ -423,23 +426,23 @@ def setup_method(self):

def test_copy_is_equal(self):
"""Test that copied values are equal to copied field."""

ct = ConcentrationTrackerForDiffusion(self.mg)
ct.copy_old_soil_depth()

assert ct._soil__depth_old == self.mg.at_node["soil__depth"]

def test_copy_is_not_reference(self):
"""Test that copy not a reference."""

ct = ConcentrationTrackerForDiffusion(self.mg)
ct.copy_old_soil_depth()

self.mg.at_node["soil__depth"] += 1

assert ct._soil__depth_old != self.mg.at_node["soil__depth"]


def test_not_implemented(self):
"""Test that private run_one_step is not implemented"""

Expand Down

0 comments on commit 65ddd27

Please sign in to comment.