|
14 | 14 | * Range / padding calculations |
15 | 15 | * Grouped bars – 2-D height array, group_labels, group_colors |
16 | 16 | * Log scale – log_scale flag, clamping, set_log_scale() |
17 | | - * update() – value replacement and axis recalculation |
| 17 | + * set_data() – value replacement and axis recalculation |
18 | 18 | * Display-setting mutations: set_color, set_colors, set_show_values, set_log_scale |
19 | 19 | * _push() contract – state is propagated to the Figure |
20 | 20 | * Layout JSON reflects "bar" kind for PlotBar panels |
@@ -275,17 +275,17 @@ def test_repr_shows_groups(self): |
275 | 275 | p = ax.bar([0, 1], [[1, 2], [3, 4]]) |
276 | 276 | assert "groups=2" in repr(p) |
277 | 277 |
|
278 | | - def test_update_2d_values(self): |
| 278 | + def test_set_data_2d_values(self): |
279 | 279 | fig, ax = apl.subplots(1, 1) |
280 | 280 | p = ax.bar(["A", "B"], [[1, 2], [3, 4]]) |
281 | | - p.update([[10, 20], [30, 40]]) |
| 281 | + p.set_data([[10, 20], [30, 40]]) |
282 | 282 | assert _state(p)["values"] == pytest.approx(np.array([[10, 20], [30, 40]])) |
283 | 283 |
|
284 | | - def test_update_group_count_mismatch_raises(self): |
| 284 | + def test_set_data_group_count_mismatch_raises(self): |
285 | 285 | fig, ax = apl.subplots(1, 1) |
286 | 286 | p = ax.bar(["A", "B"], [[1, 2], [3, 4]]) # groups=2 |
287 | 287 | with pytest.raises(ValueError, match="Group count mismatch"): |
288 | | - p.update([[1, 2, 3], [4, 5, 6]]) # 3 groups → error |
| 288 | + p.set_data([[1, 2, 3], [4, 5, 6]]) # 3 groups → error |
289 | 289 |
|
290 | 290 |
|
291 | 291 | # ───────────────────────────────────────────────────────────────────────────── |
@@ -341,55 +341,55 @@ def test_set_log_scale_push(self): |
341 | 341 |
|
342 | 342 |
|
343 | 343 | # ───────────────────────────────────────────────────────────────────────────── |
344 | | -# 6. update() — value replacement |
| 344 | +# 6. set_data() — value replacement |
345 | 345 | # ───────────────────────────────────────────────────────────────────────────── |
346 | 346 |
|
347 | | -class TestPlotBarUpdate: |
| 347 | +class TestPlotBarSetData: |
348 | 348 |
|
349 | 349 | def test_update_replaces_values(self): |
350 | 350 | p = _make_bar([1, 2, 3]) |
351 | | - p.update([10, 20, 30]) |
| 351 | + p.set_data([10, 20, 30]) |
352 | 352 | assert _state(p)["values"] == pytest.approx(np.array([[10.0], [20.0], [30.0]])) |
353 | 353 |
|
354 | 354 | def test_update_recalculates_data_max(self): |
355 | 355 | p = _make_bar([1, 2, 3]) |
356 | | - p.update([100, 200, 300]) |
| 356 | + p.set_data([100, 200, 300]) |
357 | 357 | assert _state(p)["data_max"] > 300.0 |
358 | 358 |
|
359 | 359 | def test_update_recalculates_data_min(self): |
360 | 360 | p = _make_bar([1, 2, 3]) |
361 | | - p.update([-50, -20, -10]) |
| 361 | + p.set_data([-50, -20, -10]) |
362 | 362 | assert _state(p)["data_min"] < -50.0 |
363 | 363 |
|
364 | 364 | def test_update_with_new_x_centers(self): |
365 | 365 | p = _make_bar([1, 2, 3]) |
366 | | - p.update([4, 5, 6], x_centers=[0.5, 1.5, 2.5]) |
| 366 | + p.set_data([4, 5, 6], x_centers=[0.5, 1.5, 2.5]) |
367 | 367 | assert _state(p)["x_centers"] == pytest.approx([0.5, 1.5, 2.5]) |
368 | 368 |
|
369 | 369 | def test_update_with_new_x(self): |
370 | 370 | p = _make_bar([1, 2, 3]) |
371 | | - p.update([4, 5, 6], x=[0.5, 1.5, 2.5]) |
| 371 | + p.set_data([4, 5, 6], x=[0.5, 1.5, 2.5]) |
372 | 372 | assert _state(p)["x_centers"] == pytest.approx([0.5, 1.5, 2.5]) |
373 | 373 |
|
374 | 374 | def test_update_with_new_x_labels(self): |
375 | 375 | p = _make_bar([1, 2, 3], x_labels=["a", "b", "c"]) |
376 | | - p.update([4, 5, 6], x_labels=["x", "y", "z"]) |
| 376 | + p.set_data([4, 5, 6], x_labels=["x", "y", "z"]) |
377 | 377 | assert _state(p)["x_labels"] == ["x", "y", "z"] |
378 | 378 |
|
379 | 379 | def test_update_preserves_orient(self): |
380 | 380 | p = _make_bar([1, 2, 3], orient="h") |
381 | | - p.update([4, 5, 6]) |
| 381 | + p.set_data([4, 5, 6]) |
382 | 382 | assert _state(p)["orient"] == "h" |
383 | 383 |
|
384 | 384 | def test_update_preserves_baseline(self): |
385 | 385 | p = _make_bar([1, 2, 3], baseline=2.0) |
386 | | - p.update([10, 20, 30]) |
| 386 | + p.set_data([10, 20, 30]) |
387 | 387 | assert _state(p)["baseline"] == pytest.approx(2.0) |
388 | 388 |
|
389 | | - def test_update_3d_raises(self): |
| 389 | + def test_set_data_3d_raises(self): |
390 | 390 | p = _make_bar([1, 2, 3]) |
391 | 391 | with pytest.raises(ValueError, match="1-D or 2-D"): |
392 | | - p.update(np.zeros((2, 2, 2))) |
| 392 | + p.set_data(np.zeros((2, 2, 2))) |
393 | 393 |
|
394 | 394 |
|
395 | 395 | # ───────────────────────────────────────────────────────────────────────────── |
@@ -441,7 +441,7 @@ def test_panel_json_contains_kind_bar(self): |
441 | 441 | def test_panel_json_values_after_update(self): |
442 | 442 | fig, ax = apl.subplots(1, 1) |
443 | 443 | p = ax.bar([1, 2, 3]) |
444 | | - p.update([7, 8, 9]) |
| 444 | + p.set_data([7, 8, 9]) |
445 | 445 | trait_name = f"panel_{p._id}_json" |
446 | 446 | data = json.loads(getattr(fig, trait_name)) |
447 | 447 | assert data["values"] == pytest.approx(np.array([[7.0], [8.0], [9.0]])) |
|
0 commit comments