Skip to content

Commit cf489db

Browse files
committed
Test every behaviour the review named
A 1-D navigator drag lands on its time frame and a span gathers the run between its edges; a figure's own marker group survives a dispatch; a mismatched ragged index and a short reduce mask both throw; a views button re-reads the frame from its block; a reduce binding with no detector is refused at mount while a crosshair on that panel is ignored at dispatch; a circle detector gives the navigator numpy's einsum; a geom push leaves a live binary token alone but yields to one of its own; two figures in one document keep their own pixels; the frame window stays the panel's; and a resize does not reach the panel before the bytes it describes. The region mean is compared with a tolerance of one code, since a float32 sum scaled by 1/n and numpy's float64 mean can truncate either side of a boundary, and the rasterDisks reference states the convention (a filled disk per row, combined by max or sum) rather than transcribing the loop.
1 parent 92a8a4c commit cf489db

3 files changed

Lines changed: 492 additions & 23 deletions

File tree

anyplotlib/tests/test_embed/test_embed_api.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,43 @@ def test_state_dict_is_accepted_in_place_of_a_figure(self):
227227
{"cube": np.zeros((4, 4, 8, 8), dtype=np.uint8)},
228228
self._bindings(navigator, signal))
229229
assert f"panel_{signal._id}_json" in html
230+
231+
232+
class TestEmbedSurface:
233+
def test_the_readers_live_under_one_namespace(self):
234+
"""Generic names stay out of the top level beside mount / render."""
235+
source = esm_path().read_text(encoding="utf-8")
236+
assert "export const embed = {" in source
237+
assert "export async function mountNavigated" in source
238+
for name in ("dense", "ragged", "toU8", "decodeBlocks",
239+
"maskFromWidget", "rasterDisks", "robustLevels"):
240+
assert f"export function {name}(" not in source, (
241+
f"{name} is still a top-level export")
242+
assert f"export async function {name}(" not in source
243+
244+
def test_views_blocks_are_validated(self):
245+
fig, axes = apl.subplots(1, 2, figsize=(400, 200))
246+
navigator = axes[0].imshow(np.zeros((4, 4), dtype=np.uint8))
247+
panel = axes[1].imshow(np.zeros((8, 8), dtype=np.uint8))
248+
cube = np.zeros((4, 4, 8, 8), dtype=np.uint8)
249+
bindings = [
250+
{"panel_id": navigator._id, "role": "navigator"},
251+
{"panel_id": panel._id, "role": "driven",
252+
"views": [{"label": "a", "block": "cube"},
253+
{"label": "b", "block": "gone"}]},
254+
]
255+
with pytest.raises(ValueError, match="unknown block 'gone'"):
256+
navigated_html(fig, {"cube": cube}, bindings)
257+
258+
def test_a_views_binding_needs_no_frame_block(self):
259+
fig, axes = apl.subplots(1, 2, figsize=(400, 200))
260+
navigator = axes[0].imshow(np.zeros((4, 4), dtype=np.uint8))
261+
panel = axes[1].imshow(np.zeros((8, 8), dtype=np.uint8))
262+
cube = np.zeros((4, 4, 8, 8), dtype=np.uint8)
263+
html = navigated_html(
264+
fig, {"cube": cube},
265+
[{"panel_id": navigator._id, "role": "navigator"},
266+
{"panel_id": panel._id, "role": "driven",
267+
"views": [{"label": "a", "block": "cube"}],
268+
"frame": {"kind": "image"}}])
269+
assert f'id="apl-views-{panel._id}"' in html

0 commit comments

Comments
 (0)