diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fe6e0a58..55d4bfaf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,8 @@ ODS_Tools Changelog =================== +.. _`3.1.4`: https://github.com/OasisLMF/ODS_Tools/compare/3.1.3...3.1.4 + `3.1.3`_ --------- * [#64](https://github.com/OasisLMF/ODS_Tools/pull/66) - Backward compatibility when adding new codes in OED diff --git a/ods_tools/__init__.py b/ods_tools/__init__.py index 9c88df38..9863d825 100644 --- a/ods_tools/__init__.py +++ b/ods_tools/__init__.py @@ -1,4 +1,4 @@ -__version__ = '3.1.3' +__version__ = '3.1.4' import logging diff --git a/ods_tools/data/analysis_settings_schema.json b/ods_tools/data/analysis_settings_schema.json index 66e9e3d5..ac0f4cff 100644 --- a/ods_tools/data/analysis_settings_schema.json +++ b/ods_tools/data/analysis_settings_schema.json @@ -46,12 +46,12 @@ "description": "If true, output the average annual loss by level for the summary set.", "default": false }, - "aalcalcmeanonly": { - "type": "boolean", - "title": "AAL Mean Only calculaton flag", - "description": "If true, output the average annual loss by level for the summary set without calculating the standard deviation.", - "default": false - }, + "aalcalcmeanonly": { + "type": "boolean", + "title": "AAL Mean Only calculaton flag", + "description": "If true, output the average annual loss by level for the summary set without calculating the standard deviation.", + "default": false + }, "pltcalc": { "type": "boolean", "title": "PLT calculation flag", @@ -172,12 +172,12 @@ "description": "Period Average Loss Table (ORD Output flag)", "default": false }, - "alt_meanonly": { - "type": "boolean", - "title": "ALT Mean Only", - "description": "Average Loss Table with no standard deviation calculation (ORD Output flag)", - "default": false - }, + "alt_meanonly": { + "type": "boolean", + "title": "ALT Mean Only", + "description": "Average Loss Table with no standard deviation calculation (ORD Output flag)", + "default": false + }, "alct_convergence": { "type": "boolean", "title": "ALCT", @@ -379,10 +379,37 @@ }, "footprint_set": { "type": "string", - "title": "Footprint set file ID.", - "description": "Identifier for the footprint files that are used for output calculations.", - "default": 1 - } + "title": "Footprint set file ID.", + "description": "Identifier for the footprint files that are used for output calculations.", + "default": 1 + }, + "vulnerability_set": { + "type": "string", + "title": "Vulnerability set file ID.", + "description": "Identifier for the vulnerability files that are used for output calculations.", + "default": 1 + }, + "correlation_settings": { + "type": "array", + "title": "Correlation Settings", + "description": "The Correlation Settings", + "items": { + "type": "object", + "properties": { + "peril_correlation_group": { + "type": "integer", + "title": "Peril Correlation Group", + "description": "The Peril Correlation Group", + "minLength": 1 + }, + "correlation_value": { + "type": "string", + "title": "Correlation Value", + "description": "The Correlation Value" + } + } + } + } } }, "gul_output": { @@ -425,27 +452,27 @@ "description": "If true generate losses for fully correlated output, i.e. no independence between groups, in addition to losses for default output.", "default": false }, - "pla": { - "type": "boolean", - "title": "Apply Post Loss Amplification", - "description": "If true apply post loss amplification/reduction to losses.", - "default": false - }, - "pla_secondary_factor": { - "type": "number", - "title": "Optional secondary factor for Post Loss Amplification", - "description": "Secondary factor to apply to post loss amplification/reduction factors.", - "default": 1, - "minimum": 0, - "maximum": 1 - }, - "pla_uniform_factor": { - "type": "number", - "title": "Optional uniform factor for Post Loss Amplification", - "description": "Uniform factor to apply across all losses.", - "default": 0, - "minimum": 0 - } + "pla": { + "type": "boolean", + "title": "Apply Post Loss Amplification", + "description": "If true apply post loss amplification/reduction to losses.", + "default": false + }, + "pla_secondary_factor": { + "type": "number", + "title": "Optional secondary factor for Post Loss Amplification", + "description": "Secondary factor to apply to post loss amplification/reduction factors.", + "default": 1, + "minimum": 0, + "maximum": 1 + }, + "pla_uniform_factor": { + "type": "number", + "title": "Optional uniform factor for Post Loss Amplification", + "description": "Uniform factor to apply across all losses.", + "default": 0, + "minimum": 0 + } }, "required": [ "model_supplier_id", diff --git a/ods_tools/data/model_settings_schema.json b/ods_tools/data/model_settings_schema.json index 1dd6e035..b35a0b86 100644 --- a/ods_tools/data/model_settings_schema.json +++ b/ods_tools/data/model_settings_schema.json @@ -163,6 +163,7 @@ "type":"string", "enum":[ "aal", + "aalcalcmeanonly", "elt", "plt", "lec", @@ -186,6 +187,8 @@ "plt_quantile", "plt_moment", "alt_period", + "alt_meanonly", + "alct_confidence", "alct_convergence", "ept", "ept_full_uncertainty_aep", @@ -407,6 +410,7 @@ "type":"string", "enum":[ "aal", + "aalcalcmeanonly", "elt", "plt", "lec", @@ -429,6 +433,8 @@ "plt_quantile", "plt_moment", "alt_period", + "alt_meanonly", + "alct_confidence", "alct_convergence", "ept", "ept_full_uncertainty_aep", diff --git a/tests/test_ods_package.py b/tests/test_ods_package.py index 3ce1d5d9..35d739c7 100644 --- a/tests/test_ods_package.py +++ b/tests/test_ods_package.py @@ -826,3 +826,27 @@ def test_versioning_wrong_order(self): # # Assert the OccupancyCode is as expected assert oed_exposure.location.dataframe.loc[0, "OccupancyCode"] == 9995 + + def test_all_analysis_options__in_valid_metrics(self): + model_schema = ModelSettingSchema().schema + analysis_schema = AnalysisSettingSchema().schema + + # extract model settings 'valid_metrics' options, and check both match + global__valid_output_metrics = set(model_schema['properties']['model_settings']['properties']['valid_output_metrics']['items']['enum']) + event_set__valid_metrics = set(model_schema['properties']['model_settings']['properties']['event_set'] + ['properties']['options']['items']['properties']['valid_metrics']['items']['enum']) + self.assertEqual(global__valid_output_metrics, event_set__valid_metrics) + + # Build expected list from analysis settings schema. + excluded_keys_list = ['id', 'oed_fields', 'lec_output', 'return_period_file', 'parquet_format', 'eltcalc', 'pltcalc', 'leccalc', 'aalcalc'] + extra_keys_list = ['aal', 'elt', 'plt', 'lec', 'aep', 'oep', 'ept', 'psept'] + + settings_output_options = { + **analysis_schema['definitions']['output_summaries']['items']['properties'], + **analysis_schema['definitions']['output_summaries']['items']['properties']['leccalc']['properties'], + **analysis_schema['definitions']['output_summaries']['items']['properties']['ord_output']['properties'] + } + expected_list = set(extra_keys_list + [k for k in settings_output_options if k not in excluded_keys_list]) + + self.assertEqual(expected_list, global__valid_output_metrics) + self.assertEqual(expected_list, event_set__valid_metrics)