diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-05-04 14:44:40 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-05-05 13:39:27 +0000 |
commit | 45ba07e3145dc0977383b1a0633e72eda4270ffd (patch) | |
tree | 355b6ffbc8b38d713fb5a538042c9c553c08f7be /sources/pyside6/tests/QtCharts/qcharts_numpy_test.py | |
parent | 14bcdfe09bd5a94816af69f3f91797d3069e45e3 (diff) |
Numpy support: Handle short/long/long long integer types
The default type of numpy is int64 on Linux and long in Windows
these days. As numpy is still based on the old long/long long
scheme for the types, add some mapping.
[ChangeLog][shiboken6] numpy support has been extended to handle
short/long long integer types.
Fixes: PYSIDE-2313
Change-Id: I75d9277ae0867401c2c188efb3a50f4c53c4fc24
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 499832abfdf13eac5aa35f84a62166fb5aa2e034)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources/pyside6/tests/QtCharts/qcharts_numpy_test.py')
-rw-r--r-- | sources/pyside6/tests/QtCharts/qcharts_numpy_test.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sources/pyside6/tests/QtCharts/qcharts_numpy_test.py b/sources/pyside6/tests/QtCharts/qcharts_numpy_test.py new file mode 100644 index 000000000..044fab34c --- /dev/null +++ b/sources/pyside6/tests/QtCharts/qcharts_numpy_test.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +'''Test cases for QCharts/numpy''' + +import os +import sys +import unittest +try: + import numpy as np + HAVE_NUMPY = True +except ModuleNotFoundError: + HAVE_NUMPY = False + +from pathlib import Path +sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6.QtCore import QCoreApplication +from PySide6.QtCharts import QLineSeries + + +class QChartsNumpyTestCase(UsesQApplication): + '''Tests related to QCharts/numpy''' + + @unittest.skipUnless(HAVE_NUMPY, "requires numpy") + def test(self): + """PYSIDE-2313: Verify various types.""" + line_series = QLineSeries() + data_types = [np.short, np.ushort, np.int32, np.uint32, + np.int64, np.uint64, np.float32, np.float64] + for dt in data_types: + old_size = line_series.count() + arr = np.array([2], dtype=dt) + line_series.appendNp(arr, arr) + self.assertEqual(line_series.count(), old_size + 1) + + +if __name__ == '__main__': + unittest.main() |