Skip to content

Commit

Permalink
Merge pull request #746 from kids-first/fix-missing-values
Browse files Browse the repository at this point in the history
🐛 Fix processing of missing value list
  • Loading branch information
znatty22 authored Sep 17, 2021
2 parents a5c722e + 0b2c0d1 commit ffeb690
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion creator/data_templates/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Meta:
"data_type": "string",
"instructions": f"Populate label_{x} properly",
"accepted_values": ["a", "b", "c"],
"missing_values": "Unknown, Not Reported",
"missing_values": ["a", "b", "c"],
}
for x in range(2)
]
Expand Down
7 changes: 5 additions & 2 deletions creator/data_templates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def field_definitions_dataframe(self):
This will become the content of the field definitions file when
the user requests to download the template files
"""
def format_accepted(value):
def format_list(value):
"""
Convert list to delimited str
"""
Expand All @@ -224,7 +224,10 @@ def format_accepted(value):
if "key" in df.columns:
df.drop(columns=["key"], axis=1, inplace=True)
df["accepted_values"] = df["accepted_values"].apply(
format_accepted
format_list
)
df["missing_values"] = df["missing_values"].apply(
format_list
)
df.columns = [
" ".join([w.title() for w in col.split("_")])
Expand Down
1 change: 1 addition & 0 deletions tests/data_templates/test_template_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def test_field_definitions_dataframe(db):
)
assert df.shape == (2, len(FieldDefinitionsSchema.key_order) - 1)
assert set(df["Accepted Values"].values.tolist()) == {"a,b,c"}
assert set(df["Missing Values"].values.tolist()) == {"a,b,c"}


def test_load_field_definitions(db, tmpdir):
Expand Down

0 comments on commit ffeb690

Please sign in to comment.