Skip to content

Commit da5f514

Browse files
committed
feat(processing): validate inputs for get_processing_settings
* Added input validation for 'dimension' and 'selection' parameters. * Raises ValueError for invalid inputs with descriptive messages.
1 parent 6261182 commit da5f514

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/imcflibs/imagej/bdv.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from .. import pathtools
2222
from ..log import LOG as log
2323

24-
2524
# internal template strings used in string formatting (note: the `"""@private"""`
2625
# pseudo-decorator is there to instruct [pdoc] to omit those variables when generating
2726
# API documentation):
@@ -733,6 +732,21 @@ def get_processing_settings(dimension, selection, value, range_end):
733732
processing_option, dimension_select
734733
"""
735734

735+
# Validate inputs according to the function docstring
736+
valid_dimensions = ("angle", "channel", "illumination", "tile", "timepoint")
737+
if dimension not in valid_dimensions:
738+
raise ValueError(
739+
"Invalid dimension '%s', expected one of: %s"
740+
% (dimension, ", ".join(valid_dimensions))
741+
)
742+
743+
valid_selections = ("single", "multiple", "range")
744+
if selection not in valid_selections:
745+
raise ValueError(
746+
"Invalid selection '%s', expected one of: %s"
747+
% (selection, ", ".join(valid_selections))
748+
)
749+
736750
if selection == "single":
737751
processing_option = SINGLE % dimension
738752
dimension_select = "processing_" + dimension + "=[" + dimension + " %s]" % value

0 commit comments

Comments
 (0)