Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed DFR3 service's out of index error #564

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [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
ywkim312 marked this conversation as resolved.
Show resolved Hide resolved
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"
ywkim312 marked this conversation as resolved.
Show resolved Hide resolved
# 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
Loading