Skip to content

Commit

Permalink
#68 fixed: type casting from str to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
funkchaser committed Feb 17, 2025
1 parent ccc05c4 commit d89fbfb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/aixd_ara/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,16 @@ def cast_to_python_type(self, dataobject_name, value):
elif isinstance(dobj, DataReal):
castvalue = [float(v) for v in value]
elif isinstance(dobj, DataBool):
castvalue = [bool(v) for v in value]
castvalue = []
for v in value:
if isinstance(v, bool):
castvalue.append(v)
elif isinstance(v, int):
castvalue.append(bool(v))
elif isinstance(v, str):
castvalue.append({"True": True, "False": False}[v])
else:
raise ValueError(f"Dataobject type not recognized: {dobj.type}")
elif isinstance(dobj, DataCategorical):
castvalue = [str(v) for v in value]
else:
Expand Down
5 changes: 1 addition & 4 deletions src/aixd_ara/gh_ui_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ def instantiate_sample(ghdoc, sample_dict):
component_name = "DP_{}".format(dp_name)
component = find_component_by_nickname(ghdoc, component_name)

if not dp_vals:
print("No values for {}!".format(dp_name))
else:
ghparam_set_values(component, dp_vals)
ghparam_set_values(component, dp_vals)


def convert_str_to_bitmap(base64_imgstr, scale=1.0):
Expand Down

0 comments on commit d89fbfb

Please sign in to comment.