You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of expected behavior and the observed behavior
On a dataframe with non-standard index (ordered integer starting at zero), patch index should be applied but fails with ValueError: Invalid patch index
I believe the bug is here, where as_index is used to interpret the row index in patch_value as actual value or position when updating the underlying dataframe, but then patch_value is passed to the underlying _patch without modifcation. The downstream code appears to require positional information, not named index.
File /opt/miniconda3/envs/ais/lib/python3.9/site-packages/panel/widgets/tables.py:815, in BaseTable.patch(self, patch_value, as_index)
813 else:
814 self.value.iloc[ind, columns.index(k)] = value
--> 815 self._patch(patch_value)
816 else:
817 raise ValueError(
818 f"Patching with a patch_value of type {type(patch_value).name} "
819 "is not supported. Please provide a DataFrame, Series or Dict."
820 )
File /opt/miniconda3/envs/ais/lib/python3.9/site-packages/panel/reactive.py:1035, in SyncableData._patch(self, patch)
1033 if comm or not doc.session_context or state._unblocked(doc):
1034 with unlocked():
-> 1035 m.source.patch(patch)
1036 if comm and 'embedded' not in root.tags:
1037 push(doc, comm)
Possibly this is related to the following code section; although Tabulator has a filters param, it also has a _filters attribute which is the one that appears to be used throughout the code. Thus even when you have done add_filter this section is skipped.
Tabulator version info
1.0.4
Description of expected behavior and the observed behavior
On a dataframe with non-standard index (ordered integer starting at zero), patch index should be applied but fails with
ValueError: Invalid patch index
I believe the bug is here, where
as_index
is used to interpret the row index inpatch_value
as actual value or position when updating the underlying dataframe, but thenpatch_value
is passed to the underlying_patch
without modifcation. The downstream code appears to require positional information, not named index.panel/panel/widgets/tables.py
Lines 807 to 815 in e4f4c5d
Complete, minimal, self-contained example code that reproduces the issue
In a jupyter notebook:
First cell:
Second cell (works):
Third cell (fails with error below):
Stack traceback and/or browser JavaScript console output
ValueError Traceback (most recent call last)
Cell In[73], line 1
----> 1 widget.patch({'x':[('a', 10)]})
File /opt/miniconda3/envs/ais/lib/python3.9/site-packages/panel/widgets/tables.py:815, in BaseTable.patch(self, patch_value, as_index)
813 else:
814 self.value.iloc[ind, columns.index(k)] = value
--> 815 self._patch(patch_value)
816 else:
817 raise ValueError(
818 f"Patching with a patch_value of type {type(patch_value).name} "
819 "is not supported. Please provide a DataFrame, Series or Dict."
820 )
File /opt/miniconda3/envs/ais/lib/python3.9/site-packages/panel/util/init.py:372, in updating..wrapped(self, *args, **kwargs)
370 self._updating = True
371 try:
--> 372 fn(self, *args, **kwargs)
373 finally:
374 self._updating = updating
File /opt/miniconda3/envs/ais/lib/python3.9/site-packages/panel/widgets/tables.py:1443, in Tabulator._patch(self, patch)
1441 if not patch:
1442 return
-> 1443 super()._patch(patch)
1444 self._update_style()
1445 self._update_selectable()
File /opt/miniconda3/envs/ais/lib/python3.9/site-packages/panel/util/init.py:372, in updating..wrapped(self, *args, **kwargs)
370 self._updating = True
371 try:
--> 372 fn(self, *args, **kwargs)
373 finally:
374 self._updating = updating
File /opt/miniconda3/envs/ais/lib/python3.9/site-packages/panel/reactive.py:1035, in SyncableData._patch(self, patch)
1033 if comm or not doc.session_context or state._unblocked(doc):
1034 with unlocked():
-> 1035 m.source.patch(patch)
1036 if comm and 'embedded' not in root.tags:
1037 push(doc, comm)
File /opt/miniconda3/envs/ais/lib/python3.9/site-packages/bokeh/models/sources.py:723, in ColumnDataSource.patch(self, patches, setter)
720 _check_slice(subind)
722 else:
--> 723 raise ValueError("Invalid patch index: %s" % ind)
725 self.data._patch(self.document, self, patches, setter)
ValueError: Invalid patch index: a
Screenshots or screencasts of the bug in action
The text was updated successfully, but these errors were encountered: