holoviz / holoviz/param

parameters good, parameterized bad / "gradual" param

Open
#435 2 comments 0 reactions 0 assignees View on GitHub
TRIAGE type-feature
Dominant language
Python
Stars
521
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
35

Description

Param looks like an interesting library, but unfortunately I can never use it because by the time I ever get to a codebase, it's too late! People already wrote their classes and stuff, and it's not possible to make them inherit from parameterized.

I've proposed variants of "gradual parameterization" in the past. One day I'll try to write a decent overall proposal here in this issue. However, looking at param's code today I saw a comment:

https://github.com/holoviz/param/blob/b785c42e8745644ad74aa0ace758925f311443e1/param/parameterized.py#L2190-L2191

Usually my reminder comments fade into obscurity 30 mins after being written, but that one is actually useful. Following it (see the associated PR) , I can immediately get:

```python
import param

class A:
a0 = param.Number(default=0,doc="a0 doc")
```

```
>>> a = A()
>>> a.a0 = "number"
Traceback (most recent call last):
File "", line 1, in
File "/home/sefkw/proj/param-gradual/param/param/parameterized.py", line 303, in _f
return f(self, obj, val)
File "/home/sefkw/proj/param-gradual/param/param/__init__.py", line 623, in __set__
super(Dynamic,self).__set__(obj,val)
File "/home/sefkw/proj/param-gradual/param/param/parameterized.py", line 303, in _f
return f(self, obj, val)
File "/home/sefkw/proj/param-gradual/param/param/parameterized.py", line 873, in __set__
self._validate(val)
File "/home/sefkw/proj/param-gradual/param/param/__init__.py", line 882, in _validate
raise ValueError("Parameter '%s' only takes numeric values"%(self.name))
ValueError: Parameter 'a0' only takes numeric values
```

Of course, Parameterized and ParameterizedMeta class do a bunch of other stuff. However, I feel like it should be possible to factor some useful things out of those and thus also make at least certain functionality available another way. E.g. via a decorator people can use on their class. Or a number of decorators, each of which adds some particular functionality, if it makes sense on its own.

(Despite the title, I'm not suggesting to remove Parameterized - having Parameterized classes/class hierarchy is fundamentally useful.)

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.