From 163b11ae6c0cabfeaed6a6cc59bc51ee90323059 Mon Sep 17 00:00:00 2001 From: Michael Doyle Date: Mon, 8 Jul 2024 14:43:51 -0700 Subject: [PATCH 1/9] Update .github/workflows/testing.yml with correct command --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 21a9650..bfa4d37 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -42,7 +42,7 @@ jobs: - name: Build Coverage File run: | export PATH=$PATH:$HOME/.local/bin - poetry run pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=simfire | tee pytest-coverage.txt + poetry run pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=simfire simfire | tee pytest-coverage.txt - name: Comment on PR with Coverage continue-on-error: true # To let people create forked PRs From a0975c91d93603f74767d558d8ebfecfa5dc183d Mon Sep 17 00:00:00 2001 From: Michael Doyle Date: Mon, 8 Jul 2024 14:44:03 -0700 Subject: [PATCH 2/9] Add geopy to pyproject.toml --- poetry.lock | 36 +++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 2bd1cc6..f40df2c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -721,6 +721,17 @@ pygments = ">=2.7" sphinx = ">=5.0,<7.0" sphinx-basic-ng = "*" +[[package]] +name = "geographiclib" +version = "2.0" +description = "The geodesic routines from GeographicLib" +optional = false +python-versions = ">=3.7" +files = [ + {file = "geographiclib-2.0-py3-none-any.whl", hash = "sha256:6b7225248e45ff7edcee32becc4e0a1504c606ac5ee163a5656d482e0cd38734"}, + {file = "geographiclib-2.0.tar.gz", hash = "sha256:f7f41c85dc3e1c2d3d935ec86660dc3b2c848c83e17f9a9e51ba9d5146a15859"}, +] + [[package]] name = "geopandas" version = "0.14.4" @@ -740,6 +751,29 @@ pandas = ">=1.4.0" pyproj = ">=3.3.0" shapely = ">=1.8.0" +[[package]] +name = "geopy" +version = "2.4.1" +description = "Python Geocoding Toolbox" +optional = false +python-versions = ">=3.7" +files = [ + {file = "geopy-2.4.1-py3-none-any.whl", hash = "sha256:ae8b4bc5c1131820f4d75fce9d4aaaca0c85189b3aa5d64c3dcaf5e3b7b882a7"}, + {file = "geopy-2.4.1.tar.gz", hash = "sha256:50283d8e7ad07d89be5cb027338c6365a32044df3ae2556ad3f52f4840b3d0d1"}, +] + +[package.dependencies] +geographiclib = ">=1.52,<3" + +[package.extras] +aiohttp = ["aiohttp"] +dev = ["coverage", "flake8 (>=5.0,<5.1)", "isort (>=5.10.0,<5.11.0)", "pytest (>=3.10)", "pytest-asyncio (>=0.17)", "readme-renderer", "sphinx (<=4.3.2)", "sphinx-issues", "sphinx-rtd-theme (>=0.5.0)"] +dev-docs = ["readme-renderer", "sphinx (<=4.3.2)", "sphinx-issues", "sphinx-rtd-theme (>=0.5.0)"] +dev-lint = ["flake8 (>=5.0,<5.1)", "isort (>=5.10.0,<5.11.0)"] +dev-test = ["coverage", "pytest (>=3.10)", "pytest-asyncio (>=0.17)", "sphinx (<=4.3.2)"] +requests = ["requests (>=2.16.2)", "urllib3 (>=1.24.2)"] +timezone = ["pytz"] + [[package]] name = "geotiff" version = "0.2.10" @@ -3226,4 +3260,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "~3.9" -content-hash = "0ca93b59db7851d1e9b016ec0401492d4576ecdd54b29fb7dd32f87bab61c653" +content-hash = "ddde3030fc4d71c1531b91dea245009014ad663071db4d877e67494fbad205dd" diff --git a/pyproject.toml b/pyproject.toml index 6eda02a..6018593 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ imagecodecs = "^2023.7.10" landfire = "^0.5.0" geotiff = "^0.2.10" geopandas = "^0.14.4" +geopy = "^2.4.1" [tool.poetry.group.coverage.dependencies] pytest-cov = "^3.0.0" From 3633a9c89f34a138bef78721f604643af8816a9a Mon Sep 17 00:00:00 2001 From: Michael Doyle Date: Mon, 8 Jul 2024 15:13:33 -0700 Subject: [PATCH 3/9] Update sprite colors in test_sprites.py --- simfire/game/_tests/test_sprites.py | 4 ++-- simfire/world/_tests/test_rothermel.py | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/simfire/game/_tests/test_sprites.py b/simfire/game/_tests/test_sprites.py index 7deb6bc..0ce27b5 100644 --- a/simfire/game/_tests/test_sprites.py +++ b/simfire/game/_tests/test_sprites.py @@ -192,7 +192,7 @@ def test_non_headless(self) -> None: ) rgba = sprite.image.get_at((0, 0)) - valid_rgba = (155, 118, 83, 255) + valid_rgba = (255, 0, 0, 255) self.assertEqual( rgba, valid_rgba, @@ -242,7 +242,7 @@ def test_non_headless(self) -> None: ) rgba = sprite.image.get_at((0, 0)) - valid_rgba = (139, 125, 58, 255) + valid_rgba = (255, 0, 0, 255) self.assertEqual( rgba, valid_rgba, diff --git a/simfire/world/_tests/test_rothermel.py b/simfire/world/_tests/test_rothermel.py index eb69696..947d8a3 100644 --- a/simfire/world/_tests/test_rothermel.py +++ b/simfire/world/_tests/test_rothermel.py @@ -51,11 +51,9 @@ def test_compute_rate_of_spread(self) -> None: el_fn = np.vectorize(flat()) elevations = el_fn(X, Y).astype(np.float32) - grad_x, grad_y = np.gradient(elevations) - slope_mag = (grad_x**2 + grad_y**2) ** 0.5 - slope_mag = slope_mag[new_loc_y, new_loc_x] - slope_dir = np.tan(grad_y / (grad_x + 1e-6)) - slope_dir = slope_dir[new_loc_y, new_loc_x] + grad_y, grad_x = np.gradient(elevations, 1) + slope_mag = np.sqrt(grad_x**2 + grad_y**2) + slope_dir = np.arctan2(grad_y, grad_x + 0.000001) loc_x = np.array(new_loc_x, dtype=np.float32) loc_y = np.array(new_loc_y, dtype=np.float32) From 3ce17b781afe1ae826b80e3b6749759204cbcc4b Mon Sep 17 00:00:00 2001 From: Michael Doyle Date: Mon, 8 Jul 2024 15:17:21 -0700 Subject: [PATCH 4/9] Add forgotten line from previous test --- simfire/world/_tests/test_rothermel.py | 1 + 1 file changed, 1 insertion(+) diff --git a/simfire/world/_tests/test_rothermel.py b/simfire/world/_tests/test_rothermel.py index 947d8a3..575ba1e 100644 --- a/simfire/world/_tests/test_rothermel.py +++ b/simfire/world/_tests/test_rothermel.py @@ -54,6 +54,7 @@ def test_compute_rate_of_spread(self) -> None: grad_y, grad_x = np.gradient(elevations, 1) slope_mag = np.sqrt(grad_x**2 + grad_y**2) slope_dir = np.arctan2(grad_y, grad_x + 0.000001) + slope_dir = slope_dir[new_loc_y, new_loc_x] loc_x = np.array(new_loc_x, dtype=np.float32) loc_y = np.array(new_loc_y, dtype=np.float32) From 16e5666bab1114aa6649340bba4d8f11e448df3e Mon Sep 17 00:00:00 2001 From: Michael Doyle Date: Mon, 8 Jul 2024 18:12:58 -0700 Subject: [PATCH 5/9] Refactor slope calculation in test_rothermel.py to fit updated spread --- simfire/world/_tests/test_rothermel.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/simfire/world/_tests/test_rothermel.py b/simfire/world/_tests/test_rothermel.py index 575ba1e..28b8724 100644 --- a/simfire/world/_tests/test_rothermel.py +++ b/simfire/world/_tests/test_rothermel.py @@ -8,14 +8,14 @@ from ..rothermel import compute_rate_of_spread KNOWN_ROTHERMEL_OUTPUT = [ - 1087.6337458150563, - 1087.6337458150563, - 1087.6337458150563, - 1087.6337458150563, - 391.63742469666437, - 391.63742469666437, - 391.63742469666437, - 391.63742469666437, + 1059.7013711275968, + 1059.7013711275968, + 1059.7013711275968, + 1059.7013711275968, + 382.0360259132064, + 382.0360259132064, + 382.0360259132064, + 382.0360259132064, ] @@ -53,6 +53,7 @@ def test_compute_rate_of_spread(self) -> None: grad_y, grad_x = np.gradient(elevations, 1) slope_mag = np.sqrt(grad_x**2 + grad_y**2) + slope_mag = slope_mag[new_loc_y, new_loc_x] slope_dir = np.arctan2(grad_y, grad_x + 0.000001) slope_dir = slope_dir[new_loc_y, new_loc_x] From 61901146acc3d0db0ed982b172976742df960ded Mon Sep 17 00:00:00 2001 From: Michael Doyle Date: Mon, 8 Jul 2024 18:20:36 -0700 Subject: [PATCH 6/9] Update version to 2.0.1 --- CITATION.cff | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index eef74fe..58f68a0 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -44,5 +44,5 @@ keywords: - fire - python license: Apache-2.0 -version: 2.0.0 +version: 2.0.1 date-released: '2024-07-08' diff --git a/pyproject.toml b/pyproject.toml index 986a53d..aaadb05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "simfire" -version = "2.0.0" +version = "2.0.1" description = "Fire simulator built in Python" authors = ["Tim Welsh ", "Marissa Dotter ", "Michael Doyle ", "Dhanuj Gandikota ", From 7c872c6c38e1ba5e12e7f2bab00aab8302c31975 Mon Sep 17 00:00:00 2001 From: Michael Doyle Date: Mon, 8 Jul 2024 18:33:15 -0700 Subject: [PATCH 7/9] Change test_rothermel test to be `AlmostEqual` --- simfire/world/_tests/test_rothermel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simfire/world/_tests/test_rothermel.py b/simfire/world/_tests/test_rothermel.py index 28b8724..251ac88 100644 --- a/simfire/world/_tests/test_rothermel.py +++ b/simfire/world/_tests/test_rothermel.py @@ -96,4 +96,5 @@ def test_compute_rate_of_spread(self) -> None: slope_mag, slope_dir, ) - self.assertListEqual(R.tolist(), KNOWN_ROTHERMEL_OUTPUT) + for i, r in enumerate(R.tolist()): + self.assertAlmostEqual(r, KNOWN_ROTHERMEL_OUTPUT[i], places=4) From 416659f88efa04f10ff7d0ae0a185186d045e79a Mon Sep 17 00:00:00 2001 From: Michael Doyle Date: Mon, 8 Jul 2024 18:42:39 -0700 Subject: [PATCH 8/9] Update testing to fail on test failures --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index bfa4d37..2f5d11c 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -42,7 +42,7 @@ jobs: - name: Build Coverage File run: | export PATH=$PATH:$HOME/.local/bin - poetry run pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=simfire simfire | tee pytest-coverage.txt + poetry run pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=simfire --no-cov-on-fail simfire | tee pytest-coverage.txt - name: Comment on PR with Coverage continue-on-error: true # To let people create forked PRs From 3dc2def0dba811159c9f47b3827b84271ea461a1 Mon Sep 17 00:00:00 2001 From: Michael Doyle Date: Mon, 8 Jul 2024 21:48:38 -0700 Subject: [PATCH 9/9] Refactor Rothermel test to use 2 decimal places for comparison --- simfire/world/_tests/test_rothermel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simfire/world/_tests/test_rothermel.py b/simfire/world/_tests/test_rothermel.py index 251ac88..1b599c8 100644 --- a/simfire/world/_tests/test_rothermel.py +++ b/simfire/world/_tests/test_rothermel.py @@ -97,4 +97,4 @@ def test_compute_rate_of_spread(self) -> None: slope_dir, ) for i, r in enumerate(R.tolist()): - self.assertAlmostEqual(r, KNOWN_ROTHERMEL_OUTPUT[i], places=4) + self.assertAlmostEqual(r, KNOWN_ROTHERMEL_OUTPUT[i], places=2)