def test_no_data(self): model = ArrayDataModel(value_type=FloatValue()) self.assertEqual(model.data.ndim, 2) self.assertEqual(model.data.shape, (0, 0)) self.assertEqual(model.data.dtype, float) self.assertEqual(model.get_column_count(), 0) self.assertTrue(model.can_have_children(())) self.assertEqual(model.get_row_count(()), 0)
def _create_item_model(self): self.data = np.arange(120.0).reshape(4, 5, 6) self.model = ArrayDataModel(data=self.data, value_type=FloatValue()) return DataViewItemModel( model=self.model, selection_type='row', exporters=[], )
def setUp(self): super().setUp() self.array = np.arange(30.0).reshape(5, 2, 3) self.model = ArrayDataModel(data=self.array, value_type=FloatValue()) self.values_changed_event = None self.structure_changed_event = None self.model.observe(self.model_values_changed, 'values_changed') self.model.observe(self.model_structure_changed, 'structure_changed')
def _create_contents(self, parent): """ Creates the left hand side or top depending on the style. """ self.data_view = DataViewWidget( parent=parent, data_model=ArrayDataModel( data=self.data, value_type=FloatValue(), ), selection_mode='extended', exporters=[ RowExporter(format=table_format), RowExporter(format=csv_format), RowExporter(format=npy_format), ], drop_handlers=[ FileDropHandler(extensions=['.npy'], open_file=self.load_data), ], ) self.data_view._create() return self.data_view.control
def test_data_list(self): data = list(range(30)) model = ArrayDataModel(data=data, value_type=FloatValue()) self.assertEqual(model.data.ndim, 2) self.assertEqual(model.data.shape, (30, 1))
def test_data_1d(self): array = np.arange(30.0) model = ArrayDataModel(data=array, value_type=FloatValue()) self.assertEqual(model.data.ndim, 2) self.assertEqual(model.data.shape, (30, 1))
def _create_widget(self): self.data = np.arange(120.0).reshape(4, 5, 6) self.model = ArrayDataModel(data=self.data, value_type=FloatValue()) return DataViewWidget(parent=self.parent.control, data_model=self.model)