summaryrefslogtreecommitdiff
path: root/silx/gui/data/NumpyAxesSelector.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/data/NumpyAxesSelector.py')
-rw-r--r--silx/gui/data/NumpyAxesSelector.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/silx/gui/data/NumpyAxesSelector.py b/silx/gui/data/NumpyAxesSelector.py
index f4641da..4530aa9 100644
--- a/silx/gui/data/NumpyAxesSelector.py
+++ b/silx/gui/data/NumpyAxesSelector.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
+# Copyright (c) 2016-2018 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -29,7 +29,7 @@ from __future__ import division
__authors__ = ["V. Valls"]
__license__ = "MIT"
-__date__ = "16/01/2017"
+__date__ = "29/01/2018"
import numpy
import functools
@@ -133,7 +133,7 @@ class _Axis(qt.QWidget):
def setAxisNames(self, axesNames):
"""Set the available list of names for the axis.
- :param list[str] axesNames: List of available names
+ :param List[str] axesNames: List of available names
"""
self.__axes.clear()
previous = self.__axes.blockSignals(True)
@@ -146,7 +146,7 @@ class _Axis(qt.QWidget):
def setCustomAxis(self, axesNames):
"""Set the available list of named axis which can be set to a value.
- :param list[str] axesNames: List of customable axis names
+ :param List[str] axesNames: List of customable axis names
"""
self.__customAxisNames = set(axesNames)
self.__updateSliderVisibility()
@@ -258,9 +258,12 @@ class NumpyAxesSelector(qt.QWidget):
The size of the list will constrain the dimension of the resulting
array.
- :param list[str] axesNames: List of string identifying axis names
+ :param List[str] axesNames: List of distinct strings identifying axis names
"""
self.__axisNames = list(axesNames)
+ assert len(set(self.__axisNames)) == len(self.__axisNames),\
+ "Non-unique axes names: %s" % self.__axisNames
+
delta = len(self.__axis) - len(self.__axisNames)
if delta < 0:
delta = 0
@@ -277,7 +280,7 @@ class NumpyAxesSelector(qt.QWidget):
def setCustomAxis(self, axesNames):
"""Set the available list of named axis which can be set to a value.
- :param list[str] axesNames: List of customable axis names
+ :param List[str] axesNames: List of customable axis names
"""
self.__customAxisNames = set(axesNames)
for axis in self.__axis:
@@ -415,13 +418,20 @@ class NumpyAxesSelector(qt.QWidget):
else:
selection.append(slice(None))
axisNames.append(name)
-
self.__selection = tuple(selection)
# get a view with few fixed dimensions
# with a h5py dataset, it create a copy
# TODO we can reuse the same memory in case of a copy
view = self.__data[self.__selection]
+ if set(self.__axisNames) - set(axisNames) != set([]):
+ # Not all the expected axis are there
+ if self.__selectedData is not None:
+ self.__selectedData = None
+ self.__selection = tuple()
+ self.selectionChanged.emit()
+ return
+
# order axis as expected
source = []
destination = []