Skip to content

Commit

Permalink
Merge pull request #2175 from plotly/fix-no-update-np
Browse files Browse the repository at this point in the history
Fix callback output of ndarray and no_update check.
  • Loading branch information
T4rk1n authored Aug 2, 2022
2 parents ced1451 + 73c80cf commit 8453bdd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
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() == []

0 comments on commit 8453bdd

Please sign in to comment.