Number's `crop_to_bounds` does not respect exclusive bounds
- Dominant language
- Python
- Stars
- 521
- Forks
- 86
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 35
Description
Create a number with bounds (0,1] and verify that Number respects the bounds:
``` python
>>> import param
>>> class Q(param.Parameterized):
... n = param.Number(default=0.5, bounds=(0,1), inclusive_bounds=(False,True))
...
>>> q = Q()
>>> q.n=0
Traceback (most recent call last):
File "", line 1, in
File "param\__init__.py", line 563, in __set__
if not callable(val): self._check_value(val)
File "param\__init__.py", line 671, in _check_value
self._checkBounds(val)
File "param\__init__.py", line 643, in _checkBounds
raise ValueError("Parameter '%s' must be greater than %s"%(self._attrib_name,vmin))
ValueError: Parameter 'n' must be greater than 0
>>> q.n=1
```
But Number's `crop_to_bounds` (and hence `set_in_bounds`) does not respect exclusive bounds:
``` python
>>> q.params()['n'].crop_to_bounds(0)
0
>>> q.params()['n'].crop_to_bounds(1)
1
```
Contributor guide
Assessment
This issue has not been assessed yet.