diff --git a/curation/parsers/demographic.py b/curation/parsers/demographic.py index 2fe2c222..cee6a551 100644 --- a/curation/parsers/demographic.py +++ b/curation/parsers/demographic.py @@ -4,14 +4,21 @@ class DemographicData(GenericData): - def __init__(self,type,value,spreadsheet_name): + def __init__(self,type:str,value:str|int|float,spreadsheet_name:str) -> None: GenericData.__init__(self,spreadsheet_name) self.type = type.strip() self.value = value + def update_demographic_data(self) -> None: + """ Change the default estimate_type value if no estimate is provided """ + demographic_keys = self.data.keys() + if not 'estimate' in demographic_keys and 'range' in demographic_keys: + self.data['estimate_type'] = 'range' + + @transaction.atomic - def create_demographic_model(self): + def create_demographic_model(self) -> Demographic: ''' Create an instance of the Demographic model. Return type: Demographic model diff --git a/curation/parsers/sample.py b/curation/parsers/sample.py index 4b72dfa8..5a8148dc 100644 --- a/curation/parsers/sample.py +++ b/curation/parsers/sample.py @@ -72,6 +72,7 @@ def str2demographic(self, field, val): else: variability = value current_demographic.add_data('variability', variability) + current_demographic.update_demographic_data() return current_demographic