diff --git a/orangecontrib/spark/utils/gui_utils.py b/orangecontrib/spark/utils/gui_utils.py index 0471357..2a23455 100644 --- a/orangecontrib/spark/utils/gui_utils.py +++ b/orangecontrib/spark/utils/gui_utils.py @@ -69,17 +69,19 @@ def update(self, values): self.widget.setText(values) def get_usable_value(self): - val = self.get_value() - if val=='None' or val=='' or val is None: + val = self.get_value().strip() + if val == 'None' or val == '' or val is None: return None if val in ('True', 'False'): return bool(val) try: - if float(val) == int(val): - return int(val) - else: + try: + if float(val) == int(val): + return int(val) + except ValueError: return float(val) + except ValueError: return val diff --git a/orangecontrib/spark/widgets/spark_ml_dataset.py b/orangecontrib/spark/widgets/spark_ml_dataset.py index d385cc4..8413f26 100644 --- a/orangecontrib/spark/widgets/spark_ml_dataset.py +++ b/orangecontrib/spark/widgets/spark_ml_dataset.py @@ -416,18 +416,18 @@ def set_data(self, data = None): self.data = data if self.data is not None: self.in_df = self.data - #self.used_attrs. - #self.class_attrs = VariablesListItemModel() - #self.meta_attrs = VariablesListItemModel() + # self.used_attrs. + # self.class_attrs = VariablesListItemModel() + # self.meta_attrs = VariablesListItemModel() self.available_attrs.extend(sorted(self.in_df.columns)) else: self.data = None self.in_df = None - #self.used_attrs = VariablesListItemModel() - #self.class_attrs = VariablesListItemModel() - #self.meta_attrs = VariablesListItemModel() - #self.available_attrs = VariablesListItemModel() + # self.used_attrs = VariablesListItemModel() + # self.class_attrs = VariablesListItemModel() + # self.meta_attrs = VariablesListItemModel() + # self.available_attrs = VariablesListItemModel() def update_domain_role_hints(self): """ Update the domain hints to be stored in the widgets settings. @@ -569,16 +569,11 @@ def update_completer_prefix(self, filter): def commit(self): self.update_domain_role_hints() if self.in_df is not None: - print(self.used_attrs) - print(self.class_attrs) - print(self.meta_attrs) - attributes = [att for att in self.used_attrs._list] class_var = [var for var in self.class_attrs._list] metas = [meta for meta in self.meta_attrs._list] VA = VectorAssembler(inputCols = attributes, outputCol = 'features') self.out_df = VA.transform(self.in_df) - print("class", class_var, type(class_var)) print("atributes", attributes) if len(class_var): self.out_df = self.out_df.withColumn('label', self.out_df[class_var[0]]) @@ -591,11 +586,11 @@ def reset(self): if self.data is not None: self.available_attrs.extend(sorted(self.in_df.columns)) else: - self.available_attrs = VariablesListItemModel() + self.available_attrs._list = [] - self.used_attrs = VariablesListItemModel() - self.class_attrs = VariablesListItemModel() - self.meta_attrs = VariablesListItemModel() + self.used_attrs._list = [] + self.class_attrs._list = [] + self.meta_attrs._list = [] self.update_domain_role_hints()