Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8ac5fc

Browse filesBrowse files
committed
Actually run ruff
1 parent de242bc commit e8ac5fc
Copy full SHA for e8ac5fc

File tree

Expand file treeCollapse file tree

68 files changed

+382
-335
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

68 files changed

+382
-335
lines changed

‎docs/source/conf.py

Copy file name to clipboardExpand all lines: docs/source/conf.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"sphinx.ext.viewcode",
4545
"sphinx_copybutton",
4646
"sphinx_design",
47-
"sphinx_gallery.gen_gallery"
47+
"sphinx_gallery.gen_gallery",
4848
]
4949

5050
sphinx_gallery_conf = {
@@ -70,9 +70,9 @@
7070
"../../examples/qt",
7171
]
7272
),
73-
"ignore_pattern": r'__init__\.py',
73+
"ignore_pattern": r"__init__\.py",
7474
"nested_sections": False,
75-
"thumbnail_size": (250, 250)
75+
"thumbnail_size": (250, 250),
7676
}
7777

7878
extra_conf = find_examples_for_gallery(EXAMPLES_DIR)
@@ -100,8 +100,8 @@
100100
"check_switcher": True,
101101
"switcher": {
102102
"json_url": "http://www.fastplotlib.org/_static/switcher.json",
103-
"version_match": release
104-
}
103+
"version_match": release,
104+
},
105105
}
106106

107107
html_static_path = ["_static"]

‎docs/source/generate_api.py

Copy file name to clipboardExpand all lines: docs/source/generate_api.py
+2-13Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,10 @@
4242
"fastplotlib\n"
4343
"***********\n\n"
4444
".. currentmodule:: fastplotlib\n\n"
45-
4645
".. autofunction:: fastplotlib.pause_events\n\n"
47-
4846
".. autofunction:: fastplotlib.enumerate_adapters\n\n"
49-
5047
".. autofunction:: fastplotlib.select_adapter\n\n"
51-
5248
".. autofunction:: fastplotlib.print_wgpu_report\n\n"
53-
5449
"fastplotlib.loop\n"
5550
"------------------\n"
5651
"See the rendercanvas docs: https://rendercanvas.readthedocs.io/stable/api.html#rendercanvas.BaseLoop "
@@ -60,7 +55,6 @@
6055
f.write(
6156
"fastplotlib.utils\n"
6257
"*****************\n\n"
63-
6458
"..currentmodule:: fastplotlib.utils\n"
6559
"..automodule:: fastplotlib.utils.functions\n"
6660
" : members:\n"
@@ -161,13 +155,7 @@ def generate_page(
161155
):
162156
page_name_underline = "*" * len(page_name)
163157
with open(source_path, "w") as f:
164-
f.write(
165-
f".. _api.{page_name}:\n"
166-
f"\n"
167-
f"{page_name}\n"
168-
f"{page_name_underline}\n"
169-
f"\n"
170-
)
158+
f.write(f".. _api.{page_name}:\n\n{page_name}\n{page_name_underline}\n\n")
171159

172160
for cls, module in zip(classes, modules):
173161
to_write = generate_class(cls, module)
@@ -362,5 +350,6 @@ def main():
362350
" utils\n"
363351
)
364352

353+
365354
if __name__ == "__main__":
366355
main()

‎examples/gridplot/gridplot_viewports_check.py

Copy file name to clipboardExpand all lines: examples/gridplot/gridplot_viewports_check.py
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212
import numpy as np
1313

1414

15-
figure = fpl.Figure(
16-
shape=(2, 3),
17-
size=(700, 560),
18-
names=list(map(str, range(6)))
19-
)
15+
figure = fpl.Figure(shape=(2, 3), size=(700, 560), names=list(map(str, range(6))))
2016

2117
np.random.seed(0)
2218
a = np.random.rand(6, 10, 10)

‎examples/gridplot/multigraphic_gridplot.py

Copy file name to clipboardExpand all lines: examples/gridplot/multigraphic_gridplot.py
+4-9Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
figure = fpl.Figure(
1818
shape=(2, 2),
1919
names=[["image-overlay", "circles"], ["line-stack", "scatter"]],
20-
size=(700, 560)
20+
size=(700, 560),
2121
)
2222

2323
img = iio.imread("imageio:coffee.png")
@@ -36,6 +36,7 @@
3636
# add overlay to image
3737
figure["image-overlay"].add_image(data=overlay)
3838

39+
3940
# generate some circles
4041
def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray:
4142
theta = np.linspace(0, 2 * np.pi, n_points)
@@ -54,12 +55,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray:
5455
circles.append(make_circle(center, 5, n_points=75))
5556

5657
# things like class labels, cluster labels, etc.
57-
cmap_transform = [
58-
0, 1, 1, 2,
59-
0, 0, 1, 1,
60-
2, 2, 8, 3,
61-
1, 9, 1, 5
62-
]
58+
cmap_transform = [0, 1, 1, 2, 0, 0, 1, 1, 2, 2, 8, 3, 1, 9, 1, 5]
6359

6460
# add an image to overlay the circles on
6561
img2 = iio.imread("imageio:coins.png")[10::5, 5::5]
@@ -73,7 +69,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray:
7369
cmap_transform=cmap_transform,
7470
thickness=3,
7571
alpha=0.5,
76-
name="circles-graphic"
72+
name="circles-graphic",
7773
)
7874

7975
# move the circles graphic so that it is centered over the image
@@ -115,4 +111,3 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray:
115111
if __name__ == "__main__":
116112
print(__doc__)
117113
fpl.loop.run()
118-

‎examples/guis/image_widget_imgui.py

Copy file name to clipboardExpand all lines: examples/guis/image_widget_imgui.py
+12-4Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ def update(self):
4141
something_changed = False
4242

4343
# slider for gaussian filter sigma value
44-
changed, value = imgui.slider_float(label="sigma", v=self.sigma, v_min=0.0, v_max=20.0)
44+
changed, value = imgui.slider_float(
45+
label="sigma", v=self.sigma, v_min=0.0, v_max=20.0
46+
)
4547
if changed:
4648
self.sigma = value
4749
something_changed = True
4850

4951
# int entries for gaussian filter order
5052
for axis in ["x", "y"]:
51-
changed, value = imgui.input_int(f"order {axis}", v=getattr(self, f"order_{axis}"))
53+
changed, value = imgui.input_int(
54+
f"order {axis}", v=getattr(self, f"order_{axis}")
55+
)
5256
if changed:
5357
if value < 0:
5458
value = 0
@@ -63,11 +67,15 @@ def update(self):
6367
# do not call imgui.end_frame(), this is handled by Figure
6468

6569
def process_image(self):
66-
processed = gaussian_filter(a, sigma=self.sigma, order=(self.order_y, self.order_x))
70+
processed = gaussian_filter(
71+
a, sigma=self.sigma, order=(self.order_y, self.order_x)
72+
)
6773
iw.set_data(processed)
6874

6975

70-
gui = ImageProcessingWindow(iw.figure, size=200, location="right", title="Gaussian Filter")
76+
gui = ImageProcessingWindow(
77+
iw.figure, size=200, location="right", title="Gaussian Filter"
78+
)
7179

7280

7381
iw.figure.add_gui(gui)

‎examples/guis/imgui_basic.py

Copy file name to clipboardExpand all lines: examples/guis/imgui_basic.py
+21-7Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@
2929
figure = fpl.Figure(size=(700, 560))
3030

3131
# make some scatter points at every 10th point
32-
figure[0, 0].add_scatter(data[::10], colors="cyan", sizes=15, name="sine-scatter", uniform_color=True)
32+
figure[0, 0].add_scatter(
33+
data[::10], colors="cyan", sizes=15, name="sine-scatter", uniform_color=True
34+
)
3335

3436
# place a line above the scatter
35-
figure[0, 0].add_line(data, thickness=3, colors="r", name="sine-wave", uniform_color=True)
37+
figure[0, 0].add_line(
38+
data, thickness=3, colors="r", name="sine-wave", uniform_color=True
39+
)
3640

3741

3842
class ImguiExample(EdgeWindow):
@@ -60,27 +64,35 @@ def update(self):
6064
# get current line color alpha value
6165
alpha = self._line.colors[-1]
6266
# make float slider
63-
changed_alpha, new_alpha = imgui.slider_float("alpha", v=alpha, v_min=0.0, v_max=1.0)
67+
changed_alpha, new_alpha = imgui.slider_float(
68+
"alpha", v=alpha, v_min=0.0, v_max=1.0
69+
)
6470

6571
# if RGB or alpha changed
6672
if changed_color | changed_alpha:
6773
# set new color along with alpha
6874
self._line.colors = [*rgb, new_alpha]
6975

7076
# example of a slider, you can also use input_float
71-
changed, amplitude = imgui.slider_float("amplitude", v=self._amplitude, v_max=10, v_min=0.1)
77+
changed, amplitude = imgui.slider_float(
78+
"amplitude", v=self._amplitude, v_max=10, v_min=0.1
79+
)
7280
if changed:
7381
# set y values
7482
self._amplitude = amplitude
7583
self._set_data()
7684

7785
# slider for thickness
78-
changed, thickness = imgui.slider_float("thickness", v=self._line.thickness, v_max=50.0, v_min=2.0)
86+
changed, thickness = imgui.slider_float(
87+
"thickness", v=self._line.thickness, v_max=50.0, v_min=2.0
88+
)
7989
if changed:
8090
self._line.thickness = thickness
8191

8292
# slider for gaussian noise
83-
changed, sigma = imgui.slider_float("noise-sigma", v=self._sigma, v_max=1.0, v_min=0.0)
93+
changed, sigma = imgui.slider_float(
94+
"noise-sigma", v=self._sigma, v_max=1.0, v_min=0.0
95+
)
8496
if changed:
8597
self._sigma = sigma
8698
self._set_data()
@@ -99,7 +111,9 @@ def update(self):
99111
self._set_data()
100112

101113
def _set_data(self):
102-
self._line.data[:, 1] = (np.sin(xs) * self._amplitude) + np.random.normal(scale=self._sigma, size=100)
114+
self._line.data[:, 1] = (np.sin(xs) * self._amplitude) + np.random.normal(
115+
scale=self._sigma, size=100
116+
)
103117

104118

105119
# make GUI instance

‎examples/image/image_small.py

Copy file name to clipboardExpand all lines: examples/image/image_small.py
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414

1515
figure = fpl.Figure(size=(700, 560))
1616

17-
data = np.array(
18-
[[0, 1, 2],
19-
[3, 4, 5]]
20-
)
17+
data = np.array([[0, 1, 2], [3, 4, 5]])
2118
image_graphic = figure[0, 0].add_image(data)
2219

2320
figure.show()

‎examples/image_widget/image_widget_grid.py

Copy file name to clipboardExpand all lines: examples/image_widget/image_widget_grid.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
iw = fpl.ImageWidget(
2020
data=[img1, img2, img3, img4],
21-
rgb=[False, True, True, True], # mix of grayscale and RGB images
21+
rgb=[False, True, True, True], # mix of grayscale and RGB images
2222
names=["cameraman", "astronaut", "chelsea", "Almar's cat"],
2323
# ImageWidget will sync controllers by default
2424
# by setting `controller_ids=None` we can have independent controllers for each subplot

‎examples/image_widget/image_widget_videos.py

Copy file name to clipboardExpand all lines: examples/image_widget/image_widget_videos.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
[random_data, cockatoo_sub],
3030
rgb=[False, True],
3131
figure_shape=(2, 1), # 2 rows, 1 column
32-
figure_kwargs={"size": (700, 940)}
32+
figure_kwargs={"size": (700, 940)},
3333
)
3434

3535
iw.show()

‎examples/line/line_cmap.py

Copy file name to clipboardExpand all lines: examples/line/line_cmap.py
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,13 @@
2424

2525
# cmap_transform from an array, so the colors on the sine line will be based on the sine y-values
2626
sine_graphic = figure[0, 0].add_line(
27-
data=sine,
28-
thickness=10,
29-
cmap="plasma",
30-
cmap_transform=sine[:, 1]
27+
data=sine, thickness=10, cmap="plasma", cmap_transform=sine[:, 1]
3128
)
3229

3330
# qualitative colormaps, useful for cluster labels or other types of categorical labels
3431
labels = [0] * 25 + [5] * 10 + [1] * 35 + [2] * 30
3532
cosine_graphic = figure[0, 0].add_line(
36-
data=cosine,
37-
thickness=10,
38-
cmap="tab10",
39-
cmap_transform=labels
33+
data=cosine, thickness=10, cmap="tab10", cmap_transform=labels
4034
)
4135

4236
figure.show()

‎examples/line/line_cmap_more.py

Copy file name to clipboardExpand all lines: examples/line/line_cmap_more.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,22 @@
3131
# set colormap by mapping data using a transform
3232
# here we map the color using the y-values of the sine data
3333
# i.e., the color is a function of sine(x)
34-
line2 = figure[0, 0].add_line(sine, thickness=10, cmap="jet", cmap_transform=sine[:, 1], offset=(0, 4, 0))
34+
line2 = figure[0, 0].add_line(
35+
sine, thickness=10, cmap="jet", cmap_transform=sine[:, 1], offset=(0, 4, 0)
36+
)
3537

3638
# make a line and change the cmap afterward, here we are using the cosine instead fot the transform
37-
line3 = figure[0, 0].add_line(sine, thickness=10, cmap="jet", cmap_transform=cosine[:, 1], offset=(0, 6, 0))
39+
line3 = figure[0, 0].add_line(
40+
sine, thickness=10, cmap="jet", cmap_transform=cosine[:, 1], offset=(0, 6, 0)
41+
)
3842
# change the cmap
3943
line3.cmap = "bwr"
4044

4145
# use quantitative colormaps with categorical cmap_transforms
4246
labels = [0] * 25 + [1] * 5 + [2] * 50 + [3] * 20
43-
line4 = figure[0, 0].add_line(sine, thickness=10, cmap="tab10", cmap_transform=labels, offset=(0, 8, 0))
47+
line4 = figure[0, 0].add_line(
48+
sine, thickness=10, cmap="tab10", cmap_transform=labels, offset=(0, 8, 0)
49+
)
4450

4551
# some text labels
4652
for i in range(5):

‎examples/line/line_colorslice.py

Copy file name to clipboardExpand all lines: examples/line/line_colorslice.py
+9-15Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,30 @@
2727
ys = np.sinc(xs) * 3
2828
sinc = np.column_stack([xs, ys])
2929

30-
sine_graphic = figure[0, 0].add_line(
31-
data=sine,
32-
thickness=5,
33-
colors="magenta"
34-
)
30+
sine_graphic = figure[0, 0].add_line(data=sine, thickness=5, colors="magenta")
3531

3632
# you can also use colormaps for lines!
3733
cosine_graphic = figure[0, 0].add_line(
3834
data=cosine,
3935
thickness=12,
4036
cmap="autumn",
41-
offset=(0, 3, 0) # places the graphic at a y-axis offset of 3, offsets don't affect data
37+
offset=(
38+
0,
39+
3,
40+
0,
41+
), # places the graphic at a y-axis offset of 3, offsets don't affect data
4242
)
4343

4444
# or a list of colors for each datapoint
4545
colors = ["r"] * 25 + ["purple"] * 25 + ["y"] * 25 + ["b"] * 25
4646
sinc_graphic = figure[0, 0].add_line(
47-
data=sinc,
48-
thickness=5,
49-
colors=colors,
50-
offset=(0, 6, 0)
47+
data=sinc, thickness=5, colors=colors, offset=(0, 6, 0)
5148
)
5249

5350
zeros = np.zeros(xs.size)
5451
zeros_data = np.column_stack([xs, zeros])
5552
zeros_graphic = figure[0, 0].add_line(
56-
data=zeros_data,
57-
thickness=8,
58-
colors="w",
59-
offset=(0, 10, 0)
53+
data=zeros_data, thickness=8, colors="w", offset=(0, 10, 0)
6054
)
6155

6256
figure.show()
@@ -67,7 +61,7 @@
6761
cosine_graphic.colors[60] = "w"
6862

6963
# more complex indexing, set the blue value directly from an array
70-
cosine_graphic.colors[65:90, 0] = np.linspace(0, 1, 90-65)
64+
cosine_graphic.colors[65:90, 0] = np.linspace(0, 1, 90 - 65)
7165

7266
# additional fancy indexing using numpy
7367
key = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 67, 19])

‎examples/line_collection/line_collection_cmap_values.py

Copy file name to clipboardExpand all lines: examples/line_collection/line_collection_cmap_values.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import numpy as np
1313
import fastplotlib as fpl
1414

15+
1516
def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray:
1617
theta = np.linspace(0, 2 * np.pi, n_points)
1718
xs = radius * np.sin(theta)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.