Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1340 - removes dependency on removed ipywidgets API #1455

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -330,22 +330,6 @@ def test_widget_client_update(self):
widget.update(data)
assert hasattr(widget, "table") is False

def test_widget_client_update_cached(self):
import perspective
assert perspective.is_libpsp() is False
data = {"a": [1, 2]}
widget = perspective.PerspectiveWidget(data)
mocked_post = partial(mock_post, assert_msg={
"cmd": "update",
"data": data
})
widget.post = MethodType(mocked_post, widget)
widget.update(data)
assert widget._predisplay_update_cache == [data]
widget._displayed = True
widget.update(data)
assert widget._predisplay_update_cache == [data]

def test_widget_client_replace(self):
import perspective
assert perspective.is_libpsp() is False
Expand Down
24 changes: 0 additions & 24 deletions python/perspective/perspective/widget/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ def __init__(
... filter=[["a", ">", 1]],
... expressions=["// new column \n \"Sales\" + \"Profit\""])
"""
self._displayed = False
self.on_displayed(self._on_display)

# Trigger special flow when receiving an ArrayBuffer/binary
self._pending_binary = None

Expand All @@ -282,10 +279,6 @@ def __init__(
# Pass table load options to the front-end, unless in server mode
self._options = {}

if self.client:
# Cache calls to `update()` before the widget has been displayed.
self._predisplay_update_cache = []

if index is not None and limit is not None:
raise PerspectiveError("Index and Limit cannot be set at the same time!")

Expand Down Expand Up @@ -378,10 +371,6 @@ def update(self, data):
method. Otherwise, it calls `Viewer.update()` using `super()`.
"""
if self.client is True:
if self._displayed is False:
self._predisplay_update_cache.append(data)
return

# serialize the data and send a custom message to the browser
if isinstance(data, pandas.DataFrame) or isinstance(data, pandas.Series):
data, _ = deconstruct_pandas(data)
Expand Down Expand Up @@ -491,13 +480,6 @@ def handle_message(self, widget, content, buffers):
# return the dataset or table name to the front-end
msg = self._make_load_message()
self.send(msg.to_dict())

# In client mode, users can call `update()` before the widget
# is visible. This applies the updates after the viewer has
# loaded the initial dataset.
if self.client is True and len(self._predisplay_update_cache) > 0:
for data in self._predisplay_update_cache:
self.update(data)
else:
# If the message has `binary_length` set, wait for the arrow
# and join it with the JSON message.
Expand Down Expand Up @@ -557,9 +539,3 @@ def _make_load_message(self):
raise PerspectiveError(
"Widget does not have any data loaded - use the `load()` method to provide it with data."
)

def _on_display(self, widget, **kwargs):
"""When the widget has been displayed, make sure `displayed` is set to
True so updates stop being cached.
"""
self._displayed = True