From 2cabf58b95981e9dd8d756ef554992d31686c11d Mon Sep 17 00:00:00 2001 From: burnout87 Date: Fri, 12 Apr 2024 14:13:15 +0200 Subject: [PATCH 1/3] LongString Parameter class --- cdci_data_analysis/analysis/parameters.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cdci_data_analysis/analysis/parameters.py b/cdci_data_analysis/analysis/parameters.py index 41574002..bdaaee04 100644 --- a/cdci_data_analysis/analysis/parameters.py +++ b/cdci_data_analysis/analysis/parameters.py @@ -580,6 +580,9 @@ def __init__(self, value=None, name_format='str', name=None, allowed_values = No def check_name_value(value, units=None, name=None, par_format=None): pass +class LongString(String): + owl_uris = String.owl_uris + ("http://odahub.io/ontology#LongString",) + class Name(String): owl_uris = String.owl_uris + ("http://odahub.io/ontology#AstrophysicalObject",) From 9e221a51c2f3f75d3bb9ee56cb75c95046f66698 Mon Sep 17 00:00:00 2001 From: burnout87 Date: Fri, 12 Apr 2024 14:30:16 +0200 Subject: [PATCH 2/3] LongString Parameter test --- tests/test_parameters.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_parameters.py b/tests/test_parameters.py index 552ea613..34788797 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -22,6 +22,7 @@ InputProdList, DetectionThreshold, String, + LongString, Boolean, StructuredParameter, PhosphorosFiltersTable, @@ -354,6 +355,7 @@ def test_parameter_bounds(): def test_parameter_meta_data(): bounded_parameter = Float(value = 1., name='bounded', min_value=0.1, max_value=2) choice_parameter = String(value = 'spam', name='choice', allowed_values=['spam', 'eggs', 'hams']) + long_choice_parameter = LongString(value='spam', name='choice', allowed_values=['spam', 'eggs', 'hams']) bool_parameter = Boolean(value = True, name = 'bool') assert bounded_parameter.reprJSONifiable() == [{'name': 'bounded', 'units': None, 'value': 1.0, @@ -364,6 +366,13 @@ def test_parameter_meta_data(): 'value': 'spam', 'restrictions': {'allowed_values': ['spam', 'eggs', 'hams']}, 'owl_uri': ["http://www.w3.org/2001/XMLSchema#str", "http://odahub.io/ontology#String"]}] + assert long_choice_parameter.reprJSONifiable() == [{'name': 'choice', + 'units': 'str', + 'value': 'spam', + 'restrictions': {'allowed_values': ['spam', 'eggs', 'hams']}, + 'owl_uri': ["http://www.w3.org/2001/XMLSchema#str", + "http://odahub.io/ontology#String", + "http://odahub.io/ontology#LongString"]}] assert bool_parameter.reprJSONifiable() == [{'name': 'bool', 'units': None, 'value': True, From 17872434cb725ae1a22fb0429503cc27b11c2093 Mon Sep 17 00:00:00 2001 From: burnout87 Date: Fri, 12 Apr 2024 15:46:56 +0200 Subject: [PATCH 3/3] adapted test --- tests/test_parameters.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_parameters.py b/tests/test_parameters.py index 34788797..3eb47853 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -355,7 +355,7 @@ def test_parameter_bounds(): def test_parameter_meta_data(): bounded_parameter = Float(value = 1., name='bounded', min_value=0.1, max_value=2) choice_parameter = String(value = 'spam', name='choice', allowed_values=['spam', 'eggs', 'hams']) - long_choice_parameter = LongString(value='spam', name='choice', allowed_values=['spam', 'eggs', 'hams']) + long_choice_parameter = LongString(value='long_spam', name='choice') bool_parameter = Boolean(value = True, name = 'bool') assert bounded_parameter.reprJSONifiable() == [{'name': 'bounded', 'units': None, 'value': 1.0, @@ -368,8 +368,7 @@ def test_parameter_meta_data(): 'owl_uri': ["http://www.w3.org/2001/XMLSchema#str", "http://odahub.io/ontology#String"]}] assert long_choice_parameter.reprJSONifiable() == [{'name': 'choice', 'units': 'str', - 'value': 'spam', - 'restrictions': {'allowed_values': ['spam', 'eggs', 'hams']}, + 'value': 'long_spam', 'owl_uri': ["http://www.w3.org/2001/XMLSchema#str", "http://odahub.io/ontology#String", "http://odahub.io/ontology#LongString"]}]