Skip to content

Commit

Permalink
MNT: Use generic signature for createCurveItem plot methods
Browse files Browse the repository at this point in the history
This gives more flexibility to the subclasses to change their signatures
of __init__.

Signed-off-by: flowln <[email protected]>
  • Loading branch information
flowln committed Oct 24, 2023
1 parent 92a1268 commit 60bfb8a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 57 deletions.
23 changes: 3 additions & 20 deletions pydm/widgets/archiver_time_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
import numpy as np
from collections import OrderedDict
from typing import List, Optional, Union
from typing import List, Optional
from pyqtgraph import DateAxisItem, ErrorBarItem
from pydm.widgets.channel import PyDMChannel
from pydm.widgets.timeplot import TimePlotCurveItem
Expand Down Expand Up @@ -332,26 +332,9 @@ def getArchiveBufferSize(self) -> int:
return DEFAULT_ARCHIVE_BUFFER_SIZE
return self._curves[0].getArchiveBufferSize()

def createCurveItem(
self,
y_channel: str,
plot_by_timestamps: bool,
name: str,
color: Union[QColor, str],
yAxisName: str,
useArchiveData: bool,
**plot_opts
) -> ArchivePlotCurveItem:
def createCurveItem(self, *args, **kwargs) -> ArchivePlotCurveItem:
"""Create and return a curve item to be plotted"""
curve_item = ArchivePlotCurveItem(
y_channel,
use_archive_data=useArchiveData,
plot_by_timestamps=plot_by_timestamps,
name=name,
color=color,
yAxisName=yAxisName,
**plot_opts
)
curve_item = ArchivePlotCurveItem(*args, **kwargs)
curve_item.archive_data_received_signal.connect(self.archive_data_received)
return curve_item

Expand Down
13 changes: 2 additions & 11 deletions pydm/widgets/eventplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,17 +359,8 @@ def addChannel(
self.addCurve(curve, curve_color=color, y_axis_name=yAxisName)
curve.data_changed.connect(self.set_needs_redraw)

def createCurveItem(self, channel, y_idx, x_idx, name, color, yAxisName, bufferSizeChannelAddress, **plot_opts):
return EventPlotCurveItem(
addr=channel,
y_idx=y_idx,
x_idx=x_idx,
name=name,
color=color,
yAxisName=yAxisName,
bufferSizeChannelAddress=bufferSizeChannelAddress,
**plot_opts
)
def createCurveItem(self, *args, **kwargs):
return EventPlotCurveItem(*args, *kwargs)

def removeChannel(self, curve):
"""
Expand Down
12 changes: 2 additions & 10 deletions pydm/widgets/scatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,16 +448,8 @@ def addChannel(
self.addCurve(curve, curve_color=color, y_axis_name=yAxisName)
curve.data_changed.connect(self.set_needs_redraw)

def createCurveItem(self, y_addr, x_addr, name, color, yAxisName, bufferSizeChannelAddress, **plot_opts):
return ScatterPlotCurveItem(
y_addr,
x_addr,
name=name,
color=color,
yAxisName=yAxisName,
bufferSizeChannelAddress=bufferSizeChannelAddress,
**plot_opts
)
def createCurveItem(self, *args, **kwargs):
return ScatterPlotCurveItem(*args, **kwargs)

def removeChannel(self, curve):
"""
Expand Down
14 changes: 2 additions & 12 deletions pydm/widgets/timeplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,18 +547,8 @@ def addYChannel(

return new_curve

def createCurveItem(
self, y_channel, plot_by_timestamps, plot_style, name, color, yAxisName, useArchiveData, **plot_opts
):
return TimePlotCurveItem(
y_channel,
plot_by_timestamps=plot_by_timestamps,
plot_style=plot_style,
name=name,
color=color,
yAxisName=yAxisName,
**plot_opts
)
def createCurveItem(self, *args, **kwargs):
return TimePlotCurveItem(*args, **kwargs)

def removeYChannel(self, curve):
"""
Expand Down
6 changes: 2 additions & 4 deletions pydm/widgets/waveformplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,8 @@ def addChannel(
curve.getViewBox().addItem(curve.bar_graph_item)
curve.data_changed.connect(self.set_needs_redraw)

def createCurveItem(self, y_addr, x_addr, plot_style, name, color, yAxisName, **plot_opts):
return WaveformCurveItem(
y_addr, x_addr, plot_style=plot_style, name=name, color=color, yAxisName=yAxisName, **plot_opts
)
def createCurveItem(self, *args, **kwargs):
return WaveformCurveItem(*args, **kwargs)

def removeChannel(self, curve):
"""
Expand Down

0 comments on commit 60bfb8a

Please sign in to comment.