Skip to content

Commit

Permalink
Merge pull request #34 from mitrefireline/add-geopy-and-fix-tests
Browse files Browse the repository at this point in the history
Add geopy and fix tests
  • Loading branch information
mdotter-mitre authored Jul 9, 2024
2 parents 6ff9ebe + 3dc2def commit 5d76a16
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 --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
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ keywords:
- fire
- python
license: Apache-2.0
version: 2.0.0
version: 2.0.1
date-released: '2024-07-08'
34 changes: 34 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <twelsh@mitre.org>", "Marissa Dotter <mdotter@mitre.org>",
"Michael Doyle <mdoyle@mitre.org>", "Dhanuj Gandikota <dgandikota@mitre.org>",
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions simfire/game/_tests/test_sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 13 additions & 12 deletions simfire/world/_tests/test_rothermel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]


Expand Down Expand Up @@ -51,10 +51,10 @@ 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
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.tan(grad_y / (grad_x + 1e-6))
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)
Expand Down Expand Up @@ -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=2)

0 comments on commit 5d76a16

Please sign in to comment.