def test_save_matrixes(all_dsc): all_dsc.save_datasets(f_name) dsto = DatasetContainer() dsto.read_datasets(f_name) nm = dsto.get_id_name_map() mat_ds = dsto[nm[0][0]] print(mat_ds.values)
def test_save_tree(dsc3): dsc3.save_datasets(f_name) dsto = DatasetContainer() dsto.read_datasets(f_name) assert len(dsto) == 3 dsnext = DataSet() with pytest.raises(ValueError): dsdummy = dsto[dsnext.id]
def prefmap_dsc(): '''Get liking and sensory std. test data sets ''' dsc = DatasetContainer() for mi in CHEESE: dsc.add(imp_ds(mi)) return dsc
def conjoint_dsc(): '''Get Conjoint std. test data sets ''' dsc = DatasetContainer() for mi in CONJOINT: dsc.add(imp_ds(*mi)) return dsc
def dsc3(): dsl = [] for i in range(3): name = "Dataset{index}".format(index=i) dtype = DS_TYPES[i % 2] ds = DataSet(display_name=name, kind=dtype) dsl.append(ds) dst = tuple(dsl) dsc = DatasetContainer() dsc.add(*dst) return dsc
def all_dsc(): '''Data set container/collection mock''' dsc = DatasetContainer() # ad = CONJOINT + VINE + CHEESE ad = CHEESE + CONJOINT for mi in ad: dsc.add(imp_ds(mi)) dsc.add(discrete_ds()) dsc.add(discrete_nans_ds()) return dsc
def test_update_propagation(discrete_ds): # Assemble object graph dsc = DatasetContainer() bsp = CalcContainer(dsc=dsc) bspc = BasicStatPluginController(bsp) # Verify that empty dsc gives empty selection list print("Available", bspc.available_ds) assert len(bspc.available_ds) == 0 # Simulate data set added dsc.add(discrete_ds) # Verify that the added data set i available in the selection list print("Available", bspc.available_ds) assert len(bspc.available_ds) == 1 # Simulat that data set i selected for computation bspc.selected_ds.append(bspc.available_ds[0][0]) print("Selected", bspc.selected_ds) print("Calculations", bspc.model.calculations) # Simulat removal of data set del dsc[bspc.available_ds[0][0]] # Verify that it is also removed from selection list assert len(bspc.available_ds) == 0
def retrieve_dataset(self, dataset, timestamp_min=None, timestamp_max=None, time_resolution=None): """Retrieve a dataset from the database. Parameters ---------- dataset : string The dataset to retrieve from the database. Must be one of the following: * timestamp * heartrate * intensity * activity * steps timestamp_min : datetime.datetime, None The lower limit (included) to return data for. If None, no lower limit will be set. timestamp_max : datetime.datetime, None The upper limit (not included) to return data for If None, no upper limit will be set. time_resolution : datetime.timedelta, None The time resolution of the dataset container returned. If None, the default of 1 minute will be used. Returns ------- res : DatasetContainer The container with the retrieved dataset. """ self.query_dataset(dataset, timestamp_min=timestamp_min, timestamp_max=timestamp_max) res = DatasetContainer(dataset, time_resolution=time_resolution) for ts, val in self.results: res.append(datetime.fromtimestamp(ts), val) return res
from dataset_container import DatasetContainer dsc = DatasetContainer() dsc.read_datasets('/home/thomas/.config/ConsumerCheck.pkl') nm = dsc.get_id_name_map() print(nm)
prefmap_plugin_view = make_plugin_view( 'Prefmap', prefmap_nodes, selection_view, prefmap_view) if __name__ == '__main__': print("Prefmap GUI test start") from tests.conftest import imp_ds one_branch = False # Folder, File name, Display name, DS type ds_C_meta = ('Cheese', 'ConsumerLiking.txt', 'Cheese liking', 'Consumer liking') ds_S_meta = ('Cheese', 'SensoryData.txt', 'Cheese profiling', 'Descriptive analysis / sensory profiling') C = imp_ds(ds_C_meta) S = imp_ds(ds_S_meta) if one_branch: prefmap = Prefmap(ds_C=C, ds_S=S) pc = PrefmapController(prefmap) test = TestOneNode(one_model=pc) test.configure_traits(view=dummy_view(prefmap_nodes)) else: dsc = DatasetContainer() dsc.add(C) dsc.add(S) prefmap = PrefmapCalcContainer(dsc=dsc) ppc = PrefmapPluginController(prefmap) ppc.configure_traits( view=prefmap_plugin_view)
class MainUi(HasTraits): """Main application class""" dsc = DatasetContainer() # en_advanced = Bool(False) win_handle = Any() splash = None # Object representating the basic stat basic_stat = Instance(BasicStatPluginController) # Object representing the PCA and the GUI tab pca = Instance(PcaPluginController) # Object representing the Prefmap and the GUI tab prefmap = Instance(PrefmapPluginController) # Object representing the PlsrPcr and the GUI tab plscr = Instance(PlsrPcrPluginController) # Object representing the Conjoint and the GUI tab conjoint = Instance(ConjointPluginController) # Object representing the IndDiff and the GUI tab ind_diff = Instance(IndDiffPluginController) # Create an action that open dialog for dataimport import_action = Action(name='Add &Data set', action='import_data') # Create an action that exits the application. exit_action = Action(name='E&xit', action='_on_close') about_action = Action(name='&About', action='view_about') user_manual_action = Action(name='&User manual', action='view_user_manual') close_action = Action(name='&Remove Data sets', action='_close_ds') advanced_action = Action(name='&Advanced settings', checked_when='en_advanced', style='toggle', action='_toggle_advanced') def _basic_stat_default(self): basic_statisitc = BasicStatCalcContainer(dsc=self.dsc) return BasicStatPluginController(basic_statisitc) def _pca_default(self): pca = PcaCalcContainer(dsc=self.dsc) return PcaPluginController(pca) def _prefmap_default(self): prefmap = PrefmapCalcContainer(dsc=self.dsc) return PrefmapPluginController(prefmap) def _plscr_default(self): plscr = PlsrPcrCalcContainer(dsc=self.dsc) return PlsrPcrPluginController(plscr) def _conjoint_default(self): conjoint = ConjointCalcContainer(dsc=self.dsc) return ConjointPluginController(conjoint) def _ind_diff_default(self): ind_diff = IndDiffCalcContainer(dsc=self.dsc) return IndDiffPluginController(ind_diff) def _toggle_advanced(self): self.en_advanced = not self.en_advanced print(self.en_advanced) # The main view traits_ui_view = View( Group(Item('dsc', editor=tree_editor, label="Data sets", show_label=False), Item('basic_stat', editor=InstanceEditor(view=bs_plugin_view), style='custom', label="Basic stat liking", show_label=False), Item('pca', editor=InstanceEditor(view=pca_plugin_view), style='custom', label="PCA", show_label=False), Item('prefmap', editor=InstanceEditor(view=prefmap_plugin_view), style='custom', label="Prefmap", show_label=False), Item('plscr', editor=InstanceEditor(view=plscr_plugin_view), style='custom', label="PLSR/PCR", show_label=False), Item('conjoint', editor=InstanceEditor(view=conjoint_plugin_view), style='custom', label="Conjoint", show_label=False), Item('ind_diff', editor=InstanceEditor(view=ind_diff_plugin_view), style='custom', label="Individual differences", show_label=False), layout='tabbed'), # end UI tabs group resizable=True, width=1000, height=600, title='ConsumerCheck', menubar=MenuBar( Menu( import_action, close_action, # exit_action, name='&File'), ## Menu(advanced_action, name='&Settings'), Menu(about_action, user_manual_action, name='&Help'), ), handler=MainViewHandler)
def synth_dsc(): dsc = DatasetContainer() dsc.add(simple_ds(), discrete_ds(), discrete_nans_ds(), zero_var_ds(), iris_ds()) return dsc