diff --git a/CHANGELOG.md b/CHANGELOG.md index c2f84f562..3de1e1b39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pyincore/dfr3service.py b/pyincore/dfr3service.py index 68480b24f..a7bc56b41 100644 --- a/pyincore/dfr3service.py +++ b/pyincore/dfr3service.py @@ -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] diff --git a/tests/pyincore/analyses/roaddamage/test_roaddamage.py b/tests/pyincore/analyses/roaddamage/test_roaddamage.py old mode 100755 new mode 100644 index 667770050..810b0001a --- a/tests/pyincore/analyses/roaddamage/test_roaddamage.py +++ b/tests/pyincore/analyses/roaddamage/test_roaddamage.py @@ -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 diff --git a/tests/pyincore/analyses/roaddamage/test_roaddamage_w_hazard_obj.py b/tests/pyincore/analyses/roaddamage/test_roaddamage_w_hazard_obj.py index c10beae53..efb14356d 100755 --- a/tests/pyincore/analyses/roaddamage/test_roaddamage_w_hazard_obj.py +++ b/tests/pyincore/analyses/roaddamage/test_roaddamage_w_hazard_obj.py @@ -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