Skip to content

[BUG] NoUpdate.is_no_update can't handle ndarray #2173

@maor1993

Description

@maor1993

Describe your context
currently running project using dash for data display, callbacks pass ndarrays of certain sections of data to view

dash 2.6.0 dash-bootstrap-components 1.2.0 dash-core-components 2.0.0 dash-daq 0.5.0 dash-extensions 0.1.5 dash-html-components 2.0.0 dash-table 5.0.0 

Describe the bug
if callback passes an ndarray, NoUpdate.is_no_update on line 441 of _callback.py raises a ValueError, this issue was not seen in previous versions.

[2022-07-31 16:27:03,570] ERROR in app: Exception on /_dash-update-component [POST] Traceback (most recent call last): File "...\venv\lib\site-packages\flask\app.py", line 2077, in wsgi_app response = self.full_dispatch_request() File "...\venv\lib\site-packages\flask\app.py", line 1525, in full_dispatch_request rv = self.handle_user_exception(e) File "...\venv\lib\site-packages\flask\app.py", line 1523, in full_dispatch_request rv = self.dispatch_request() File "...\venv\lib\site-packages\flask\app.py", line 1509, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "...\venv\lib\site-packages\dash\dash.py", line 1260, in dispatch ctx.run( File "...\venv\lib\site-packages\dash\_callback.py", line 441, in add_context if NoUpdate.is_no_update(output_value): ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() 

Workaround for this is wrapping ndarray with list, like this:

return [myndArr] 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions