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

Fix callback output of ndarray and no_update check. #2175

Merged
merged 5 commits into from
Aug 2, 2022
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).

## [UNRELEASED]

### Fixed

- [#2175](https://github.com/plotly/dash/pull/2175) Fix [#2173](https://github.com/plotly/dash/issues/2173) callback output of ndarray and no_update check.
- [#2146](https://github.com/plotly/dash/pull/2146) Remove leftover debug console.log statement.
- [#2168](https://github.com/plotly/dash/pull/2168) Reverts [#2126](https://github.com/plotly/dash/pull/2126) (supporting redirect from root when using pages) until the new bugs introduced by that PR are fixed.

Expand Down
6 changes: 3 additions & 3 deletions dash/_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def to_plotly_json(self): # pylint: disable=no-self-use

@staticmethod
def is_no_update(obj):
return isinstance(obj, NoUpdate) or obj == {
"_dash_no_update": "_dash_no_update"
}
return isinstance(obj, NoUpdate) or (
isinstance(obj, dict) and obj == {"_dash_no_update": "_dash_no_update"}
)


GLOBAL_CALLBACK_LIST = []
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/callbacks/test_basic_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
import time

import numpy as np
import werkzeug

from dash_test_components import (
Expand Down Expand Up @@ -765,3 +766,19 @@ def update_output(value):
return f"returning {value}"

assert update_output("my-value") == "returning my-value"


def test_cbsc018_callback_ndarray_output(dash_duo):
app = Dash(__name__)
app.layout = html.Div([dcc.Store(id="output"), html.Button("click", id="clicker")])

@app.callback(
Output("output", "data"),
Input("clicker", "n_clicks"),
)
def on_click(_):
return np.array([[1, 2, 3], [4, 5, 6]], np.int32)

dash_duo.start_server(app)

assert dash_duo.get_logs() == []