Skip to content

Commit

Permalink
Merge pull request #669 from oda-hub/longStringParam
Browse files Browse the repository at this point in the history
LongString Parameter class
  • Loading branch information
burnout87 authored Apr 12, 2024
2 parents c1b4607 + 1787243 commit 7331d28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cdci_data_analysis/analysis/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",)

Expand Down
8 changes: 8 additions & 0 deletions tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
InputProdList,
DetectionThreshold,
String,
LongString,
Boolean,
StructuredParameter,
PhosphorosFiltersTable,
Expand Down Expand Up @@ -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='long_spam', name='choice')
bool_parameter = Boolean(value = True, name = 'bool')
assert bounded_parameter.reprJSONifiable() == [{'name': 'bounded',
'units': None, 'value': 1.0,
Expand All @@ -364,6 +366,12 @@ 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': 'long_spam',
'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,
Expand Down

0 comments on commit 7331d28

Please sign in to comment.