Skip to content

Commit 0021652

Browse files
authored
Use simpler form of super() where possible (#453)
1 parent 99e8a0b commit 0021652

File tree

16 files changed

+26
-33
lines changed

16 files changed

+26
-33
lines changed

fastplotlib/graphics/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ class GraphicCollection(Graphic):
439439
"""Graphic Collection base class"""
440440

441441
def __init__(self, name: str = None):
442-
super(GraphicCollection, self).__init__(name)
442+
super().__init__(name)
443443
self._graphics: List[str] = list()
444444

445445
self._graphics_changed: bool = True

fastplotlib/graphics/_features/_colors.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ def __init__(
124124
if alpha != 1.0:
125125
data[:, -1] = alpha
126126

127-
super(ColorFeature, self).__init__(
128-
parent, data, collection_index=collection_index
129-
)
127+
super().__init__(parent, data, collection_index=collection_index)
130128

131129
def __setitem__(self, key, value):
132130
# parse numerical slice indices
@@ -253,6 +251,7 @@ class CmapFeature(ColorFeature):
253251
"""
254252

255253
def __init__(self, parent, colors, cmap_name: str, cmap_values: np.ndarray):
254+
# Skip the ColorFeature's __init__
256255
super(ColorFeature, self).__init__(parent, colors)
257256

258257
self._cmap_name = cmap_name
@@ -278,7 +277,7 @@ def __setitem__(self, key, cmap_name):
278277
)
279278

280279
self._cmap_name = cmap_name
281-
super(CmapFeature, self).__setitem__(key, colors)
280+
super().__setitem__(key, colors)
282281

283282
@property
284283
def name(self) -> str:
@@ -299,7 +298,7 @@ def values(self, values: np.ndarray):
299298

300299
self._cmap_values = values
301300

302-
super(CmapFeature, self).__setitem__(slice(None), colors)
301+
super().__setitem__(slice(None), colors)
303302

304303
def __repr__(self) -> str:
305304
s = f"CmapFeature for {self._parent}, to get name or values: `<graphic>.cmap.name`, `<graphic>.cmap.values`"
@@ -330,7 +329,7 @@ class ImageCmapFeature(GraphicFeature):
330329

331330
def __init__(self, parent, cmap: str):
332331
cmap_texture_view = get_cmap_texture(cmap)
333-
super(ImageCmapFeature, self).__init__(parent, cmap_texture_view)
332+
super().__init__(parent, cmap_texture_view)
334333
self._name = cmap
335334

336335
def _set(self, cmap_name: str):

fastplotlib/graphics/_features/_data.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ class PointsDataFeature(GraphicFeatureIndexable):
2121

2222
def __init__(self, parent, data: Any, collection_index: int = None):
2323
data = self._fix_data(data, parent)
24-
super(PointsDataFeature, self).__init__(
25-
parent, data, collection_index=collection_index
26-
)
24+
super().__init__(parent, data, collection_index=collection_index)
2725

2826
@property
2927
def buffer(self) -> pygfx.Buffer:
@@ -117,7 +115,7 @@ def __init__(self, parent, data: Any):
117115
"``[x_dim, y_dim]`` or ``[x_dim, y_dim, rgb]``"
118116
)
119117

120-
super(ImageDataFeature, self).__init__(parent, data)
118+
super().__init__(parent, data)
121119

122120
@property
123121
def buffer(self) -> pygfx.Texture:

fastplotlib/graphics/_features/_deleted.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Deleted(GraphicFeature):
1616
"""
1717

1818
def __init__(self, parent, value: bool):
19-
super(Deleted, self).__init__(parent, value)
19+
super().__init__(parent, value)
2020

2121
def _set(self, value: bool):
2222
value = self._parse_set_value(value)

fastplotlib/graphics/_features/_present.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PresentFeature(GraphicFeature):
2323

2424
def __init__(self, parent, present: bool = True, collection_index: int = False):
2525
self._scene = None
26-
super(PresentFeature, self).__init__(parent, present, collection_index)
26+
super().__init__(parent, present, collection_index)
2727

2828
def _set(self, present: bool):
2929
present = self._parse_set_value(present)

fastplotlib/graphics/_features/_selection_features.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class LinearSelectionFeature(GraphicFeature):
2727
"""
2828

2929
def __init__(self, parent, axis: str, value: float, limits: Tuple[int, int]):
30-
super(LinearSelectionFeature, self).__init__(parent, data=value)
30+
super().__init__(parent, data=value)
3131

3232
self._axis = axis
3333
self._limits = limits
@@ -99,7 +99,7 @@ class LinearRegionSelectionFeature(GraphicFeature):
9999
def __init__(
100100
self, parent, selection: Tuple[int, int], axis: str, limits: Tuple[int, int]
101101
):
102-
super(LinearRegionSelectionFeature, self).__init__(parent, data=selection)
102+
super().__init__(parent, data=selection)
103103

104104
self._axis = axis
105105
self._limits = limits

fastplotlib/graphics/_features/_sizes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ class PointsSizesFeature(GraphicFeatureIndexable):
2121

2222
def __init__(self, parent, sizes: Any, collection_index: int = None):
2323
sizes = self._fix_sizes(sizes, parent)
24-
super(PointsSizesFeature, self).__init__(
25-
parent, sizes, collection_index=collection_index
26-
)
24+
super().__init__(parent, sizes, collection_index=collection_index)
2725

2826
@property
2927
def buffer(self) -> pygfx.Buffer:

fastplotlib/graphics/_features/_thickness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ThicknessFeature(GraphicFeature):
1919

2020
def __init__(self, parent, thickness: float):
2121
self._scene = None
22-
super(ThicknessFeature, self).__init__(parent, thickness)
22+
super().__init__(parent, thickness)
2323

2424
def _set(self, value: float):
2525
value = self._parse_set_value(value)

fastplotlib/graphics/histogram.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class _HistogramBin(pygfx.Mesh):
1212
def __int__(self, *args, **kwargs):
13-
super(_HistogramBin, self).__init__(*args, **kwargs)
13+
super().__init__(*args, **kwargs)
1414
self.bin_center: float = None
1515
self.frequency: Union[int, float] = None
1616

@@ -93,9 +93,7 @@ def __init__(
9393

9494
data = np.vstack([x_positions_bins, self.hist])
9595

96-
super(HistogramGraphic, self).__init__(
97-
data=data, colors=colors, n_colors=n_bins, **kwargs
98-
)
96+
super().__init__(data=data, colors=colors, n_colors=n_bins, **kwargs)
9997

10098
self._world_object: pygfx.Group = pygfx.Group()
10199

fastplotlib/graphics/line.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
self, self.colors(), cmap_name=cmap, cmap_values=cmap_values
103103
)
104104

105-
super(LineGraphic, self).__init__(*args, **kwargs)
105+
super().__init__(*args, **kwargs)
106106

107107
if thickness < 1.1:
108108
material = pygfx.LineThinMaterial

0 commit comments

Comments
 (0)