holoviz / holoviz/param

Number's `crop_to_bounds` does not respect exclusive bounds

Open
#80 2 comments 0 reactions 0 assignees View on GitHub
component: type/value stuff type-bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.