Skip to content

Commit a443d53

Browse files
committed
QwtPointArrayData constructor: added 'finite' arg
1 parent 92aa144 commit a443d53

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

qwt/plot_series.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,16 @@ class QwtPointArrayData(QwtSeriesData):
185185
"""
186186
Interface for iterating over two array objects
187187
188-
.. py:class:: QwtCQwtPointArrayDataolorMap(x, y, [size=None])
188+
.. py:class:: QwtPointArrayData(x, y, [size=None], [finite=True])
189189
190190
:param x: Array of x values
191191
:type x: list or tuple or numpy.array
192192
:param y: Array of y values
193193
:type y: list or tuple or numpy.array
194194
:param int size: Size of the x and y arrays
195+
:param bool finite: if True, keep only finite array elements (remove all infinity and not a number values), otherwise do not filter array elements
195196
"""
196-
def __init__(self, x=None, y=None, size=None):
197+
def __init__(self, x=None, y=None, size=None, finite=None):
197198
QwtSeriesData.__init__(self)
198199
if x is None and y is not None:
199200
x = np.arange(len(y))
@@ -210,8 +211,13 @@ def __init__(self, x=None, y=None, size=None):
210211
if size is not None:
211212
x = np.resize(x, (size, ))
212213
y = np.resize(y, (size, ))
213-
self.__x = x
214-
self.__y = y
214+
if finite if finite is not None else True:
215+
indexes = np.logical_and(np.isfinite(x), np.isfinite(y))
216+
self.__x = x[indexes]
217+
self.__y = y[indexes]
218+
else:
219+
self.__x = x
220+
self.__y = y
215221

216222
def boundingRect(self):
217223
"""
@@ -343,4 +349,4 @@ def swapData(self, series):
343349
"""
344350
swappedSeries = self.__series
345351
self.__series = series
346-
return swappedSeries
352+
return swappedSeries

0 commit comments

Comments
 (0)