Skip to content

Commit

Permalink
Merge pull request #392 from ens-lgil/feature/demographic_range
Browse files Browse the repository at this point in the history
Set the demographic estimate_type to 'range' if there is no estimate …
  • Loading branch information
fyvon authored Oct 10, 2024
2 parents f49b046 + 6fc6216 commit f5d1330
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions curation/parsers/demographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions curation/parsers/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit f5d1330

Please sign in to comment.