Skip to content

Commit

Permalink
Fix black
Browse files Browse the repository at this point in the history
  • Loading branch information
dladrichem committed Feb 9, 2024
1 parent d17a5d2 commit 020efc2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion flood_adapt/object_model/interface/measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def validate_hazard_type_values(self) -> "GreenInfrastructureModel":
return self
elif self.type == HazardType.greening:
if not isinstance(self.height, UnitfulHeight) or not isinstance(
self.percent_area, float):
self.percent_area, float
):
raise ValueError(
"Height and percent_area needs to be set for greening type measures"
)
Expand Down
3 changes: 2 additions & 1 deletion flood_adapt/object_model/io/unitfulvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ def convert(self, new_units: UnitTypesLength) -> float:

class UnitfulHeight(UnitfulLength):
"""A special type of length that is always positive and non-zero. Used for heights."""

value: float = Field(..., gt=0)

@root_validator(pre=True)
def convert_length_to_height(cls, obj):
if isinstance(obj, UnitfulLength):
if isinstance(obj, UnitfulLength):
return UnitfulHeight(value=obj.value, units=obj.units)
return obj

Expand Down
5 changes: 2 additions & 3 deletions tests/test_object_model/interface/test_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,8 @@ def test_green_infrastructure_model_other_measure_type(self):
)

# Assert
assert (
"GreenInfrastructureModel\n Value error, Type must be one of "
in str(excinfo.value)
assert "GreenInfrastructureModel\n Value error, Type must be one of " in str(
excinfo.value
)

@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_object_model/interface/test_unitfulvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_unitfulHeight_setUnit_invalidUnits(self):
with pytest.raises(ValueError) as excinfo:
UnitfulHeight(value=10, units="invalid_units")
assert "UnitfulHeight\nunits\n Input should be " in str(excinfo.value)


class TestUnitfulArea:
def test_unitfulArea_convertM2ToCM2_correct(self):
Expand Down

0 comments on commit 020efc2

Please sign in to comment.