From f4d9ef6b878574aadffbcfe53454865bc43c2d1d Mon Sep 17 00:00:00 2001 From: angelmons Date: Mon, 11 Nov 2024 00:32:50 -0300 Subject: [PATCH] Edits required by lint A few edits required by nox lint --- .../river_flow_dynamics_tutorial2.ipynb | 8 ++++---- .../river_flow_dynamics/test_river_flow_dynamics.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/source/tutorials/river_flow_dynamics/river_flow_dynamics_tutorial2.ipynb b/docs/source/tutorials/river_flow_dynamics/river_flow_dynamics_tutorial2.ipynb index 9bca504c04..ec813831a7 100644 --- a/docs/source/tutorials/river_flow_dynamics/river_flow_dynamics_tutorial2.ipynb +++ b/docs/source/tutorials/river_flow_dynamics/river_flow_dynamics_tutorial2.ipynb @@ -45,11 +45,11 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", "from landlab import RasterModelGrid\n", "from landlab.components import RiverFlowDynamics # Note: Using updated CamelCase naming\n", - "from landlab.io import read_esri_ascii\n", "from landlab.plot.imshow import imshow_grid" ] }, @@ -312,7 +312,7 @@ "outputs": [], "source": [ "plt.figure(figsize=(12, 4))\n", - "plt.plot(flow_depth, label='Simulated')\n", + "plt.plot(flow_depth, label=\"Simulated\")\n", "plt.title(\"Flow Depth Along Channel Centerline\")\n", "plt.xlabel(\"Distance (cells)\")\n", "plt.ylabel(\"Depth (m)\")\n", @@ -338,7 +338,7 @@ "flow_velocity = grid[\"link\"][\"surface_water__velocity\"][linksAtCenter]\n", "\n", "plt.figure(figsize=(12, 4))\n", - "plt.plot(flow_velocity, label='Simulated')\n", + "plt.plot(flow_velocity, label=\"Simulated\")\n", "plt.title(\"Flow Velocity Along Channel Centerline\")\n", "plt.xlabel(\"Distance (cells)\")\n", "plt.ylabel(\"Velocity (m/s)\")\n", diff --git a/tests/components/river_flow_dynamics/test_river_flow_dynamics.py b/tests/components/river_flow_dynamics/test_river_flow_dynamics.py index 0c2459256f..9e83e61b2a 100644 --- a/tests/components/river_flow_dynamics/test_river_flow_dynamics.py +++ b/tests/components/river_flow_dynamics/test_river_flow_dynamics.py @@ -444,8 +444,14 @@ def create_test_grid(): ) final_depths.append(grid_test.at_node["surface_water__depth"].copy()) - except AssertionError: - raise AssertionError(f"Instability detected with dt={dt}") + except AssertionError as err: + raise AssertionError(f"Instability detected with dt={dt}") from err + + depth_variations = [ + np.max(np.abs(d1 - d2)) for d1, d2 in zip(final_depths[:-1], final_depths[1:]) + ] + assert np.all(np.array(depth_variations) < 0.1) + assert np.all(np.array(max_velocities) < 10.0) depth_variations = [ np.max(np.abs(d1 - d2)) for d1, d2 in zip(final_depths[:-1], final_depths[1:])