Skip to content

Commit

Permalink
Ensure rx._callback resolves accessors (#949)
Browse files Browse the repository at this point in the history
Co-authored-by: maximlt <mliquet@anaconda.com>
  • Loading branch information
philippjfr and maximlt authored Jun 24, 2024
1 parent c0fa26e commit 853c42b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions param/reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def bool(self):

def buffer(self, n):
"""
Collects the last n items that were emmitted.
Collects the last n items that were emitted.
"""
items = []
def collect(new, n):
Expand Down Expand Up @@ -954,7 +954,10 @@ def _transform_output(self, obj):
def _callback(self):
params = self._params
def evaluate(*args, **kwargs):
return self._transform_output(self._current)
out = self._current
if self._method:
out = getattr(out, self._method)
return self._transform_output(out)
if params:
return bind(evaluate, *params)
return evaluate
Expand Down
6 changes: 6 additions & 0 deletions tests/testreactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,3 +761,9 @@ def transform(obj):
t.lst = list("ABCDE")
t.items[1].value = "TEST"
assert t.lst[1] == "TEST"

def test_reactive_callback_resolve_accessor():
df = pd.DataFrame({"name": ["Bill", "Bob"]})
dfx = rx(df)
out = dfx["name"].str._callback()
assert out is df["name"].str

0 comments on commit 853c42b

Please sign in to comment.