Skip to content

Commit ead4dc8

Browse files
abidlabscursoragentgradio-pr-bot
authored
Fix redundant double rendering of group checkboxes (#426)
Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
1 parent c650ea4 commit ead4dc8

6 files changed

Lines changed: 21 additions & 35 deletions

File tree

.changeset/floppy-results-think.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trackio": minor
3+
---
4+
5+
feat:Fix redundant double rendering of group checkboxes

tests/unit/test_audio_writer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def test_write_mp3_mono_and_stereo(tmp_path: Path, channels: int) -> None:
7878
"dtype, generator",
7979
[
8080
(np.int32, lambda n: (np.arange(n, dtype=np.int32) % 10000) - 5000),
81-
(np.uint16, lambda n: (np.arange(n, dtype=np.uint16) % 65535)),
82-
(np.uint8, lambda n: (np.arange(n, dtype=np.uint8) % 255)),
81+
(np.uint16, lambda n: np.arange(n, dtype=np.uint16) % 65535),
82+
(np.uint8, lambda n: np.arange(n, dtype=np.uint8) % 255),
8383
(np.int8, lambda n: (np.arange(n, dtype=np.int8) % 127) - 63),
8484
],
8585
)

trackio/media/audio.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,17 @@ def ensure_int16_pcm(data: np.ndarray) -> np.ndarray:
114114

115115
converters: dict[np.dtype, callable] = {
116116
np.dtype(np.int16): lambda a: a,
117-
np.dtype(np.int32): lambda a: (
118-
(a.astype(np.int32) // 65536).astype(np.int16, copy=False)
117+
np.dtype(np.int32): lambda a: (a.astype(np.int32) // 65536).astype(
118+
np.int16, copy=False
119119
),
120-
np.dtype(np.uint16): lambda a: (
121-
(a.astype(np.int32) - 32768).astype(np.int16, copy=False)
120+
np.dtype(np.uint16): lambda a: (a.astype(np.int32) - 32768).astype(
121+
np.int16, copy=False
122122
),
123-
np.dtype(np.uint8): lambda a: (
124-
(a.astype(np.int32) * 257 - 32768).astype(np.int16, copy=False)
123+
np.dtype(np.uint8): lambda a: (a.astype(np.int32) * 257 - 32768).astype(
124+
np.int16, copy=False
125125
),
126-
np.dtype(np.int8): lambda a: (
127-
(a.astype(np.int32) * 256).astype(np.int16, copy=False)
126+
np.dtype(np.int8): lambda a: (a.astype(np.int32) * 256).astype(
127+
np.int16, copy=False
128128
),
129129
}
130130

trackio/table.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ def _has_media_objects(self, dataframe: DataFrame) -> bool:
6161
if (
6262
dataframe[col]
6363
.apply(
64-
lambda x: isinstance(x, list)
65-
and len(x) > 0
66-
and isinstance(x[0], TrackioMedia)
64+
lambda x: (
65+
isinstance(x, list)
66+
and len(x) > 0
67+
and isinstance(x[0], TrackioMedia)
68+
)
6769
)
6870
.any()
6971
):

trackio/ui/fns.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -263,24 +263,6 @@ def handle_run_checkbox_change(
263263
return selection
264264

265265

266-
def group_checkbox_update(
267-
group_runs: list[str], selection: RunSelection
268-
) -> ColoredCheckboxGroup:
269-
color_palette = utils.get_color_palette()
270-
choice_indices = {run: i for i, run in enumerate(selection.choices)}
271-
colors = [
272-
color_palette[choice_indices.get(run, 0) % len(color_palette)]
273-
for run in group_runs
274-
]
275-
subset = utils.ordered_subset(group_runs, selection.selected)
276-
return ColoredCheckboxGroup(
277-
choices=group_runs,
278-
value=subset,
279-
colors=colors,
280-
label=f"Runs ({len(group_runs)})",
281-
)
282-
283-
284266
def handle_group_checkbox_change(
285267
group_selected: list[str] | None,
286268
selection: RunSelection,
@@ -289,7 +271,6 @@ def handle_group_checkbox_change(
289271
selection.replace_group(group_runs or [], group_selected or [])
290272
return (
291273
selection,
292-
group_checkbox_update(group_runs or [], selection),
293274
run_checkbox_update(selection),
294275
)
295276

@@ -303,6 +284,5 @@ def handle_group_toggle(
303284
selection.replace_group(group_runs or [], target)
304285
return (
305286
selection,
306-
group_checkbox_update(group_runs or [], selection),
307287
run_checkbox_update(selection),
308288
)

trackio/ui/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,6 @@ def render_grouped_runs(project, group_key, filter_text, selection):
12721272
],
12731273
outputs=[
12741274
run_selection_state,
1275-
group_cb,
12761275
run_cb,
12771276
],
12781277
show_progress="hidden",
@@ -1288,7 +1287,7 @@ def render_grouped_runs(project, group_key, filter_text, selection):
12881287
run_selection_state,
12891288
gr.State(runs),
12901289
],
1291-
outputs=[run_selection_state, group_cb, run_cb],
1290+
outputs=[run_selection_state, run_cb],
12921291
show_progress="hidden",
12931292
api_visibility="private",
12941293
queue=False,

0 commit comments

Comments
 (0)