Skip to content

Commit

Permalink
Replaced super(Klass, self) by super()
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Sep 27, 2023
1 parent 059b021 commit 98bfa88
Show file tree
Hide file tree
Showing 50 changed files with 142 additions and 152 deletions.
20 changes: 9 additions & 11 deletions plotpy/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class KeyEventMatch(EventMatch):
"""

def __init__(self, keys):
super(KeyEventMatch, self).__init__()
super().__init__()
key_list, mod_list = [], []
for item in keys:
if isinstance(item, (tuple, list)):
Expand Down Expand Up @@ -120,7 +120,7 @@ class StandardKeyMatch(EventMatch):
"""

def __init__(self, keysequence):
super(StandardKeyMatch, self).__init__()
super().__init__()
assert isinstance(keysequence, int)
self.keyseq = keysequence

Expand All @@ -139,7 +139,7 @@ class MouseEventMatch(EventMatch):
"""Base class for matching mouse events"""

def __init__(self, evt_type, btn, modifiers=QC.Qt.NoModifier):
super(MouseEventMatch, self).__init__()
super().__init__()
assert isinstance(modifiers, (int, QC.Qt.KeyboardModifiers))
self.evt_type = evt_type
self.button = btn
Expand Down Expand Up @@ -190,7 +190,7 @@ class StatefulEventFilter(QC.QObject):
"""

def __init__(self, parent):
super(StatefulEventFilter, self).__init__()
super().__init__()
self.states = {0: {}} # 0 : cursor 1: panning, 2: zooming
self.cursors = {}
self.state = 0
Expand Down Expand Up @@ -309,7 +309,7 @@ class DragHandler(QC.QObject):
cursor = None

def __init__(self, filter, btn, mods=QC.Qt.NoModifier, start_state=0):
super(DragHandler, self).__init__()
super().__init__()
self.state0 = filter.add_event(
start_state, filter.mouse_press(btn, mods), self.start_tracking
)
Expand Down Expand Up @@ -407,7 +407,7 @@ class ClickHandler(QC.QObject):
SIG_CLICK_EVENT = QC.Signal(object, "QEvent")

def __init__(self, filter, btn, mods=QC.Qt.NoModifier, start_state=0):
super(ClickHandler, self).__init__()
super().__init__()
self.state0 = filter.add_event(
start_state, filter.mouse_press(btn, mods), filter.nothing
)
Expand Down Expand Up @@ -579,7 +579,7 @@ class UndoMovePoint(UndoMoveObject):
""" """

def __init__(self, obj, pos1, pos2, handle, ctrl):
super(UndoMovePoint, self).__init__(obj, pos1, pos2)
super().__init__(obj, pos1, pos2)
self.handle = handle
self.ctrl = ctrl

Expand All @@ -596,7 +596,7 @@ def redo(self):

class UndoRotatePoint(UndoMoveObject):
def __init__(self, obj, pos1, pos2):
super(UndoRotatePoint, self).__init__(obj, pos1, pos2)
super().__init__(obj, pos1, pos2)

def undo(self):
pos1, pos2 = self.compute_positions()
Expand Down Expand Up @@ -860,9 +860,7 @@ class RectangularSelectionHandler(DragHandler):
SIG_END_RECT = QC.Signal(object, "QPointF", "QPointF")

def __init__(self, filter, btn, mods=QC.Qt.NoModifier, start_state=0):
super(RectangularSelectionHandler, self).__init__(
filter, btn, mods, start_state
)
super().__init__(filter, btn, mods, start_state)
self.avoid_null_shape = False

def set_shape(self, shape, h0, h1, setup_shape_cb=None, avoid_null_shape=False):
Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/curve/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CurveItem(QwtPlotCurve):
_private = False

def __init__(self, curveparam=None):
super(CurveItem, self).__init__()
super().__init__()
if curveparam is None:
self.param = CurveParam(_("Curve"), icon="curve.png")
else:
Expand Down
4 changes: 2 additions & 2 deletions plotpy/items/curve/errorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, curveparam=None, errorbarparam=None):
self.errorBrush: QG.QBrush | None = None
self.errorCap: int | None = None
self.errorOnTop: bool | None = None
super(ErrorBarCurveItem, self).__init__(curveparam)
super().__init__(curveparam)
self._dx = None
self._dy = None
self._minmaxarrays = {}
Expand All @@ -72,7 +72,7 @@ def serialize(
Args:
writer: HDF5, INI or JSON writer
"""
super(ErrorBarCurveItem, self).serialize(writer)
super().serialize(writer)
writer.write(self._dx, group_name="dXdata")
writer.write(self._dy, group_name="dYdata")
self.errorbarparam.update_param(self)
Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GridItem(QwtPlotGrid):
_private = False

def __init__(self, gridparam=None):
super(GridItem, self).__init__()
super().__init__()
if gridparam is None:
self.gridparam = GridParam(title=_("Grid"), icon="grid.png")
else:
Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/image/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class BaseImageItem(QwtPlotItem):
_private = False

def __init__(self, data=None, param=None):
super(BaseImageItem, self).__init__()
super().__init__()

self.bg_qcolor = QG.QColor()

Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/image/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, image, filter, param):
self.use_source_cmap = None
self.image = None # BaseImageItem constructor will try to set this
# item's color map using the method 'set_color_map'
super(ImageFilterItem, self).__init__(param=param)
super().__init__(param=param)
self.border_rect.set_style("plot", "shape/imagefilter")
self.image = image
self.filter = filter
Expand Down
14 changes: 7 additions & 7 deletions plotpy/items/image/image_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, data=None, param=None):
self.xmax = None
self.ymin = None
self.ymax = None
super(ImageItem, self).__init__(data=data, param=param)
super().__init__(data=data, param=param)

# ---- BaseImageItem API ---------------------------------------------------
def get_default_param(self):
Expand Down Expand Up @@ -132,7 +132,7 @@ def serialize(
Args:
writer: HDF5, INI or JSON writer
"""
super(ImageItem, self).serialize(writer)
super().serialize(writer)
(xmin, xmax), (ymin, ymax) = self.get_xdata(), self.get_ydata()
writer.write(xmin, group_name="xmin")
writer.write(xmax, group_name="xmax")
Expand All @@ -150,7 +150,7 @@ def deserialize(
Args:
reader: HDF5, INI or JSON reader
"""
super(ImageItem, self).deserialize(reader)
super().deserialize(reader)
for attr in ("xmin", "xmax", "ymin", "ymax"):
# Note: do not be tempted to write the symetric code in `serialize`
# because calling `get_xdata` and `get_ydata` is necessary
Expand Down Expand Up @@ -428,7 +428,7 @@ def __init__(self, x=None, y=None, data=None, param=None):
self.tr = np.eye(3, dtype=float)
self.itr = np.eye(3, dtype=float)
self.points = np.array([[0, 0, 2, 2], [0, 2, 2, 0], [1, 1, 1, 1]], float)
super(XYImageItem, self).__init__(data, param)
super().__init__(data, param)

if x is not None and y is not None:
self.set_xy(x, y)
Expand Down Expand Up @@ -476,7 +476,7 @@ def serialize(
Args:
writer: HDF5, INI or JSON writer
"""
super(XYImageItem, self).serialize(writer)
super().serialize(writer)
writer.write(self.x, group_name="Xdata")
writer.write(self.y, group_name="Ydata")

Expand All @@ -491,7 +491,7 @@ def deserialize(
Args:
reader: HDF5, INI or JSON reader
"""
super(XYImageItem, self).deserialize(reader)
super().deserialize(reader)
x = reader.read(group_name="Xdata", func=reader.read_array)
y = reader.read(group_name="Ydata", func=reader.read_array)
self.set_xy(x, y)
Expand Down Expand Up @@ -672,7 +672,7 @@ class RGBImageItem(ImageItem):

def __init__(self, data=None, param=None):
self.orig_data = None
super(RGBImageItem, self).__init__(data, param)
super().__init__(data, param)
self.lut = None

# ---- BaseImageItem API ---------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions plotpy/items/image/masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def set_data(self, data, lut_range=None):
* data: 2D NumPy array
* lut_range: LUT range -- tuple (levelmin, levelmax)
"""
super(MaskedImageItem, self).set_data(data, lut_range)
super().set_data(data, lut_range)
MaskedImageMixin._set_data(self, data)


Expand Down Expand Up @@ -344,5 +344,5 @@ def set_data(self, data, lut_range=None):
* data: 2D NumPy array
* lut_range: LUT range -- tuple (levelmin, levelmax)
"""
super(MaskedXYImageItem, self).set_data(data, lut_range)
super().set_data(data, lut_range)
MaskedImageMixin._set_data(self, data)
4 changes: 2 additions & 2 deletions plotpy/items/image/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, X, Y, Z, param=None):
self.tr = np.eye(3, dtype=float)
self.itr = np.eye(3, dtype=float)
self.points = np.array([[0, 0, 2, 2], [0, 2, 2, 0], [1, 1, 1, 1]], float)
super(QuadGridItem, self).__init__(Z, param)
super().__init__(Z, param)
self.set_data(Z)
self.grid = 1
self.interpolate = (0, 0.5, 0.5)
Expand Down Expand Up @@ -185,7 +185,7 @@ def __init__(self, X, Y, param=None, Z=None):
self.tr = np.eye(3, dtype=float)
self.itr = np.eye(3, dtype=float)
self.points = np.array([[0, 0, 2, 2], [0, 2, 2, 0], [1, 1, 1, 1]], float)
super(Histogram2DItem, self).__init__(param=param)
super().__init__(param=param)

# Set by parameters
self.nx_bins = 0
Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/image/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, data=None, param=None):
self.locked = False
self.rotation_point = None
self.rotation_point_move_with_shape = None
super(TrImageItem, self).__init__(data, param)
super().__init__(data, param)

# ---- BaseImageItem API ---------------------------------------------------
def get_default_param(self):
Expand Down
14 changes: 7 additions & 7 deletions plotpy/items/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class AbstractLabelItem(QwtPlotItem):
_private = False

def __init__(self, labelparam=None):
super(AbstractLabelItem, self).__init__()
super().__init__()
self.selected = False
self.anchor = None
self.G = None
Expand Down Expand Up @@ -458,7 +458,7 @@ def __init__(self, text=None, labelparam=None):
self.text_string = "" if text is None else text
self.text = QG.QTextDocument()
self.marker: QwtSymbol | None = None
super(LabelItem, self).__init__(labelparam)
super().__init__(labelparam)
self.setIcon(get_icon("label.png"))

def __reduce__(self):
Expand All @@ -475,7 +475,7 @@ def serialize(
Args:
writer: HDF5, INI or JSON writer
"""
super(LabelItem, self).serialize(writer)
super().serialize(writer)
writer.write(self.text_string, group_name="text")

def deserialize(
Expand All @@ -489,7 +489,7 @@ def deserialize(
Args:
reader: HDF5, INI or JSON reader
"""
super(LabelItem, self).deserialize(reader)
super().deserialize(reader)
self.set_text(reader.read("text", func=reader.read_unicode))

def types(self) -> tuple[type[IItemType], ...]:
Expand Down Expand Up @@ -588,7 +588,7 @@ class LegendBoxItem(AbstractLabelItem):
def __init__(self, labelparam=None):
self.font = None
self.color = None
super(LegendBoxItem, self).__init__(labelparam)
super().__init__(labelparam)
# saves the last computed sizes
self.sizes = 0.0, 0.0, 0.0, 0.0
self.setIcon(get_icon("legend.png"))
Expand Down Expand Up @@ -762,7 +762,7 @@ class SelectedLegendBoxItem(LegendBoxItem):
""" """

def __init__(self, dataset=None, itemlist=None):
super(SelectedLegendBoxItem, self).__init__(dataset)
super().__init__(dataset)
self.itemlist = [] if itemlist is None else itemlist

def __reduce__(self):
Expand Down Expand Up @@ -911,7 +911,7 @@ class DataInfoLabel(LabelItem):
__implements__ = (IBasePlotItem,)

def __init__(self, labelparam=None, infos=None):
super(DataInfoLabel, self).__init__(None, labelparam)
super().__init__(None, labelparam)
if isinstance(infos, ObjectInfo):
infos = [infos]
self.infos = infos
Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PolygonMapItem(QwtPlotItem):
_can_rotate = False

def __init__(self, curveparam=None):
super(PolygonMapItem, self).__init__()
super().__init__()
if curveparam is None:
self.param = CurveParam(_("PolygonMap"), icon="curve.png")
else:
Expand Down
6 changes: 3 additions & 3 deletions plotpy/items/shapes/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Axes(PolygonShape):
def __init__(
self, p0=(0, 0), p1=(0, 0), p2=(0, 0), axesparam=None, shapeparam=None
):
super(Axes, self).__init__(shapeparam=shapeparam)
super().__init__(shapeparam=shapeparam)
self.set_rect(p0, p1, p2)
self.arrow_angle = 15 # degrees
self.arrow_size = 0.05 # % of axe length
Expand Down Expand Up @@ -70,7 +70,7 @@ def serialize(
Args:
writer: HDF5, INI or JSON writer
"""
super(Axes, self).serialize(writer)
super().serialize(writer)
self.axesparam.update_param(self)
writer.write(self.axesparam, group_name="axesparam")

Expand All @@ -85,7 +85,7 @@ def deserialize(
Args:
reader: HDF5, INI or JSON reader
"""
super(Axes, self).deserialize(reader)
super().deserialize(reader)
self.axesparam = AxesShapeParam(_("Axes"), icon="gtaxes.png")
reader.read("axesparam", instance=self.axesparam)
self.axesparam.update_axes(self)
Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/shapes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AbstractShape(QwtPlotItem):
_can_move = True

def __init__(self):
super(AbstractShape, self).__init__()
super().__init__()
self.selected = False

# ------IBasePlotItem API----------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/shapes/ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class EllipseShape(PolygonShape):
CLOSED = True

def __init__(self, x1=0, y1=0, x2=0, y2=0, shapeparam=None):
super(EllipseShape, self).__init__(shapeparam=shapeparam)
super().__init__(shapeparam=shapeparam)
self.is_ellipse = False
self.set_xdiameter(x1, y1, x2, y2)
self.setIcon(get_icon("circle.png"))
Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/shapes/marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Marker(QwtPlotMarker):
_can_move = True

def __init__(self, label_cb=None, constraint_cb=None, markerparam=None):
super(Marker, self).__init__()
super().__init__()
self._pending_center_handle = None
self.selected = False
self.label_cb = label_cb
Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/shapes/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PointShape(PolygonShape):
CLOSED = False

def __init__(self, x=0, y=0, shapeparam=None):
super(PointShape, self).__init__(shapeparam=shapeparam)
super().__init__(shapeparam=shapeparam)
self.set_pos(x, y)
self.setIcon(get_icon("point_shape.png"))

Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/shapes/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PolygonShape(AbstractShape):
CLOSED = True

def __init__(self, points=None, closed=None, shapeparam=None):
super(PolygonShape, self).__init__()
super().__init__()
self.closed = self.CLOSED if closed is None else closed
self.selected = False

Expand Down
2 changes: 1 addition & 1 deletion plotpy/items/shapes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class XRangeSelection(AbstractShape):
""" """

def __init__(self, _min, _max, shapeparam=None):
super(XRangeSelection, self).__init__()
super().__init__()
self._min = _min
self._max = _max
if shapeparam is None:
Expand Down
Loading

0 comments on commit 98bfa88

Please sign in to comment.