Commit Graph

163 Commits

Author SHA1 Message Date
pijyoi
4d6a8e4998
add usage of numba (for rescale) (#1695)
* implement rescale using numba

* workaround to pass test_makeARGB.py

* key on (input, output) manually

* remove minimum version check

* signature needs to be a list of signatures

numba considers it a mistake for single-item non-list but works around
it internally

* add numba test to test_makeARGB.py

* add numba as dependency in CI

* handle properly the case where useNumba was already True

* restore useCupy setting after test

* filter numba nan warning

* don't make changes to test_cupy_makeARGB_...
2021-04-28 22:29:09 -07:00
Ogi Moore
03ea368454 Clean up Errors for CodeQL analyzer
CodeQL identified some errors and warnings, which this commit cleans up.
2021-04-23 22:44:29 -07:00
Ogi Moore
6a386e723b Fix overflow warning in QColor by using np.isfinite 2021-04-23 22:43:57 -07:00
Ogi Moore
314121192a Use math module for isfinite or isnan for scalars
Various places in the library attempt to check if scalars are finite
via numpy methods, which are intended to be used on numpy arrays.  Using
the math module equivalent functions on scalars is significantly faster.

In a few places, I also use numpy methods explicitly (np.all vs. all)
2021-04-23 22:43:57 -07:00
Ogi Moore
b0769f4be9 Use math.radians and math.degrees
Many places in the library were doing radian to degree conversion
via the manual calculation.  Doing timeit benchmarks on my system, I
am able to get a 4x speedup by using math.degrees or math.radians
instead
2021-04-23 22:43:51 -07:00
Ogi Moore
1138c67d45 Use math module trig functions for scalars
This commit replaces the use of np.sin/np.cos/np.tan uses throughout
the library with math.sin/math.cos/math.tan for scalar values
2021-04-23 22:42:46 -07:00
Ogi Moore
85c726e49a Replace uses of np.log on scalers with math.log 2021-04-23 11:53:00 -07:00
Nathan Jessurun
e890d832e0 promote use of '#' in mkPen 2021-04-10 17:52:51 -04:00
KIU Shueng Chuan
3be8cafff4 avoid numpy scalar overflow
the "offset" argument passed into rescaleData() is typically an element
of an ndarray, i.e. it comes from the lower bound value of the "levels"
ndarray. as such, arithmetic operations on it can overflow.

this triggers a runtime warning in the test suite.

the workaround is to convert it to a Python (integer) scalar.
2021-04-09 10:14:23 +08:00
pijyoi
aa57c7a685
implement rescaleData as a blocked iterator using np.nditer (#1648)
* implement rescaleData_blocked

clip limits should be int if data is int

* add test for rescaleData_blocked

* dispatch to different versions depending on numpy or cupy

* make rescaleData() the only entry-point
2021-04-05 23:02:52 -07:00
KIU Shueng Chuan
17e2f0f5f2 fix makeARGB() endian ordering 2021-04-01 08:38:08 +08:00
KIU Shueng Chuan
b3dc090373 implement fastpath for makeARGB 2021-03-26 04:07:19 +08:00
Ogi Moore
bb5a179647
Add Deprecation Warning to Hex Strings That Do Not Start With "#" in mkColor (#1644)
* Add deprecation warning

* Incorporate changes to docs/warning

* correct input for no warnings

* Update docs examples in LabelItem
2021-03-23 11:35:06 -07:00
Nils Nemitz
2c82a84f68 Do not use clip_array on scalars (use clip_scalar instead) 2021-03-23 01:08:31 +09:00
pijyoi
d74bbe3bf6
Fix functions.clip_array() (#1649)
* fix clip_array()

return error for invalid inputs.
use minmax for win32, umath.clip for other platforms

the previous code was penalizing Linux

* force output to be an array
2021-03-21 18:44:26 -07:00
KIU Shueng Chuan
8d74dfe11b refactor code to replace np.clip 2021-03-20 08:09:29 +08:00
KIU Shueng Chuan
56b54344e2 workaround np.clip regression since numpy 1.17 2021-03-14 16:01:29 +08:00
Martin
09fd7a81b9 account for cupy inconsistency in slicing with a boolean array
See https://github.com/cupy/cupy/issues/4693
2021-02-19 20:51:35 -08:00
lidstrom83
6519734932
Deprecate unused/unnecessary modules (#1576)
* Deprecate ordereddict module

* Import OrderedDict from collections module instead of pgcollections

* Deprecate pgcollections module

* Deprecate lru_cache module

A simpler recipe exists from the standard library using OrderedDict.

* Deprecate pil_fix module

* Python 3.7 compatibility fix

* Avoid or suppress deprecation warnings in tests
2021-02-15 09:52:06 -08:00
Ogi Moore
825286066a only cast to float32 when safe to do so 2021-02-14 17:43:32 -08:00
Ogi Moore
dce2288a18 Fix most errors... 2021-02-13 10:57:38 -08:00
Ogi Moore
3bfe2d81ba Do not use numpy deprecated type aliases 2021-02-13 10:57:38 -08:00
KIU Shueng Chuan
6c8e07c377 use 64-bits qimage size for PyQt5 5.15
PyQt5 5.15 has both methods sizeInBytes() (64-bits) and byteCount()
(32-bits)
the previous formulation would use 32-bits qimage size for PyQt5 5.15.
2021-02-11 10:38:19 +08:00
Ogi Moore
28e7d4d12c
Fix Small Heights in ErrorBarItem (#1558)
* Add arrayToQPath bit

* No more moveTo or lineTo

* Use better names than 'partial'

* Implement feedback from reviewer
2021-02-09 20:42:39 -08:00
KIU Shueng Chuan
54d7c591b5 PyQt6 6.0.1 changes QImage constructor api 2021-02-07 07:14:24 +08:00
Nils Nemitz
194941dfb2
change imports in cupy module to be local (#1548) 2021-02-06 09:21:24 -08:00
Kenneth Lyons
15bdd89293 Add a few minor notes to docs on suffix/siPrefix 2021-02-03 17:27:41 -08:00
Kenneth Lyons
cd10719837 Support siPrefix with no suffix in SpinBox 2021-02-03 17:14:06 -08:00
Ogi Moore
7b3fdda1e4 Merge branch 'master' into ptree 2021-01-31 13:36:53 -08:00
pijyoi
9d89d10bcf
some optimizations for rescaleData (#1518)
1) use float32 instead of float64 for low precision inputs
2) use in-place operations to avoid unnecessary copies
2021-01-30 14:38:34 -08:00
KIU Shueng Chuan
dcbddb0abf add PyQt6 support to Qt.py and functions.py 2021-01-23 08:29:43 +08:00
Martin Chase
1654cb62ac
Small ImageItem-related improvements (#1501)
* Initial asv configuration

* makeARGB benchmarks are working

* Fix array type checking and allow making QImage in greyscale mode

* Performance improvements

* benchmark minor update

* Add CLI args to video speed test for easier / automated benchmarking

* udpate asv conf

* use a buffer-qimage so we can avoid allocing so much

this should improve performance under windows

* Add CLI args to video speed test for easier / automated benchmarking

* use a buffer-qimage so we can avoid allocing so much

this should improve performance under windows

* playing with numba

* oh, mins/maxes in the other order

* maybe put the cupy in here and see what happens

* pre-alloc for gpu and cpu

* handle possibility of not having cupy

* no numba in this branch

* organize imports

* name them after their use, not their expected device

* cupy.take does not support clip mode, so do it explicitly

* add CUDA option to the VideoSpeedTest

* rename private attr xp to _xp

* handle resizes at the last moment

* cupy is less accepting of lists as args

* or somehow range isn't allowed? what histogram is this?

* construct the array with python objects

* get the python value right away

* put LUT into cupy if needed

* docstring about cuda toolkit version

* better handling and display of missing cuda lib

* lint

* import need

* handle switching between cupy and numpy in a single ImageItem

* only use xp when necessary

we can now depend on numpy >= 1.17, which means __array_function__-implementing cupy can
seamlessly pass into numpy functions. the remaining uses of xp are for our functions which
need to allocate new data structures, an operation that has to be substrate-specific.

remove empty_cupy; just check if the import succeeded, instead.

* use an option to control use of cupy

* convert cupy.ceil array to int for easier mathing

* RawImageWidget gets to use the getCupy function now, too

* raise error to calm linters; rename for clarity

* Add Generated Template Files

* document things better

* cruft removal

* warnings to communicate when cupy is expected but somehow broken

* Merge branch 'cupy-rebase' into 'l/imageitem-performance'

Abundant conflicts; accept theirs in nearly every case.

* playing with settings to suss out timeout

* playing with more stuff to suss out timeout

* replace with empty list

* skip test_ExampleApp on linux+pyside2 only

* clean out some bits that no longer make sense; linty

* ignore airspeed velocity dir

* lint

* tidy up for merge

* lint

* lint, avoid shadowing

* specific import; run-as-script setup

Co-authored-by: Luke Campagnola <luke.campagnola@gmail.com>
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2021-01-19 23:19:03 -08:00
Martin Chase
f2b4a15b2d
Performance enhancement: use CUDA in ImageItem (#1466)
* Add CLI args to video speed test for easier / automated benchmarking

* use a buffer-qimage so we can avoid allocing so much

this should improve performance under windows

* playing with numba

* oh, mins/maxes in the other order

* maybe put the cupy in here and see what happens

* pre-alloc for gpu and cpu

* handle possibility of not having cupy

* no numba in this branch

* organize imports

* name them after their use, not their expected device

* cupy.take does not support clip mode, so do it explicitly

* add CUDA option to the VideoSpeedTest

* rename private attr xp to _xp

* handle resizes at the last moment

* cupy is less accepting of lists as args

* or somehow range isn't allowed? what histogram is this?

* construct the array with python objects

* get the python value right away

* put LUT into cupy if needed

* docstring about cuda toolkit version

* better handling and display of missing cuda lib

* lint

* import need

* handle switching between cupy and numpy in a single ImageItem

* only use xp when necessary

we can now depend on numpy >= 1.17, which means __array_function__-implementing cupy can
seamlessly pass into numpy functions. the remaining uses of xp are for our functions which
need to allocate new data structures, an operation that has to be substrate-specific.

remove empty_cupy; just check if the import succeeded, instead.

* use an option to control use of cupy

* convert cupy.ceil array to int for easier mathing

* RawImageWidget gets to use the getCupy function now, too

* raise error to calm linters; rename for clarity

* Add Generated Template Files

* document things better

* cruft removal

* warnings to communicate when cupy is expected but somehow broken

* playing with settings to suss out timeout

* playing with more stuff to suss out timeout

* replace with empty list

* skip test_ExampleApp on linux+pyside2 only

Co-authored-by: Luke Campagnola <luke.campagnola@gmail.com>
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2021-01-19 21:26:24 -08:00
KIU Shueng Chuan
6e2a28260a add QImage support for PySide6
also update for PySide2.QImage to take in ndarray directly.
2021-01-15 08:25:06 +08:00
KIU Shueng Chuan
fd85076bb6 invert QTransform using adjoint() and determinant() 2021-01-10 13:58:31 +08:00
Ogi Moore
2689cdb5f6 Fix regex warning 2020-12-22 10:26:19 -08:00
Daniel Lidstrom
0703e3db9b Ensure synchronization of parameter and widget's values 2020-12-20 18:43:11 -08:00
Marko Toplak
00fd63e859
arrayToPath: revert to old meaning of connect=ndarray parameter (#1461)
The i-th position of that array used to define if points (i) and (i+1)
were connected, but in master it defines whether points (i-1) and (i) are connected.
This commit reverts to (i) and (i+1) interpretation.
2020-11-27 07:57:26 -08:00
Luke Campagnola
6c7bd87592
Fill in non-finite plot values for Qt versions >= 5.12.3 (#1287)
* Fill in non-finite plot values for Qt versions >= 5.12.3

* handle the case of all nan entries

Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2020-11-22 20:27:24 -08:00
lidstrom83
0a7a54c3f6
Permit entry of non-finite values into float SpinBox (#1422)
* Permit nan, inf, and -inf for float SpinBox

Bounds are enforced against inf and -inf inputs, but not for nan.

* Ensure SpinBox text is updated when out-of-bounds value is entered

* Make inf and nan entry in SpinBox case-insensitive

* Make SpinBox example behave as advertised

* Make non-finite SpinBox values optionally allowed

* Python 2 compatibility
2020-10-27 21:26:05 -07:00
Kenneth Lyons
b058d032d1 Fix some warnings 2020-07-13 21:09:31 -07:00
Luke Campagnola
ac417a6567 py3 fixes 2020-07-05 22:52:15 -07:00
zhujun98
b61c7c1e39 Fix the cases with connect being 'pairs' and 'finite' 2020-06-29 23:20:29 +02:00
zhujun98
7016d1c6c3 Fix arrayToPath
Use the correct format for streaming QByteArray to QPainterPath.
2020-06-28 21:23:06 +02:00
Ogi Moore
ecd0642ca9
Merge pull request #977 from campagnola/pseudoscatter-performance
Add a faster method for computing pseudoscatter
2020-06-13 21:08:33 -07:00
Maurice van der Pot
e18af48b8d
Implement headWidth parameter for arrows (#385)
Although the documentation used to say that specifying tipAngle would
override headWidth, headWidth was never used. The new behaviour is that
tipAngle will be used, with a default value of 25, unless headWidth is
specified.

Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2020-06-09 22:04:29 -07:00
alfon_news
fc7921100e
Fix siScale imprecision errors (#508)
* Fix siScale imprecision errors

* Implement 2xB suggested change

Co-authored-by: Alberto Fontán Correa <afontan@com.uvigo.es>
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2020-06-08 22:51:14 -07:00
Ogi Moore
d282f8aba8
Remove workaround for memory leak in QImage (#1223)
Co-authored-by: Ognyan Moore <omoore@sensoryinc.com>
2020-06-05 20:57:20 -07:00
Jan Kotanski
6f34da586d remove second nanMask = np.isnan(data) 2020-04-03 17:56:38 -07:00
Jan Kotanski
daeacad71f Make nanMask compatible with 3D data 2020-04-03 17:56:11 -07:00