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

Inconsistent usage of IntArrayBoundedValidator in Python #9777

Closed
martyngigg opened this issue Feb 7, 2014 · 1 comment · Fixed by #25042
Closed

Inconsistent usage of IntArrayBoundedValidator in Python #9777

martyngigg opened this issue Feb 7, 2014 · 1 comment · Fixed by #25042
Assignees
Labels
Induction Straightforward, low risk issues suitable for new starters

Comments

@martyngigg
Copy link
Member

This issue was originally TRAC 8934

Dear Mantid team,
I just stumbled accross some inconvenience as I wanted to declare an array
property where the individual values are supposed to have a minimum, but
not a maximum value.

For single numbers it is very convenient:

self.declareProperty('SingleNonNegativeInt',  0,
                      direction = Direction.Input,
                      doc = "a non-negative integer",
                      validator=IntBoundedValidator(lower=0.))

But for an array it does not work like this:

theProp = IntArrayProperty(name='PositiveNumbers',
                            validator = IntArrayBoundedValidator(lowerBound=1),
                            direction = Direction.Input)
self.declareProperty(theProp, doc = "Positive integers")

(Nasty anyway that here it is lowerBound whereas for non-arrays it is lower)

This is because 'IntArrayBoundedValidator' does not have default arguments
nor understands 'None'. This is the workaround:

onlyLowerBound = IntArrayBoundedValidator(lowerBound=1, upperBound=1)
onlyLowerBound.clearUpper()
theProp = IntArrayProperty(name='PositiveNumbers',
                            validator = onlyLowerBound,
                            direction = Direction.Input)
self.declareProperty(theProp, doc = "Positive integers")

Would be nice if setting bounds on single values or arrays would behave
similarly (and in an easy way).

@martyngigg
Copy link
Member Author

@NickDraper (2014-02-14T11:07:55):
bulk move to assigned at the into of the triage step

@MatthewBowles MatthewBowles self-assigned this Jul 17, 2017
MatthewBowles added a commit that referenced this issue Jul 18, 2017
MatthewBowles added a commit that referenced this issue Jul 18, 2017
@MatthewBowles MatthewBowles removed their assignment Sep 22, 2017
@soininen soininen self-assigned this Mar 6, 2019
soininen pushed a commit that referenced this issue Mar 6, 2019
Refactor ArrayBoundedValidator to be more in line with BoundedValidator
by adding methods to deal with exclusive bounds.

Re #9777
soininen pushed a commit that referenced this issue Mar 7, 2019
soininen pushed a commit that referenced this issue Mar 8, 2019
Refactor ArrayBoundedValidator to be more in line with BoundedValidator
by adding methods to deal with exclusive bounds.

Re #9777
soininen pushed a commit that referenced this issue Mar 11, 2019
Refactor ArrayBoundedValidator to be more in line with BoundedValidator
by adding methods to deal with exclusive bounds.

Re #9777
soininen pushed a commit that referenced this issue Apr 8, 2019
@DanielMurphy22 DanielMurphy22 added Induction Straightforward, low risk issues suitable for new starters and removed Induction 1 labels Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Induction Straightforward, low risk issues suitable for new starters
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants