param: Overriding parameter value with None in subclass ignored
This behavior just bit me. Anyone have a clue why this would be happening?
Test case:
import param
class A(param.Parameterized):
a = param.Number(default=10)
def __init__(self, **params):
super(A, self).__init__(**params)
print self.a
class B(A):
a = param.Number(default=None)
def __init__(self, **params):
super(B, self).__init__(**params)
print self.a
a=A()
b=B()
Output:
10
10
10
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 24 (24 by maintainers)
What you wrote makes sense though as you point out, it gets complicated if you want to enforce (or at least warn!) that the allowable parameter values for every child class should be a subset of what is allowed for the superclass.
Agreed though once again #455 doesn’t seem that unreasonable or uncommon a thing to do (generalizing a base class in a compatible way). I’m fine with this suggestion being low priority in general but not for specific clashes like #455 where the resulting behavior appears buggy.
Generally, handling both typing and parameter settings to spot violations of the “is-a” property seems like a non-trivial task to do properly (and is orthogonal from simply distinguishing
NonefromNotSetanyway).Ok, I’ve fixed it. When you pull to test my fix, you should check out the new version of ParamOverrides too. I also cleaned up param’s source code, finally! Oh and I’ve put in initial versions of Dimension and Notion into param too. Let me know what you think.