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 835f0c5

Browse filesBrowse files
authored
ruff format everything (#421)
* ruff format everything * dont use formatting on GraphicMethodsMixin since it is autogenerated
1 parent 30cf1fc commit 835f0c5
Copy full SHA for 835f0c5
Expand file treeCollapse file tree

29 files changed

+275
-205
lines changed

‎fastplotlib/__init__.py

Copy file name to clipboardExpand all lines: fastplotlib/__init__.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
adapters = [a.request_adapter_info() for a in enumerate_adapters()]
2020

2121
if len(adapters) < 1:
22-
raise IndexError(
23-
"No WGPU adapters found, fastplotlib will not work."
24-
)
22+
raise IndexError("No WGPU adapters found, fastplotlib will not work.")
2523

2624
with open(Path(__file__).parent.joinpath("VERSION"), "r") as f:
2725
__version__ = f.read().split("\n")[0]

‎fastplotlib/graphics/_base.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/_base.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def link(
315315
feature=feature,
316316
new_data=new_data,
317317
callback=callback,
318-
bidirectional=False # else infinite recursion, otherwise target will call
318+
bidirectional=False, # else infinite recursion, otherwise target will call
319319
# this instance .link(), and then it will happen again etc.
320320
)
321321

‎fastplotlib/graphics/_features/__init__.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/_features/__init__.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
from ._sizes import PointsSizesFeature
44
from ._present import PresentFeature
55
from ._thickness import ThicknessFeature
6-
from ._base import GraphicFeature, GraphicFeatureIndexable, FeatureEvent, to_gpu_supported_dtype
6+
from ._base import (
7+
GraphicFeature,
8+
GraphicFeatureIndexable,
9+
FeatureEvent,
10+
to_gpu_supported_dtype,
11+
)
712
from ._selection_features import LinearSelectionFeature, LinearRegionSelectionFeature
813
from ._deleted import Deleted
914

‎fastplotlib/graphics/_features/_colors.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/_features/_colors.py
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import numpy as np
22
import pygfx
33

4-
from ...utils import make_colors, get_cmap_texture, make_pygfx_colors, parse_cmap_values, quick_min_max
4+
from ...utils import (
5+
make_colors,
6+
get_cmap_texture,
7+
make_pygfx_colors,
8+
parse_cmap_values,
9+
quick_min_max,
10+
)
511
from ._base import (
612
GraphicFeature,
713
GraphicFeatureIndexable,
@@ -426,4 +432,4 @@ def vmax(self) -> float:
426432
@vmax.setter
427433
def vmax(self, value: float):
428434
"""Maximum contrast limit."""
429-
self._parent._material.clim = (self._parent._material.clim[0], value)
435+
self._parent._material.clim = (self._parent._material.clim[0], value)

‎fastplotlib/graphics/_features/_sizes.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/_features/_sizes.py
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ def __getitem__(self, item):
3434

3535
def _fix_sizes(self, sizes, parent):
3636
graphic_type = parent.__class__.__name__
37-
37+
3838
n_datapoints = parent.data().shape[0]
3939
if not isinstance(sizes, (list, tuple, np.ndarray)):
40-
sizes = np.full(n_datapoints, sizes, dtype=np.float32) # force it into a float to avoid weird gpu errors
41-
elif not isinstance(sizes, np.ndarray): # if it's not a ndarray already, make it one
42-
sizes = np.array(sizes, dtype=np.float32) # read it in as a numpy.float32
40+
sizes = np.full(
41+
n_datapoints, sizes, dtype=np.float32
42+
) # force it into a float to avoid weird gpu errors
43+
elif not isinstance(
44+
sizes, np.ndarray
45+
): # if it's not a ndarray already, make it one
46+
sizes = np.array(sizes, dtype=np.float32) # read it in as a numpy.float32
4347
if (sizes.ndim != 1) or (sizes.size != parent.data().shape[0]):
4448
raise ValueError(
4549
f"sequence of `sizes` must be 1 dimensional with "
@@ -49,7 +53,9 @@ def _fix_sizes(self, sizes, parent):
4953
sizes = to_gpu_supported_dtype(sizes)
5054

5155
if any(s < 0 for s in sizes):
52-
raise ValueError("All sizes must be positive numbers greater than or equal to 0.0.")
56+
raise ValueError(
57+
"All sizes must be positive numbers greater than or equal to 0.0."
58+
)
5359

5460
if sizes.ndim == 1:
5561
if graphic_type == "ScatterGraphic":

‎fastplotlib/graphics/image.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/image.py
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,7 @@ def col_chunk_index(self, index: int):
345345

346346

347347
class HeatmapGraphic(Graphic, Interaction, _AddSelectorsMixin):
348-
feature_events = {
349-
"data",
350-
"cmap",
351-
"present"
352-
}
348+
feature_events = {"data", "cmap", "present"}
353349

354350
def __init__(
355351
self,

‎fastplotlib/graphics/scatter.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/scatter.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ def __init__(
9090
super(ScatterGraphic, self).__init__(*args, **kwargs)
9191

9292
world_object = pygfx.Points(
93-
pygfx.Geometry(positions=self.data(), sizes=self.sizes(), colors=self.colors()),
93+
pygfx.Geometry(
94+
positions=self.data(), sizes=self.sizes(), colors=self.colors()
95+
),
9496
material=pygfx.PointsMaterial(color_mode="vertex", vertex_sizes=True),
9597
)
9698

‎fastplotlib/graphics/selectors/_base_selector.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_base_selector.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444
hover_responsive: Tuple[WorldObject, ...] = None,
4545
arrow_keys_modifier: str = None,
4646
axis: str = None,
47-
name: str = None
47+
name: str = None,
4848
):
4949
if edges is None:
5050
edges = tuple()

‎fastplotlib/graphics/selectors/_linear.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_linear.py
+9-10Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ def limits(self, values: Tuple[float, float]):
2828
# check that `values` is an iterable of two real numbers
2929
# using `Real` here allows it to work with builtin `int` and `float` types, and numpy scaler types
3030
if len(values) != 2 or not all(map(lambda v: isinstance(v, Real), values)):
31-
raise TypeError(
32-
"limits must be an iterable of two numeric values"
33-
)
34-
self._limits = tuple(map(round, values)) # if values are close to zero things get weird so round them
31+
raise TypeError("limits must be an iterable of two numeric values")
32+
self._limits = tuple(
33+
map(round, values)
34+
) # if values are close to zero things get weird so round them
3535
self.selection._limits = self._limits
3636

3737
# TODO: make `selection` arg in graphics data space not world space
@@ -267,11 +267,7 @@ def make_ipywidget_slider(self, kind: str = "IntSlider", **kwargs):
267267

268268
return slider
269269

270-
def add_ipywidget_handler(
271-
self,
272-
widget,
273-
step: Union[int, float] = None
274-
):
270+
def add_ipywidget_handler(self, widget, step: Union[int, float] = None):
275271
"""
276272
Bidirectionally connect events with a ipywidget slider
277273
@@ -285,7 +281,10 @@ def add_ipywidget_handler(
285281
286282
"""
287283

288-
if not isinstance(widget, (ipywidgets.IntSlider, ipywidgets.FloatSlider, ipywidgets.FloatLogSlider)):
284+
if not isinstance(
285+
widget,
286+
(ipywidgets.IntSlider, ipywidgets.FloatSlider, ipywidgets.FloatLogSlider),
287+
):
289288
raise TypeError(
290289
f"`widget` must be one of: ipywidgets.IntSlider, ipywidgets.FloatSlider, or ipywidgets.FloatLogSlider\n"
291290
f"You have passed a: <{type(widget)}"

‎fastplotlib/graphics/selectors/_linear_region.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_linear_region.py
+9-11Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ def limits(self, values: Tuple[float, float]):
2727
# check that `values` is an iterable of two real numbers
2828
# using `Real` here allows it to work with builtin `int` and `float` types, and numpy scaler types
2929
if len(values) != 2 or not all(map(lambda v: isinstance(v, Real), values)):
30-
raise TypeError(
31-
"limits must be an iterable of two numeric values"
32-
)
33-
self._limits = tuple(map(round, values)) # if values are close to zero things get weird so round them
30+
raise TypeError("limits must be an iterable of two numeric values")
31+
self._limits = tuple(
32+
map(round, values)
33+
) # if values are close to zero things get weird so round them
3434
self.selection._limits = self._limits
3535

3636
def __init__(
@@ -243,7 +243,7 @@ def __init__(
243243
hover_responsive=self.edges,
244244
arrow_keys_modifier=arrow_keys_modifier,
245245
axis=axis,
246-
name=name
246+
name=name,
247247
)
248248

249249
def get_selected_data(
@@ -417,11 +417,7 @@ def make_ipywidget_slider(self, kind: str = "IntRangeSlider", **kwargs):
417417

418418
return slider
419419

420-
def add_ipywidget_handler(
421-
self,
422-
widget,
423-
step: Union[int, float] = None
424-
):
420+
def add_ipywidget_handler(self, widget, step: Union[int, float] = None):
425421
"""
426422
Bidirectionally connect events with a ipywidget slider
427423
@@ -434,7 +430,9 @@ def add_ipywidget_handler(
434430
step size, if ``None`` 100 steps are created
435431
436432
"""
437-
if not isinstance(widget, (ipywidgets.IntRangeSlider, ipywidgets.FloatRangeSlider)):
433+
if not isinstance(
434+
widget, (ipywidgets.IntRangeSlider, ipywidgets.FloatRangeSlider)
435+
):
438436
raise TypeError(
439437
f"`widget` must be one of: ipywidgets.IntRangeSlider or ipywidgets.FloatRangeSlider\n"
440438
f"You have passed a: <{type(widget)}"
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
import numpy as np
2-

‎fastplotlib/graphics/selectors/_polygon.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_polygon.py
+16-10Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def __init__(
1616
parent: Graphic = None,
1717
name: str = None,
1818
):
19-
2019
self.parent = parent
2120

2221
group = pygfx.Group()
@@ -47,7 +46,9 @@ def _add_plot_area_hook(self, plot_area):
4746
self._plot_area.renderer.add_event_handler(self._add_segment, "click")
4847

4948
# pointer move to change endpoint of segment
50-
self._plot_area.renderer.add_event_handler(self._move_segment_endpoint, "pointer_move")
49+
self._plot_area.renderer.add_event_handler(
50+
self._move_segment_endpoint, "pointer_move"
51+
)
5152

5253
# click to finish existing segment
5354
self._plot_area.renderer.add_event_handler(self._finish_segment, "click")
@@ -69,7 +70,9 @@ def _add_segment(self, ev):
6970

7071
new_line = pygfx.Line(
7172
geometry=pygfx.Geometry(positions=data.astype(np.float32)),
72-
material=pygfx.LineMaterial(thickness=self.edge_width, color=pygfx.Color(self.edge_color))
73+
material=pygfx.LineMaterial(
74+
thickness=self.edge_width, color=pygfx.Color(self.edge_color)
75+
),
7376
)
7477

7578
self.world_object.add(new_line)
@@ -86,7 +89,9 @@ def _move_segment_endpoint(self, ev):
8689
return
8790

8891
# change endpoint
89-
self.world_object.children[-1].geometry.positions.data[1] = np.array([world_pos]).astype(np.float32)
92+
self.world_object.children[-1].geometry.positions.data[1] = np.array(
93+
[world_pos]
94+
).astype(np.float32)
9095
self.world_object.children[-1].geometry.positions.update_range()
9196

9297
def _finish_segment(self, ev):
@@ -114,14 +119,15 @@ def _finish_polygon(self, ev):
114119
return
115120

116121
# make new line to connect first and last vertices
117-
data = np.vstack([
118-
world_pos,
119-
self.world_object.children[0].geometry.positions.data[0]
120-
])
122+
data = np.vstack(
123+
[world_pos, self.world_object.children[0].geometry.positions.data[0]]
124+
)
121125

122126
new_line = pygfx.Line(
123127
geometry=pygfx.Geometry(positions=data.astype(np.float32)),
124-
material=pygfx.LineMaterial(thickness=self.edge_width, color=pygfx.Color(self.edge_color))
128+
material=pygfx.LineMaterial(
129+
thickness=self.edge_width, color=pygfx.Color(self.edge_color)
130+
),
125131
)
126132

127133
self.world_object.add(new_line)
@@ -130,7 +136,7 @@ def _finish_polygon(self, ev):
130136
self._add_segment: "click",
131137
self._move_segment_endpoint: "pointer_move",
132138
self._finish_segment: "click",
133-
self._finish_polygon: "double_click"
139+
self._finish_polygon: "double_click",
134140
}
135141

136142
for handler, event in handlers.items():

‎fastplotlib/graphics/selectors/_sync.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_sync.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44

55
class Synchronizer:
6-
def __init__(self, *selectors: LinearSelector, key_bind: Union[str, None] = "Shift"):
6+
def __init__(
7+
self, *selectors: LinearSelector, key_bind: Union[str, None] = "Shift"
8+
):
79
"""
810
Synchronize the movement of `Selectors`. Selectors will move in sync only when the selected `"key_bind"` is
911
used during the mouse movement event. Valid key binds are: ``"Control"``, ``"Shift"`` and ``"Alt"``.

‎fastplotlib/graphics/text.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/text.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(
1717
screen_space: bool = True,
1818
anchor: str = "middle-center",
1919
*args,
20-
**kwargs
20+
**kwargs,
2121
):
2222
"""
2323
Create a text Graphic
@@ -144,4 +144,3 @@ def outline_color(self, color: Union[str, np.ndarray]):
144144
raise ValueError("Outline color must be of type str or np.ndarray")
145145

146146
self.world_object.material.outline_color = color
147-

‎fastplotlib/layouts/_defaults.py

Copy file name to clipboard
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11

2-
3-

‎fastplotlib/layouts/_frame/_frame.py

Copy file name to clipboardExpand all lines: fastplotlib/layouts/_frame/_frame.py
+11-13Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ def __call__(self, *args, **kwargs):
2727
JupyterOutputContext = UnavailableOutputContext(
2828
"Jupyter",
2929
"You must install fastplotlib using the `'notebook'` option to use this context:\n"
30-
'pip install "fastplotlib[notebook]"'
30+
'pip install "fastplotlib[notebook]"',
3131
)
3232

3333
if CANVAS_OPTIONS_AVAILABLE["qt"]:
3434
from ._qt_output import QOutputContext
3535
else:
3636
QtOutput = UnavailableOutputContext(
37-
"Qt",
38-
"You must install `PyQt6` to use this output context"
37+
"Qt", "You must install `PyQt6` to use this output context"
3938
)
4039

4140

@@ -45,6 +44,7 @@ class Frame:
4544
4645
Gives them their `show()` call that returns the appropriate output context.
4746
"""
47+
4848
def __init__(self):
4949
self._output = None
5050

@@ -83,13 +83,13 @@ def start_render(self):
8383
self.canvas.set_logical_size(*self._starting_size)
8484

8585
def show(
86-
self,
87-
autoscale: bool = True,
88-
maintain_aspect: bool = None,
89-
toolbar: bool = True,
90-
sidecar: bool = False,
91-
sidecar_kwargs: dict = None,
92-
add_widgets: list = None,
86+
self,
87+
autoscale: bool = True,
88+
maintain_aspect: bool = None,
89+
toolbar: bool = True,
90+
sidecar: bool = False,
91+
sidecar_kwargs: dict = None,
92+
add_widgets: list = None,
9393
):
9494
"""
9595
Begins the rendering event loop and shows the plot in the desired output context (jupyter, qt or glfw).
@@ -168,9 +168,7 @@ def show(
168168

169169
elif self.canvas.__class__.__name__ == "QWgpuCanvas":
170170
self._output = QOutputContext(
171-
frame=self,
172-
make_toolbar=toolbar,
173-
add_widgets=add_widgets
171+
frame=self, make_toolbar=toolbar, add_widgets=add_widgets
174172
)
175173

176174
else: # assume GLFW, the output context is just the canvas

0 commit comments

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