Skip to content

Commit

Permalink
fix(render): Choose value type according to latest discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jun 3, 2024
1 parent 24f8671 commit 795015f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tools/schemacode/bidsschematools/render/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,16 @@ def resolve_metadata_type(definition):

elif "definition" in definition:
json_def = definition["definition"]
if "Levels" in json_def:
keytypes = {type(k) for k in json_def["Levels"]}
type_map = {
str: "string",
int: "integer",
float: "number",
}
string = " or ".join([type_map[k] for k in keytypes])

if "Delimiter" in json_def:
# Delimiter indicates the value must be parsed. For BIDS purposes,
# this is a string, even if the parsed array is of numbers.
string = "string"

Check warning on line 231 in tools/schemacode/bidsschematools/render/utils.py

View check run for this annotation

Codecov / codecov/patch

tools/schemacode/bidsschematools/render/utils.py#L231

Added line #L231 was not covered by tests
elif "Levels" in json_def:
# JSON keys are always strings.
string = "string"
elif "Units" in json_def:
# Values with units are always (any exceptions?) numbers.
string = "number"
else:
string = "string or number"

Check warning on line 239 in tools/schemacode/bidsschematools/render/utils.py

View check run for this annotation

Codecov / codecov/patch

tools/schemacode/bidsschematools/render/utils.py#L239

Added line #L239 was not covered by tests
Expand Down

0 comments on commit 795015f

Please sign in to comment.