-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: use solara/pytest-ipywidgets to test image and contour
- Loading branch information
1 parent
9587cb8
commit bb9d236
Showing
7 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import ipywidgets as widgets | ||
import playwright.sync_api | ||
from IPython.display import display | ||
import numpy as np | ||
from bqplot import Figure, LinearScale, Axis, ColorScale | ||
from bqplot_image_gl import ImageGL, Contour | ||
|
||
|
||
def test_widget_image(solara_test, page_session: playwright.sync_api.Page, assert_solara_snapshot): | ||
|
||
scale_x = LinearScale(min=0, max=1) | ||
scale_y = LinearScale(min=0, max=1) | ||
scales = {"x": scale_x, "y": scale_y} | ||
axis_x = Axis(scale=scale_x, label="x") | ||
axis_y = Axis(scale=scale_y, label="y", orientation="vertical") | ||
|
||
figure = Figure(scales=scales, axes=[axis_x, axis_y]) | ||
|
||
scales_image = {"x": scale_x, "y": scale_y, "image": ColorScale(min=0, max=2)} | ||
|
||
x = np.linspace(0, 1, 128) | ||
y = np.linspace(0, 1, 256) | ||
X, Y = np.meshgrid(x, y) | ||
data = 5. * np.sin(2 * np.pi * (X + Y**2)) | ||
|
||
image = ImageGL(image=data, scales=scales_image) | ||
contour = Contour(image=image, level=[2, 4], scales=scales_image) | ||
|
||
|
||
figure.marks = (image, contour) | ||
|
||
display(figure) | ||
|
||
|
||
svg = page_session.locator(".bqplot") | ||
svg.wait_for() | ||
# page_session.wait_for_timeout(1000) | ||
assert_solara_snapshot(svg.screenshot()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ipywidgets as widgets | ||
import playwright.sync_api | ||
from IPython.display import display | ||
import numpy as np | ||
from bqplot import Figure, LinearScale, Axis, ColorScale | ||
from bqplot_image_gl import ImageGL | ||
|
||
|
||
def test_widget_image(solara_test, page_session: playwright.sync_api.Page, assert_solara_snapshot): | ||
|
||
scale_x = LinearScale(min=0, max=1) | ||
scale_y = LinearScale(min=0, max=1) | ||
scales = {"x": scale_x, "y": scale_y} | ||
axis_x = Axis(scale=scale_x, label="x") | ||
axis_y = Axis(scale=scale_y, label="y", orientation="vertical") | ||
|
||
figure = Figure(scales=scales, axes=[axis_x, axis_y]) | ||
|
||
scales_image = {"x": scale_x, "y": scale_y, "image": ColorScale(min=0, max=2)} | ||
|
||
data = np.array([[0., 1.], [2., 3.]]) | ||
image = ImageGL(image=data, scales=scales_image) | ||
|
||
figure.marks = (image,) | ||
|
||
display(figure) | ||
|
||
|
||
svg = page_session.locator(".bqplot") | ||
svg.wait_for() | ||
# page_session.wait_for_timeout(1000) | ||
assert_solara_snapshot(svg.screenshot()) |
Binary file added
BIN
+83.6 KB
...pshots/tests/ui/contour_test.py/test_widget_image-chromium-darwin-reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+73.1 KB
...apshots/tests/ui/contour_test.py/test_widget_image-chromium-linux-reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12 KB
...napshots/tests/ui/image_test.py/test_widget_image-chromium-darwin-reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.1 KB
...snapshots/tests/ui/image_test.py/test_widget_image-chromium-linux-reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.