Skip to content

Commit

Permalink
Merge pull request #78 from OasisLMF/release/3.1.4
Browse files Browse the repository at this point in the history
Release 3.1.4
  • Loading branch information
sambles authored Dec 11, 2023
2 parents a9795e0 + b9c44fc commit 3c9a3a2
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 38 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ods_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '3.1.3'
__version__ = '3.1.4'

import logging

Expand Down
101 changes: 64 additions & 37 deletions ods_tools/data/analysis_settings_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions ods_tools/data/model_settings_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
"type":"string",
"enum":[
"aal",
"aalcalcmeanonly",
"elt",
"plt",
"lec",
Expand All @@ -186,6 +187,8 @@
"plt_quantile",
"plt_moment",
"alt_period",
"alt_meanonly",
"alct_confidence",
"alct_convergence",
"ept",
"ept_full_uncertainty_aep",
Expand Down Expand Up @@ -407,6 +410,7 @@
"type":"string",
"enum":[
"aal",
"aalcalcmeanonly",
"elt",
"plt",
"lec",
Expand All @@ -429,6 +433,8 @@
"plt_quantile",
"plt_moment",
"alt_period",
"alt_meanonly",
"alct_confidence",
"alct_convergence",
"ept",
"ept_full_uncertainty_aep",
Expand Down
24 changes: 24 additions & 0 deletions tests/test_ods_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 3c9a3a2

Please sign in to comment.