Skip to content

Commit

Permalink
Restructure conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
sevisal committed Oct 5, 2023
1 parent 614cdf6 commit 8b5471f
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions src/vai_lab/_plugin_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,33 @@ def _reshape(self, data, shape):

def _parse_options_dict(self,options_dict:Dict):
for key, val in options_dict.items():
if type(val) == str and val.replace('.', '').replace(',', '').isnumeric():
cleaned_opts = []
for el in val.split(","):
val = float(el)
if val.is_integer():
val = int(val)
cleaned_opts.append(val)
options_dict[key] = cleaned_opts
elif type(val) == str and val.lower() in ('yes', 'true'):
options_dict[key] = True
elif type(val) == str and val.lower() in ('no', 'false'):
options_dict[key] = False
elif type(val) == str and val.lower() in ('none'):
options_dict[key] = None
elif val == 'X':
options_dict[key] = self.X
elif val == 'Y':
options_dict[key] = self.Y
elif val == 'X_test':
options_dict[key] = self.X_test
elif val == 'Y_test':
options_dict[key] = self.Y_test
elif key.lower() == 'x':
options_dict[key] = self.X
elif key.lower() == 'y':
options_dict[key] = self.Y
if type(val) == str:
if val.replace('.', '').replace(',', '').isnumeric():
cleaned_opts = []
for el in val.split(","):
val = float(el)
if val.is_integer():
val = int(val)
cleaned_opts.append(val)
options_dict[key] = cleaned_opts
elif val.lower() in ('yes', 'true'):
options_dict[key] = True
elif val.lower() in ('no', 'false'):
options_dict[key] = False
elif val.lower() in ('none'):
options_dict[key] = None
elif val == 'X':
options_dict[key] = self.X
elif val == 'Y':
options_dict[key] = self.Y
elif val == 'X_test':
options_dict[key] = self.X_test
elif val == 'Y_test':
options_dict[key] = self.Y_test
elif key.lower() == 'x':
options_dict[key] = self.X
elif key.lower() == 'y':
options_dict[key] = self.Y
return options_dict

def _clean_options(self):
Expand Down

0 comments on commit 8b5471f

Please sign in to comment.