Example #1
0
        def settings(data):
            # get the default encoded state, replacing the position with Inf
            state = VariablesSelection.encode_var_state(
                [list(self.model_selected),
                 list(self.model_other)])
            state = {
                key: (source_ind, np.inf)
                for key, (source_ind, _) in state.items()
            }

            self.openContext(data.domain)
            selected_keys = [
                key for key, (sind, _) in self.variable_state.items()
                if sind == 0
            ]

            if set(selected_keys).issubset(set(state.keys())):
                pass

            if self.__pending_selection_restore is not None:
                self._selection = np.array(self.__pending_selection_restore,
                                           dtype=int)
                self.__pending_selection_restore = None

            # update the defaults state (the encoded state must contain
            # all variables in the input domain)
            state.update(self.variable_state)
            # ... and restore it with saved positions taking precedence over
            # the defaults
            selected, other = VariablesSelection.decode_var_state(
                state, [list(self.model_selected),
                        list(self.model_other)])
            return selected, other
Example #2
0
        def settings(data):
            # get the default encoded state, replacing the position with Inf
            state = VariablesSelection.encode_var_state(
                [list(self.model_selected), list(self.model_other)]
            )
            state = {key: (source_ind, np.inf) for key, (source_ind, _) in state.items()}

            self.openContext(data.domain)
            selected_keys = [key for key, (sind, _) in self.variable_state.items() if sind == 0]

            if set(selected_keys).issubset(set(state.keys())):
                pass

            if self.__pending_selection_restore is not None:
                self._selection = np.array(self.__pending_selection_restore, dtype=int)
                self.__pending_selection_restore = None

            # update the defaults state (the encoded state must contain
            # all variables in the input domain)
            state.update(self.variable_state)
            # ... and restore it with saved positions taking precedence over
            # the defaults
            selected, other = VariablesSelection.decode_var_state(
                state, [list(self.model_selected), list(self.model_other)])
            return selected, other
Example #3
0
    def _load_settings(self):
        domain = self.data.domain
        variables = [
            v for v in domain.attributes + domain.metas if v.is_primitive()
        ]
        self.model_selected[:] = variables[:5]
        self.model_other[:] = variables[5:] + list(domain.class_vars)

        state = VariablesSelection.encode_var_state(
            [list(self.model_selected),
             list(self.model_other)])
        state = {key: (ind, np.inf) for key, (ind, _) in state.items()}
        state.update(self.variable_state)
        return VariablesSelection.decode_var_state(
            state, [list(self.model_selected),
                    list(self.model_other)])
Example #4
0
 def closeContext(self):
     self.variable_state = VariablesSelection.encode_var_state(
         [list(self.model_selected), list(self.model_other)]
     )
     super().closeContext()
Example #5
0
 def closeContext(self):
     self.variable_state = VariablesSelection.encode_var_state(
         [list(self.model_selected),
          list(self.model_other)])
     super().closeContext()