Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Added dataset transpose option

This commit is contained in:
Arnar Flatberg 2007-08-03 09:44:31 +00:00
parent e62a6ae9b3
commit 0523ebab05
2 changed files with 26 additions and 3 deletions

View File

@ -76,7 +76,7 @@ class Dataset:
"""Return the identifers along the dimension dim."""
return self._map[dim]
def _create_identifiers(self,shape,all_dims):
def _create_identifiers(self, shape, all_dims):
"""Creates dimension names and identifier names, and returns
identifiers."""
@ -141,7 +141,7 @@ class Dataset:
if type(axis)==int:
return self._dims[axis]
else:
return [dim for dim in self]
return [dim for dim in self._dims]
def common_dims(self, ds):
"""Returns a list of the common dimensions in the two datasets."""
@ -220,6 +220,19 @@ class Dataset:
"""
return copy.deepcopy(self)
def transpose(self):
"""Returns a copy of transpose of a dataset.
As for the moment: only support for 2D-arrays.
"""
#assert(self._array==ndarray)
ds = self.copy()
ds._array = ds._array.T
ds._dims.reverse()
ds.shape = ds._array.shape
return ds
def _validate_identifiers(self, identifiers):
for dim_name, ids in identifiers:

View File

@ -198,6 +198,11 @@ class NavigatorMenu(gtk.Menu):
self.append(self.save_item)
self.save_item.show()
self.trans_item = gtk.MenuItem('Transpose')
self.trans_item.connect('activate', self.on_transpose, navigator)
self.append(self.trans_item)
self.trans_item.show()
# Build plot menu
self.plot_menu = gtk.Menu()
@ -286,4 +291,9 @@ class NavigatorMenu(gtk.Menu):
project.data_tree_insert(self.tree_iter, 'Histogram', plot, None, "black", icon)
plot.set_selection_listener(project.set_selection)
project._selection_observers.append(plot)
def on_transpose(self, item, navigator):
project = main.project
ds = self.dataset.transpose()
icon = fluents.icon_factory.get("dataset")
project.data_tree_insert(self.tree_iter, self.dataset.get_name()+".T", ds, None, "black", icon)