Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 07634b9

Browse files
committed
Deduplication
1 parent 7f747b7 commit 07634b9

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

bigframes/display/anywidget.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,17 @@ def _cached_data(self) -> pd.DataFrame:
239239
return pd.DataFrame(columns=self._dataframe.columns)
240240
return pd.concat(self._cached_batches, ignore_index=True)
241241

242+
def _reset_batch_cache(self) -> None:
243+
"""Resets batch caching attributes."""
244+
self._cached_batches = []
245+
self._batch_iter = None
246+
self._all_data_loaded = False
247+
242248
def _reset_batches_for_new_page_size(self) -> None:
243249
"""Reset the batch iterator when page size changes."""
244250
self._batches = self._dataframe._to_pandas_batches(page_size=self.page_size)
245251

246-
self._cached_batches = []
247-
self._batch_iter = None
248-
self._all_data_loaded = False
252+
self._reset_batch_cache()
249253

250254
def _set_table_html(self) -> None:
251255
"""Sets the current html data based on the current page and page size."""
@@ -265,9 +269,7 @@ def _set_table_html(self) -> None:
265269
# Reset batches when sorting changes
266270
if self._last_sort_state != _SortState(self.sort_column, self.sort_ascending):
267271
self._batches = df_to_display._to_pandas_batches(page_size=self.page_size)
268-
self._cached_batches = []
269-
self._batch_iter = None
270-
self._all_data_loaded = False
272+
self._reset_batch_cache()
271273
self._last_sort_state = _SortState(self.sort_column, self.sort_ascending)
272274
self.page = 0 # Reset to first page
273275

notebooks/dataframes/anywidget_mode.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
{
158158
"data": {
159159
"application/vnd.jupyter.widget-view+json": {
160-
"model_id": "dbea81204a6045a5a22ed5d368ba9095",
160+
"model_id": "030f0b706a17487288677d33b6921a8e",
161161
"version_major": 2,
162162
"version_minor": 1
163163
},
@@ -255,7 +255,7 @@
255255
{
256256
"data": {
257257
"application/vnd.jupyter.widget-view+json": {
258-
"model_id": "a62fe54c12a14609b5068d8a42e72170",
258+
"model_id": "2fe252168e4249e5a694579e49f04065",
259259
"version_major": 2,
260260
"version_minor": 1
261261
},
@@ -369,7 +369,7 @@
369369
{
370370
"data": {
371371
"application/vnd.jupyter.widget-view+json": {
372-
"model_id": "2edf57f9b10f4ebabb1925f9a0d76df3",
372+
"model_id": "cc4d4dffe00a4f44b7cbcfdea440cc5a",
373373
"version_major": 2,
374374
"version_minor": 1
375375
},
@@ -409,7 +409,7 @@
409409
"data": {
410410
"text/html": [
411411
"✅ Completed. \n",
412-
" Query processed 85.9 kB in 17 seconds of slot time.\n",
412+
" Query processed 85.9 kB in 15 seconds of slot time.\n",
413413
" "
414414
],
415415
"text/plain": [
@@ -456,7 +456,7 @@
456456
{
457457
"data": {
458458
"application/vnd.jupyter.widget-view+json": {
459-
"model_id": "4e66779f3f0e48da9911e72c399ad960",
459+
"model_id": "7f9f40cf56ec4c30a2f1f52d0e825633",
460460
"version_major": 2,
461461
"version_minor": 1
462462
},

0 commit comments

Comments
 (0)