Skip to content

Commit

Permalink
add test_frontal_area_index, use math.inf and math.nan (#77)
Browse files Browse the repository at this point in the history
* added lot_area()

* added frontal_area()

* reformatted frontal_area_index()

* added frontal_area and lot_area() to macdonald_roughness_length()

* add test_frontal_area_index, use math.inf and math.nan

* add test_height_to_width_ratio() (#75)

* add test_building_surface_area_to_plan_area_ratio (#78)

* add new functions

* redo column naming in frontal_area()

* add test_sky_view_factor() (#72)

* add test_complete_aspect_ratio (#76)

* add test_frontal_area_index, use math.inf and math.nan

* update test_frontal_area_index()

---------

Co-authored-by: levisweet <lsweet@vols.utk.edu>
Co-authored-by: Levi Sweet-Breu <99049421+levisweetbreu@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 17, 2023
1 parent 983bc59 commit 901387d
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def test_building_surface_area_to_plan_area_ratio(self):

def test_complete_aspect_ratio(self):
"""Test that the function `complete_aspect_ratio()` returns the correct value."""

building_surface_area = pd.Series([0, 0, 0, 1, 1, 1, 5.5, 5.5, 5.5, 75, 75, 75])
total_plan_area = pd.Series([0, 1, 5.5, 75, 0, 1, 5.5, 75, 0, 1, 5.5, 75])
building_plan_area = pd.Series([0, 0, 1, 1, 5.5, 5.5, 75, 75, 0, 1, 5.5, 75])
Expand Down Expand Up @@ -548,7 +548,7 @@ def test_complete_aspect_ratio(self):
actual,
f"complete_aspect_ratio test failed, expected {expected}, actual {actual}",
)

def test_input_shapefile_df(self):
"""Test that the function `input_shapefile_df()` creates the right shape and type of DataFrame."""

Expand Down Expand Up @@ -714,6 +714,37 @@ def test_frontal_area_density(self):
f"frontal_area_density test failed, expected {expected}, actual {actual}",
)

def test_frontal_area_index(self):
"""Test that the function `frontal_area_index()` returns the correct value in each cardinal direction."""

frontal_area = pd.DataFrame(
[
[0, 1, 5.5, 75],
[0, 1, 5.5, 75],
[0, 1, 5.5, 75],
]
)
total_plan_area = pd.Series([0, 1.5, 75])
expected = pd.DataFrame(
[
[math.nan, math.inf, math.inf, math.inf],
[0.0, 0.6666666666666666, 3.6666666666666665, 50.0],
[0.0, 0.013333333333333334, 0.07333333333333333, 1.0],
]
)
expected.columns = [
Settings.frontal_area_index_north,
Settings.frontal_area_index_east,
Settings.frontal_area_index_south,
Settings.frontal_area_index_west,
]
actual = nodes.frontal_area_index(frontal_area, total_plan_area)
pd.testing.assert_frame_equal(
expected,
actual,
f"frontal_area_index test failed, expected {expected}, actual {actual}",
)

def test_frontal_length(self):
"""Test that the function `frontal_length()` returns the correct length."""

Expand Down Expand Up @@ -915,14 +946,14 @@ def test_raupach_displacement_height(self):
[
[
1 - ((1 - math.exp(-math.sqrt(constant_75))) / math.sqrt(constant_75)),
float("nan"),
math.nan,
1 - ((1 - math.exp(-math.sqrt(constant_75 * 2))) / math.sqrt(constant_75 * 2)),
1
- ((1 - math.exp(-math.sqrt(constant_75 * 20))) / math.sqrt(constant_75 * 20)),
],
[
75 * (1 - ((1 - math.exp(-math.sqrt(constant_75))) / math.sqrt(constant_75))),
float("nan"),
math.nan,
75
* (
1
Expand Down

0 comments on commit 901387d

Please sign in to comment.