You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another issue is that this Parameter class does not respect None values.
If you want to keep this example based on param.Parameter you might update it to:
def_validate_value(self, val, allow_None):
ifallow_NoneandvalisNone:
returnsuper(BinaryPower, self)._validate_value(val, allow_None)
ifnotisinstance(val, numbers.Number):
raiseValueError("BinaryPower parameter %r must be a number, ""not %r."% (self.name, val))
if (notfloat(val).is_integer()) or (val<2) or (bin(int(val)).count("1") isnot1):
# in Python >= 3.10 use `int(val).bit_count() is not 1`raiseValueError("BinaryPower parameter %r must be a power of 2, ""not %r."% (self.name, val))
I would rather suggest to have the example based on param.Integer with default=2... but that does not read so well with the way this section is structured currently ?
The text was updated successfully, but these errors were encountered:
In #634 I address this by keeping the current code and changing the example to one that only allows even integers. The purpose of the docs here is to show that parameters can be defined easily and not to have people think too much about the precise validation logic itself.
The
BinaryPower
class in the Specialized Parameter types subsection of the user guide does not validate binary powers but merely divisibility by 2.https://param.holoviz.org/user_guide/Parameters.html#specialized-parameter-types
Another issue is that this
Parameter
class does not respectNone
values.If you want to keep this example based on
param.Parameter
you might update it to:I would rather suggest to have the example based on
param.Integer
withdefault=2
... but that does not read so well with the way this section is structured currently ?The text was updated successfully, but these errors were encountered: