import param
class Test1(param.Parameterized):
input_dict = param.Dict(default=None, allow_None=False)
def __init__(self, **kwds):
super().__init__(**kwds)
Is there a way to suppress:
WARNING:param.Test100007: Setting non-parameter attribute something=['something'] using a mechanism intended only for parameters
when doing
Test1(something=['something'])
Marc
October 20, 2020, 4:03am
2
Sure @ahuang11
What triggers the warning is that something
is provided to super().__init__
in the kwds
dict.
You need to avoid that. There are two approaches. 1) Remove something
from kwds
before super
2) never add it to kwds
. The two approaches are shown below.
import param
class Test1(param.Parameterized):
input_dict = param.Dict(default=None, allow_None=False)
def __init__(self, something_else=None, **kwds):
self.something = kwds.pop("something", None)
super().__init__(**kwds)
self.something_else=something_else
Test1()
Test1(something=['something'])
Test1(something_else=['something_else'])
Test1(something=['something'], something_else=['something_else'])
4 Likes
Thanks so much. Method 1 is what I need since I am expecting multiple unknown keywords
1 Like
This is a very helpful answer, i.e. should be the “most upvoted answer.”
I ran into the same error on inheriting a base class from param.Parameterized and then additional classes from that base class.