From d5999ac40784590287655da7ac799158d88c227f Mon Sep 17 00:00:00 2001 From: Gigaszi <74006329+Gigaszi@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:09:57 +0100 Subject: [PATCH] feat: result value above 100% for mapping saturation (#479) * feat: add classification and plot creation for over 100% results * feat: new indicator classification * add: revert else-statement --------- Co-authored-by: Levi Szamek Co-authored-by: Jonas <36933111+hn437@users.noreply.github.com> --- .../indicators/mapping_saturation/indicator.py | 12 ++++++++++++ .../test_indicator_mapping_saturation.py | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/workers/ohsome_quality_analyst/indicators/mapping_saturation/indicator.py b/workers/ohsome_quality_analyst/indicators/mapping_saturation/indicator.py index 033afb839..630cdcd22 100644 --- a/workers/ohsome_quality_analyst/indicators/mapping_saturation/indicator.py +++ b/workers/ohsome_quality_analyst/indicators/mapping_saturation/indicator.py @@ -55,6 +55,8 @@ def __init__( self.upper_threshold = 0.97 # Threshold derived from Gröchenig et al. # TODO: What is a good lower threshold? self.lower_threshold = 0.30 + self.above_one_lower_threshold = 1.3 + self.above_one_upper_threshold = 1.5 # Attributes needed for result determination self.best_fit: Optional[models.BaseStatModel] = None @@ -124,6 +126,16 @@ def calculate(self) -> None: self.result.class_ = 3 elif self.lower_threshold >= self.result.value > 0: self.result.class_ = 1 + elif self.above_one_lower_threshold >= self.result.value > 1: + self.result.class_ = 5 + elif ( + self.above_one_upper_threshold + >= self.result.value + > self.above_one_lower_threshold + ): + self.result.class_ = 3 + elif self.result.value > self.above_one_upper_threshold: + self.result.class_ = 1 else: raise ValueError( "Result value (saturation) is an unexpected value: {}".format( diff --git a/workers/tests/integrationtests/test_indicator_mapping_saturation.py b/workers/tests/integrationtests/test_indicator_mapping_saturation.py index 6c1fb1294..596a27873 100644 --- a/workers/tests/integrationtests/test_indicator_mapping_saturation.py +++ b/workers/tests/integrationtests/test_indicator_mapping_saturation.py @@ -33,7 +33,6 @@ def test(self): self.assertIsNotNone(indicator.best_fit) self.assertTrue(indicator.fitted_models) - self.assertLessEqual(indicator.result.value, 1.0) self.assertGreaterEqual(indicator.result.value, 0.0) self.assertIsNotNone(indicator.result.label)