Skip to content

Commit 3f5cf9d

Browse files
authored
Fix off by one error (#530)
* ndarray.ptp -> np.ptp for numpy v2 * fix off by one error in Image feature, add test * fix off by one error in Image feature, add test * add example test for small image to prevent off by one errors * update screenshots * update texture array test * update multi graphic gallery example, do not use for tests
1 parent bb0bb27 commit 3f5cf9d

File tree

87 files changed

+190
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+190
-182
lines changed

examples/desktop/gridplot/multigraphic_gridplot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Example showing a Figure with multiple subplots and multiple graphic types.
66
"""
77

8-
# test_example = true
8+
# test_example = false
99
# sphinx_gallery_pygfx_docs = 'screenshot'
1010

1111
import fastplotlib as fpl
@@ -58,9 +58,9 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray:
5858
]
5959

6060
# add an image to overlay the circles on
61-
img2 = np.ones((60, 60))
61+
img2 = iio.imread("imageio:coins.png")[10::5, 5::5]
6262

63-
figure["circles"].add_image(data=img2)
63+
figure["circles"].add_image(data=img2, cmap="gray")
6464

6565
# add the circles to the figure
6666
figure["circles"].add_line_collection(
@@ -101,8 +101,8 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray:
101101
gaussian_cloud2 = np.random.multivariate_normal(mean, covariance, n_points)
102102

103103
# add the scatter graphics to the figure
104-
figure["scatter"].add_scatter(data=gaussian_cloud, sizes=1, cmap="jet")
105-
figure["scatter"].add_scatter(data=gaussian_cloud2, colors="r", sizes=1)
104+
figure["scatter"].add_scatter(data=gaussian_cloud, sizes=2, cmap="jet")
105+
figure["scatter"].add_scatter(data=gaussian_cloud2, colors="r", sizes=2)
106106

107107
figure.show()
108108

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Small Image
3+
===========
4+
5+
Test image to verify dims
6+
"""
7+
8+
import numpy as np
9+
10+
# test_example = true
11+
# sphinx_gallery_pygfx_docs = 'hidden'
12+
13+
import fastplotlib as fpl
14+
15+
figure = fpl.Figure()
16+
17+
data = np.array(
18+
[[0, 1, 2],
19+
[3, 4, 5]]
20+
)
21+
image_graphic = figure[0, 0].add_image(data)
22+
23+
figure.show()
24+
25+
figure.canvas.set_logical_size(700, 560)
26+
27+
figure[0, 0].auto_scale()
28+
29+
# NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively
30+
# please see our docs for using fastplotlib interactively in ipython and jupyter
31+
if __name__ == "__main__":
32+
print(__doc__)
33+
fpl.run()
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions

examples/desktop/screenshots/heatmap_cmap.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/desktop/screenshots/heatmap_data.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/desktop/screenshots/heatmap_vmin_vmax.png

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)