aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtGui
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-16 10:19:17 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-21 13:20:15 +0200
commit6389561fd75e80c69d7c83f6a87d988450a2e569 (patch)
tree5cbb981cfc1f9f3f3124fbd06a81fd6944498e35 /sources/pyside6/tests/QtGui
parentdb52b6e6ec926f48679d091f7afa42f514b5e71c (diff)
Add a numpy overload for some functions taking lists of QPointF
Add functions taking x,y data in the form of numpy-vectors (as common for matplotlib, etc) for: QPainter::drawPoints() QXYSeries::append(), QXYSeries::replace() They are added as separate functions instead of overloads since there is a restriction in that numpy arrays cause an error: FIXME Subscripted generics cannot be used with class and instance checks when passed to other type check macros. Task-number: PYSIDE-1540 Task-number: PYSIDE-1503 Change-Id: Ie1521ce19127bb0641fbdb4f7320a8707682724e Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/tests/QtGui')
-rw-r--r--sources/pyside6/tests/QtGui/qpainter_test.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/sources/pyside6/tests/QtGui/qpainter_test.py b/sources/pyside6/tests/QtGui/qpainter_test.py
index b05189d01..752475494 100644
--- a/sources/pyside6/tests/QtGui/qpainter_test.py
+++ b/sources/pyside6/tests/QtGui/qpainter_test.py
@@ -40,6 +40,13 @@ from PySide6.QtGui import QPainter, QLinearGradient, QImage
from PySide6.QtCore import QLine, QLineF, QPoint, QPointF, QRect, QRectF, Qt
+try:
+ import numpy as np
+ HAVE_NUMPY = True
+except ModuleNotFoundError:
+ HAVE_NUMPY = False
+
+
class QPainterDrawText(UsesQGuiApplication):
def setUp(self):
super(QPainterDrawText, self).setUp()
@@ -109,6 +116,11 @@ class QPainterDrawText(UsesQGuiApplication):
QPoint(20.0, 10.0),
QPoint(80.0, 30.0),
QPoint(90.0, 70.0)])
+ if HAVE_NUMPY:
+ x = np.array([10.0, 20.0, 80.0, 90.0])
+ y = np.array([80.0, 10.0, 30.0, 70.0])
+ self.painter.drawPointsNp(x, y)
+
class SetBrushWithOtherArgs(UsesQGuiApplication):