Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSkovMadsen committed Nov 23, 2024
1 parent 27a11e5 commit 0092617
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
44 changes: 26 additions & 18 deletions param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -1326,10 +1326,6 @@ def rx(self):
Provides reactive versions of operations that cannot be made reactive through operator overloading, such as
`.rx.and_` and `.rx.bool`. Calling this namespace (`()`) returns a reactive expression.
Parameters
----------
None
Returns
-------
Reactive expression
Expand Down Expand Up @@ -2374,7 +2370,7 @@ def params(self_, parameter_name=None):

def update(self_, arg=Undefined, /, **kwargs):
"""
Update one or more parameters of this object or class.
Update multiple parameters of this object or class before triggering events.
Allows setting the parameters of the object or class using a dictionary, an iterable, or keyword arguments
in the form of `param=value`. The specified parameters will be updated to the given values.
Expand All @@ -2392,27 +2388,39 @@ def update(self_, arg=Undefined, /, **kwargs):
Examples
--------
Create a Parameterized instance:
Create a Parameterized class:
>>> import param
>>> class P(param.Parameterized):
... a = param.Number()
... b = param.String()
>>> p = P()
... a = param.String()
... b = param.String()
Define the instance:
>>> p = P(a="0. Hello", b="0. World")
Update parameters permanently:
Usea `.update` to update the parameters:
>>> p.param.update(a=1, b="Hello")
>>> print(p.a, p.b)
1 Hello
>>> p.param.update(a="1. Hello", b="2. World")
p.a, p.b
Update parameters temporarily:
Update the parameters temporarily:
>>> with p.param.update(a=2, b="World"):
>>> with p.param.update(a="2. Hello", b="2. World"):
... p.a, p.b
2. Hello, 2. World
>>> p.a, p.b
1. Hello, 1. World
Lets see that events are **after** all parameters have been updated
>>> @param.depends(p.param.a, watch=True)
... def print_a_b(a):
... print(p.a, p.b)
2 World
>>> print(p.a, p.b)
1 Hello
>>> my_param.param.update(a="3. Hello",b="3. World")
3. Hello 3. World
"""

refs = {}
Expand Down
4 changes: 0 additions & 4 deletions param/reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,6 @@ def rx(self) -> reactive_ops:
Provides reactive versions of operations that cannot be made reactive through operator overloading, such as
`.rx.and_` and `.rx.bool`. Calling this namespace (`()`) returns a reactive expression.
Parameters
----------
None
Returns
-------
Reactive expression
Expand Down

0 comments on commit 0092617

Please sign in to comment.