Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to add singleton axes on export #263

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions volumina/widgets/dataExportOptionsDlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ def eventFilter(self, watched, event):

class _AxisOrderValidator(QValidator):
def __init__(self, parent, inputSlot):
super(DataExportOptionsDlg._AxisOrderValidator, self).__init__(parent)
super().__init__(parent)
self._inputSlot = inputSlot
self._valid_axes = set("tzyxc")

def validate(self, userAxes, pos):
taggedShape = self._inputSlot.meta.getTaggedShape()
Expand All @@ -415,17 +416,16 @@ def validate(self, userAxes, pos):
userSet = set(str(userAxes))

# Ensure all user axes appear in the input
if not (userSet <= inputSet):
if not userSet.issubset(self._valid_axes):
return (QValidator.Invalid, userAxes, pos)

# Ensure no repeats
if len(userSet) != len(userAxes):
return (QValidator.Invalid, userAxes, pos)

# If missing non-singleton axes, maybe intermediate entry
# (It's okay to omit singleton axes)
for key in inputSet - userSet:
if taggedShape[key] != 1:
# Ensure no non-singleton axis was omitted:
for key in self._valid_axes - userSet:
if taggedShape.get(key, 1) != 1:
k-dominik marked this conversation as resolved.
Show resolved Hide resolved
return (QValidator.Intermediate, userAxes, pos)

return (QValidator.Acceptable, userAxes, pos)
Expand Down