\(\renewcommand\AA{\unicode{x212B}}\)
Workspace Validators¶
As with the basic types (int, float, etc.) there are some special validators for checking input workspaces.
Those currently available are:
WorkspaceUnitValidator
- Checks that the workspace unit matches a given value. Code to create:WorkspaceUnitValidator("UnitName")
HistogramValidator
- Checks if the workspace is a histogram. Code to create:HistogramValidator(True/False)
CommonBinsValidator
- Checks that if bins in the first and last spectrum are the same, i.e. a tentative check that the workspace’s spectra have common bins. Code to create:CommonBinsValidator()
RawCountValidator
- Checks if the workspace contains raw counts. Code to create:RawCountsValidator(True/False)
InstrumentValidator
- Checks if the input workspace has a defined instrument. Code to create:InstrumentValidator()
To use a specific one pass the created validator as the validator argument of the declareProperty
function, e.g.
def PyInit(self):
# Requires the input workspace to have x-axis units of Wavelength
self.declareProperty(WorkspaceProperty(name="InputWorkspace",
defaultValue="",
direction=Direction.Input,
validator=WorkspaceUnitValidator("Wavelength")))