Skip to content

Commit

Permalink
Use the new ArrayBoundedValidator constructor in algorithms. Re #9777
Browse files Browse the repository at this point in the history
  • Loading branch information
Antti Soininen committed Mar 11, 2019
1 parent a1f4a68 commit 413f265
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 59 deletions.
4 changes: 1 addition & 3 deletions Framework/DataHandling/src/SaveGSS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ void SaveGSS::init() {

auto must_be_3 = boost::make_shared<Kernel::ArrayLengthValidator<int>>(3);
auto precision_range =
boost::make_shared<Kernel::ArrayBoundedValidator<int>>();
precision_range->setLower(0);
precision_range->setUpper(10);
boost::make_shared<Kernel::ArrayBoundedValidator<int>>(0, 10);

auto precision_validator = boost::make_shared<Kernel::CompositeValidator>();
precision_validator->add(must_be_3);
Expand Down
1 change: 0 additions & 1 deletion Framework/MDAlgorithms/src/SetMDFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ void SetMDFrame::init() {

auto axisValidator =
boost::make_shared<Mantid::Kernel::ArrayBoundedValidator<int>>();
axisValidator->clearUpper();
axisValidator->setLower(0);
declareProperty(
Kernel::make_unique<Kernel::ArrayProperty<int>>(
Expand Down
1 change: 0 additions & 1 deletion Framework/MDAlgorithms/src/TransposeMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void TransposeMD::init() {
"An input workspace.");

auto axisValidator = boost::make_shared<ArrayBoundedValidator<int>>();
axisValidator->clearUpper();
axisValidator->setLower(0);

declareProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ def PyInit(self):
self.declareProperty(MultipleFileProperty(name="RunNumber",
extensions=EXTENSIONS_NXS),
"Event file")
validator = IntArrayBoundedValidator()
validator.setLower(0)
validator = IntArrayBoundedValidator(lower=0)
self.declareProperty(IntArrayProperty("Background", values=[0], direction=Direction.Input,
validator=validator))
self.declareProperty("XPixelSum", 1,
Expand All @@ -91,8 +90,7 @@ def PyInit(self):
"Maximum absolute value of offsets; default is 1")
self.declareProperty("CrossCorrelation", True,
"CrossCorrelation if True; minimize using many peaks if False.")
validator = FloatArrayBoundedValidator()
validator.setLower(0.)
validator = FloatArrayBoundedValidator(lower=0.)
self.declareProperty(FloatArrayProperty("PeakPositions", []),
"Comma delimited d-space positions of reference peaks. Use 1-3 for Cross Correlation. "+
"Unlimited for many peaks option.")
Expand Down
3 changes: 1 addition & 2 deletions Framework/PythonInterface/plugins/algorithms/ConjoinFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def __load(self, directory, instr, run, loader, exts, wksp):
raise RuntimeError("Failed to load run %s from file %s" % (str(run), filename))

def PyInit(self):
greaterThanZero = IntArrayBoundedValidator()
greaterThanZero.setLower(0)
greaterThanZero = IntArrayBoundedValidator(lower=0)
self.declareProperty(IntArrayProperty("RunNumbers",values=[0],validator=greaterThanZero), doc="Run numbers")
self.declareProperty(WorkspaceProperty("OutputWorkspace", "", direction=Direction.Output))
self.declareProperty(FileProperty("Directory", "", FileAction.OptionalDirectory))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def PyInit(self):
self.declareProperty("GenerateBraggReflections", False,
"Generate Bragg reflections other than reading a Fullprof .irf file. ")

arrvalidator = IntArrayBoundedValidator()
arrvalidator.setLower(0)
arrvalidator = IntArrayBoundedValidator(lower=0)
self.declareProperty(IntArrayProperty("MaxHKL", values=[12, 12, 12], validator=arrvalidator,
direction=Direction.Input), "Maximum reflection (HKL) to generate")

Expand Down
3 changes: 1 addition & 2 deletions Framework/PythonInterface/plugins/algorithms/DeltaPDF3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def PyInit(self):
self.declareProperty("Shape", "sphere", doc="Shape to cut out reflections",
validator=StringListValidator(['sphere', 'cube']))
self.setPropertySettings("Shape", condition)
val_min_zero = FloatArrayBoundedValidator()
val_min_zero.setLower(0.)
val_min_zero = FloatArrayBoundedValidator(lower=0.)
self.declareProperty(FloatArrayProperty("Size", [0.2], validator=val_min_zero),
"Width of cube/diameter of sphere used to remove reflections, in (HKL) (one or three values)")
self.setPropertySettings("Size", condition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def PyInit(self):
self.declareProperty("ProcessBackground", False, "Option to process background from input data file.")
backgroundtypes = ["Polynomial", "Chebyshev", "FullprofPolynomial"]
self.declareProperty("BackgroundType", "Polynomial", StringListValidator(backgroundtypes), "Type of background.")
arrvalidator = FloatArrayBoundedValidator()
arrvalidator.setLower(0.)
arrvalidator = FloatArrayBoundedValidator(lower=0.)
self.declareProperty(FloatArrayProperty("BackgroundPoints", values=[], validator=arrvalidator, direction=Direction.Input),
"User specified X/TOF values of the data points to calculate background.")
self.declareProperty(MatrixWorkspaceProperty("BackgroundWorkspace", "", Direction.Output, PropertyMode.Optional),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ def __load(self, directory, prefix):

def PyInit(self):
self.declareProperty("FilePrefix","")
intArrayValidator = IntArrayBoundedValidator()
intArrayValidator.setLower(0)
intArrayValidator = IntArrayBoundedValidator(lower=0)
self.declareProperty(IntArrayProperty("RunNumbers",[0], validator=intArrayValidator))
self.declareProperty(FileProperty("Directory", "", action=FileAction.OptionalDirectory))

Expand Down
3 changes: 1 addition & 2 deletions Framework/PythonInterface/plugins/algorithms/SNAPReduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def category(self):
return "Diffraction\\Reduction"

def PyInit(self):
validator = IntArrayBoundedValidator()
validator.setLower(0)
validator = IntArrayBoundedValidator(lower=0)
self.declareProperty(IntArrayProperty("RunNumbers", values=[0], direction=Direction.Input,
validator=validator),
"Run numbers to process, comma separated")
Expand Down
19 changes: 6 additions & 13 deletions Framework/PythonInterface/plugins/algorithms/SNSPowderReduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,13 @@ def PyInit(self):
self.declareProperty("PushDataPositive", "None",
StringListValidator(["None", "ResetToZero", "AddMinimum"]),
"Add a constant to the data that makes it positive over the whole range.")
arrvalidatorBack = IntArrayBoundedValidator()
arrvalidatorBack.setLower(-1)
self.declareProperty(IntArrayProperty("BackgroundNumber", values=[0], validator=arrvalidatorBack),
arrvalidator = IntArrayBoundedValidator(lower=-1)
self.declareProperty(IntArrayProperty("BackgroundNumber", values=[0], validator=arrvalidator),
doc="If specified overrides value in CharacterizationRunsFile If -1 turns off correction.")
arrvalidatorVan = IntArrayBoundedValidator()
arrvalidatorVan.setLower(-1)
self.declareProperty(IntArrayProperty("VanadiumNumber", values=[0], validator=arrvalidatorVan),
doc="If specified overrides value in CharacterizationRunsFile. If -1 turns off correction."
"")
arrvalidatorVanBack = IntArrayBoundedValidator()
arrvalidatorVanBack.setLower(-1)
self.declareProperty(IntArrayProperty("VanadiumBackgroundNumber", values=[0], validator=arrvalidatorVanBack),
doc="If specified overrides value in CharacterizationRunsFile. If -1 turns off correction."
"")
self.declareProperty(IntArrayProperty("VanadiumNumber", values=[0], validator=arrvalidator),
doc="If specified overrides value in CharacterizationRunsFile. If -1 turns off correction.")
self.declareProperty(IntArrayProperty("VanadiumBackgroundNumber", values=[0], validator=arrvalidator),
doc="If specified overrides value in CharacterizationRunsFile. If -1 turns off correction.")
self.declareProperty(FileProperty(name="CalibrationFile",defaultValue="",action=FileAction.OptionalLoad,
extensions=[".h5", ".hd5", ".hdf", ".cal"])) # CalFileName
self.declareProperty(FileProperty(name="GroupingFile",defaultValue="",action=FileAction.OptionalLoad,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def summary(self):
def PyInit(self):
self.declareProperty(ITableWorkspaceProperty('InputWorkspace', '', Direction.Input),
doc='Input table workspace.')
validator = IntArrayBoundedValidator()
validator.setLower(0)
validator = IntArrayBoundedValidator(lower=0)
self.declareProperty(
IntArrayProperty('ColumnIndices', values=[], direction=Direction.Input, validator=validator),
'Comma separated list of column indices for which statistics will be separated')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def PyInit(self):
validator=StringListValidator(['Debye', 'Einstein']),
doc='Model used to make predictions')

arrvalid = FloatArrayBoundedValidator()
arrvalid.setLower(0.0)
arrvalid = FloatArrayBoundedValidator(lower=0.)

self.declareProperty(FloatArrayProperty(name='Temperature', validator=arrvalid),
doc='Temperature (K)')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def PyInit(self):
validator=WorkspaceUnitValidator("Wavelength")),
doc='Flood weighting measurement')

validator = FloatArrayBoundedValidator()
validator.setLower(0.)
validator = FloatArrayBoundedValidator(lower=0.)
self.declareProperty(FloatArrayProperty('Bands', [], direction=Direction.Input, validator=validator),
doc='Wavelength bands to use. Single pair min to max.')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, FileAction, InstrumentValidator,
ITableWorkspaceProperty, MatrixWorkspaceProperty, MultipleFileProperty, Progress, PropertyMode,
WorkspaceProperty, WorkspaceUnitValidator)
from mantid.kernel import (CompositeValidator, Direct, Direction, FloatBoundedValidator, IntBoundedValidator, IntArrayBoundedValidator,
from mantid.kernel import (CompositeValidator, Direct, Direction, FloatBoundedValidator, IntBoundedValidator,
IntMandatoryValidator, Property, StringListValidator, UnitConversion)
from mantid.simpleapi import (AddSampleLog, CalculateFlatBackground, CloneWorkspace, CorrectTOFAxis, CreateEPP,
CreateSingleValuedWorkspace, CreateWorkspace, CropWorkspace, DeleteWorkspace, Divide, ExtractMonitors,
Expand Down Expand Up @@ -354,8 +354,6 @@ def PyInit(self):
mandatoryPositiveInt.add(IntBoundedValidator(lower=0))
positiveFloat = FloatBoundedValidator(lower=0)
positiveInt = IntBoundedValidator(lower=0)
positiveIntArray = IntArrayBoundedValidator()
positiveIntArray.setLower(0)
inputWorkspaceValidator = CompositeValidator()
inputWorkspaceValidator.add(InstrumentValidator())
inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,7 @@ def PyInit(self):
inputWorkspaceValidator.add(InstrumentValidator())
inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
positiveFloat = FloatBoundedValidator(lower=0)
positiveIntArray = IntArrayBoundedValidator()
positiveIntArray.setLower(0)
positiveIntArray = IntArrayBoundedValidator(lower=0)
scalingFactor = FloatBoundedValidator(lower=0, upper=1)

# Properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def PyInit(self):
validator=StringListValidator(['IRIS', 'OSIRIS']),
doc='Instrument used during run.')

int_arr_valid = IntArrayBoundedValidator()
int_arr_valid.setLower(0)
int_arr_valid = IntArrayBoundedValidator(lower=0)

self.declareProperty(IntArrayProperty(name='SpectraRange', values=[0, 1],
validator=int_arr_valid),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def PyInit(self):
'relative calibration constants; for example, the beam stop [degrees]. ')

pixelRangeValidator = CompositeValidator()
greaterThanOne = IntArrayBoundedValidator()
greaterThanOne.setLower(1)
greaterThanOne = IntArrayBoundedValidator(lower=1)
lengthTwo = IntArrayLengthValidator()
lengthTwo.setLength(2)
orderedPairsValidator = IntArrayOrderedPairsValidator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ def PyInit(self):
"""Initialize the input and output properties of the algorithm."""
nonnegativeInt = IntBoundedValidator(lower=0)
wsIndexRange = IntBoundedValidator(lower=0, upper=255)
nonnegativeIntArray = IntArrayBoundedValidator()
nonnegativeIntArray.setLower(0)
nonnegativeIntArray = IntArrayBoundedValidator(lower=0)
maxTwoNonnegativeInts = CompositeValidator()
maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2))
maxTwoNonnegativeInts.add(nonnegativeIntArray)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ def PyInit(self):
"""Initialize the input and output properties of the algorithm."""
threeNonnegativeInts = CompositeValidator()
threeNonnegativeInts.add(IntArrayLengthValidator(3))
nonnegativeInts = IntArrayBoundedValidator()
nonnegativeInts.setLower(0)
nonnegativeInts = IntArrayBoundedValidator(lower=0)
threeNonnegativeInts.add(nonnegativeInts)
nonnegativeFloatArray = FloatArrayBoundedValidator()
nonnegativeFloatArray.setLower(0.)
nonnegativeFloatArray = FloatArrayBoundedValidator(lower=0.)
inWavelength = WorkspaceUnitValidator('Wavelength')
self.declareProperty(
MatrixWorkspaceProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def PyInit(self):
self.declareProperty("ApplyToDetectors", True, "If True then we apply the correction to the detector pixels")
self.declareProperty("ApplyToMonitors", False, "If True then we apply the correction to the monitors")

arrvalidator = IntArrayBoundedValidator()
arrvalidator.setLower(0)
arrvalidator = IntArrayBoundedValidator(lower=0)
self.declareProperty(IntArrayProperty("SelectedMonitors", values=[],
validator=arrvalidator,
direction=Direction.Input),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def summary(self):
return "Perform USANS data reduction"

def PyInit(self):
arrvalidator = IntArrayBoundedValidator()
arrvalidator.setLower(0)
arrvalidator = IntArrayBoundedValidator(lower=0)
self.declareProperty(IntArrayProperty("RunNumbers", values=[0], validator=arrvalidator,
direction=Direction.Input), "Runs to reduce")
self.declareProperty("EmptyRun", '', "Run number for the empty run")
Expand Down

0 comments on commit 413f265

Please sign in to comment.