Skip to content

Use simpler form of super() where possible #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fastplotlib/graphics/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class GraphicCollection(Graphic):
"""Graphic Collection base class"""

def __init__(self, name: str = None):
super(GraphicCollection, self).__init__(name)
super().__init__(name)
self._graphics: List[str] = list()

self._graphics_changed: bool = True
Expand Down
11 changes: 5 additions & 6 deletions fastplotlib/graphics/_features/_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ def __init__(
if alpha != 1.0:
data[:, -1] = alpha

super(ColorFeature, self).__init__(
parent, data, collection_index=collection_index
)
super().__init__(parent, data, collection_index=collection_index)

def __setitem__(self, key, value):
# parse numerical slice indices
Expand Down Expand Up @@ -253,6 +251,7 @@ class CmapFeature(ColorFeature):
"""

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

self._cmap_name = cmap_name
Expand All @@ -278,7 +277,7 @@ def __setitem__(self, key, cmap_name):
)

self._cmap_name = cmap_name
super(CmapFeature, self).__setitem__(key, colors)
super().__setitem__(key, colors)

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

self._cmap_values = values

super(CmapFeature, self).__setitem__(slice(None), colors)
super().__setitem__(slice(None), colors)

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

def __init__(self, parent, cmap: str):
cmap_texture_view = get_cmap_texture(cmap)
super(ImageCmapFeature, self).__init__(parent, cmap_texture_view)
super().__init__(parent, cmap_texture_view)
self._name = cmap

def _set(self, cmap_name: str):
Expand Down
6 changes: 2 additions & 4 deletions fastplotlib/graphics/_features/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class PointsDataFeature(GraphicFeatureIndexable):

def __init__(self, parent, data: Any, collection_index: int = None):
data = self._fix_data(data, parent)
super(PointsDataFeature, self).__init__(
parent, data, collection_index=collection_index
)
super().__init__(parent, data, collection_index=collection_index)

@property
def buffer(self) -> pygfx.Buffer:
Expand Down Expand Up @@ -117,7 +115,7 @@ def __init__(self, parent, data: Any):
"``[x_dim, y_dim]`` or ``[x_dim, y_dim, rgb]``"
)

super(ImageDataFeature, self).__init__(parent, data)
super().__init__(parent, data)

@property
def buffer(self) -> pygfx.Texture:
Expand Down
2 changes: 1 addition & 1 deletion fastplotlib/graphics/_features/_deleted.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Deleted(GraphicFeature):
"""

def __init__(self, parent, value: bool):
super(Deleted, self).__init__(parent, value)
super().__init__(parent, value)

def _set(self, value: bool):
value = self._parse_set_value(value)
Expand Down
2 changes: 1 addition & 1 deletion fastplotlib/graphics/_features/_present.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PresentFeature(GraphicFeature):

def __init__(self, parent, present: bool = True, collection_index: int = False):
self._scene = None
super(PresentFeature, self).__init__(parent, present, collection_index)
super().__init__(parent, present, collection_index)

def _set(self, present: bool):
present = self._parse_set_value(present)
Expand Down
4 changes: 2 additions & 2 deletions fastplotlib/graphics/_features/_selection_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LinearSelectionFeature(GraphicFeature):
"""

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

self._axis = axis
self._limits = limits
Expand Down Expand Up @@ -99,7 +99,7 @@ class LinearRegionSelectionFeature(GraphicFeature):
def __init__(
self, parent, selection: Tuple[int, int], axis: str, limits: Tuple[int, int]
):
super(LinearRegionSelectionFeature, self).__init__(parent, data=selection)
super().__init__(parent, data=selection)

self._axis = axis
self._limits = limits
Expand Down
4 changes: 1 addition & 3 deletions fastplotlib/graphics/_features/_sizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class PointsSizesFeature(GraphicFeatureIndexable):

def __init__(self, parent, sizes: Any, collection_index: int = None):
sizes = self._fix_sizes(sizes, parent)
super(PointsSizesFeature, self).__init__(
parent, sizes, collection_index=collection_index
)
super().__init__(parent, sizes, collection_index=collection_index)

@property
def buffer(self) -> pygfx.Buffer:
Expand Down
2 changes: 1 addition & 1 deletion fastplotlib/graphics/_features/_thickness.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ThicknessFeature(GraphicFeature):

def __init__(self, parent, thickness: float):
self._scene = None
super(ThicknessFeature, self).__init__(parent, thickness)
super().__init__(parent, thickness)

def _set(self, value: float):
value = self._parse_set_value(value)
Expand Down
6 changes: 2 additions & 4 deletions fastplotlib/graphics/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class _HistogramBin(pygfx.Mesh):
def __int__(self, *args, **kwargs):
super(_HistogramBin, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.bin_center: float = None
self.frequency: Union[int, float] = None

Expand Down Expand Up @@ -93,9 +93,7 @@ def __init__(

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

super(HistogramGraphic, self).__init__(
data=data, colors=colors, n_colors=n_bins, **kwargs
)
super().__init__(data=data, colors=colors, n_colors=n_bins, **kwargs)

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

Expand Down
2 changes: 1 addition & 1 deletion fastplotlib/graphics/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
self, self.colors(), cmap_name=cmap, cmap_values=cmap_values
)

super(LineGraphic, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

if thickness < 1.1:
material = pygfx.LineThinMaterial
Expand Down
4 changes: 2 additions & 2 deletions fastplotlib/graphics/line_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(

"""

super(LineCollection, self).__init__(name)
super().__init__(name)

if not isinstance(z_position, float) and z_position is not None:
if len(data) != len(z_position):
Expand Down Expand Up @@ -544,7 +544,7 @@ def __init__(
See :class:`LineGraphic` details on the features.

"""
super(LineStack, self).__init__(
super().__init__(
data=data,
z_position=z_position,
thickness=thickness,
Expand Down
2 changes: 1 addition & 1 deletion fastplotlib/graphics/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(
)

self.sizes = PointsSizesFeature(self, sizes)
super(ScatterGraphic, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

world_object = pygfx.Points(
pygfx.Geometry(
Expand Down
2 changes: 1 addition & 1 deletion fastplotlib/graphics/selectors/_rectangle_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RectangleBoundsFeature(GraphicFeature):
def __init__(
self, parent, bounds: Tuple[int, int], axis: str, limits: Tuple[int, int]
):
super(RectangleBoundsFeature, self).__init__(parent, data=bounds)
super().__init__(parent, data=bounds)

self._axis = axis
self.limits = limits
Expand Down
2 changes: 1 addition & 1 deletion fastplotlib/graphics/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(
* Vertical values: "top", "middle", "baseline", "bottom"
* Horizontal values: "left", "center", "right"
"""
super(TextGraphic, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self._text = text

Expand Down
4 changes: 2 additions & 2 deletions fastplotlib/layouts/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
passed to Subplot, for example ``name``

"""
super(Plot, self).__init__(
super().__init__(
parent=None,
position=(0, 0),
parent_dims=(1, 1),
Expand All @@ -62,7 +62,7 @@ def __init__(

def render(self):
"""performs a single render of the plot, not for the user"""
super(Plot, self).render()
super().render()

self.renderer.flush()
self.canvas.request_draw()
4 changes: 2 additions & 2 deletions fastplotlib/layouts/_subplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def __init__(

self._size = size

super(Dock, self).__init__(
super().__init__(
parent=parent,
position=position,
camera=pygfx.OrthographicCamera(),
Expand Down Expand Up @@ -349,4 +349,4 @@ def render(self):
if self.size == 0:
return

super(Dock, self).render()
super().render()
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy