Skip to content

Commit

Permalink
Fixed DFR3 service's out of index error (#564)
Browse files Browse the repository at this point in the history
* Fixed DFR3 service's out of index error

* modified the situation of the rule is empty list

* reversted the road damage test file name

* modified test roaddamage to fix the PR

* revert road damage test to fix the PR

* recreated galveston road and updated the test with new id

* changed the test road dataset id in road damage test

* fixed the dataset id in test_roaddamage_w_hazard_obj
  • Loading branch information
ywkim312 committed May 30, 2024
1 parent 45750d7 commit 57cb035
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Rename Building Portfolio Analysis to Building Cluster Recovery Analysis [#559](https://github.com/IN-CORE/pyincore/issues/559)


## [Unrelased]

### Fixed
- Out of index error in dfr3 service's property conversion when the rule is not found [#555](https://github.com/IN-CORE/pyincore/issues/555)

## [1.18.1] - 2024-04-30

### Changed
Expand Down
7 changes: 7 additions & 0 deletions pyincore/dfr3service.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,17 @@ def _convert_properties_to_dict(rules, properties):
matched_properties = {}
# Handle legacy rules
if isinstance(rules, list):
# If the rules are empty, return the matched properties
if not rules or rules == [[]] or rules == [None]:
return matched_properties
for i, and_rules in enumerate(rules):
for j, rule in enumerate(and_rules):
matched_properties.update(Dfr3Service._eval_property_from_inventory(rule, properties))
elif isinstance(rules, dict):
# If the rules are empty, return the matched properties
if not rules or rules == [[]] or rules == [None]:
return matched_properties

# Handles new style of rules
boolean = list(rules.keys())[0] # AND or OR
criteria = rules[boolean]
Expand Down
2 changes: 1 addition & 1 deletion tests/pyincore/analyses/roaddamage/test_roaddamage.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def run_with_base_class():
# test galveston hurricane road failure

# road inventory for Galveston island
road_dataset_id = "60ba5ee94219ee25a56b6999"
road_dataset_id = "664e5812efdc9f1ed5dc2f7f"
# road damage by hurricane inundation mapping
mapping_id = "60ba583b1f2b7d4a916faf03"
# Galveston Deterministic Hurricane - Kriging inundationDuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def run_with_base_class():
# test galveston hurricane road failure

# road inventory for Galveston island
road_dataset_id = "60ba5ee94219ee25a56b6999"
road_dataset_id = "664e5812efdc9f1ed5dc2f7f"
# road damage by hurricane inundation mapping
mapping_id = "60ba583b1f2b7d4a916faf03"
# Galveston Deterministic Hurricane - Kriging inundationDuration
Expand Down

0 comments on commit 57cb035

Please sign in to comment.