Commit Graph

2024 Commits

Author SHA1 Message Date
Nils Nemitz f002d70adc
Expose number of subsamples in ImageItem auto-level determination (#1638)
* exposed number of subsamples in auto-level determination

* Removing print statement at @NilsNemitz's request

* make levelSamples count pixels, not pixels * channels

* minimum number of samples can be 2 if we look at pixels anyway

* adjusted minimum levelSamples to 4: Otherwise a 2x2 image downsamples to a single pixel

* extended docstring for level to make the user aware of auto-level subsampling

* subsample towards square array for auto-leveling

* eliminated duplicated code between level downsampling and samples and QuickMinMax method

Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2021-06-08 10:25:47 -07:00
Nils Nemitz 61f067bf7c
Add axis convenience methods and matrix display example (#1726)
* add axis convenient methods and matrix display example

* wrestled wayward space back into docstring

* color map names are case sensitive on Linux

* docstring fix for PlotItem

* protect AxisItem.linkToView from being obscured by DateAxisItem override

* replaced setOrigin method by promoted setPos and setScale

* made tri-state axes switching explicit

* reverted setRect behavior, documentation pass for ImageItem

* minor text adjustment

* implmented some suggested revisions

* fix input parsing for setRect and add tests so that I don't break it again

* don't try to re-add transform after clearing it

* changed example and doc image generators to pg.exec()

* removed commented-out code

* cleaned up transform eqaulity assertion

* restored devoured comment

* restored devoured comment
2021-06-07 07:44:19 -07:00
Ogi Moore 3a3d05b16f
Merge pull request #1817 from pijyoi/split_finite
implement QPolygonF codepath for connect="finite"
2021-06-06 21:55:51 -07:00
bsobhani d863907163
add function to disable autoscaling (#1819) 2021-06-06 21:19:23 -07:00
shikishima-TasakiLab f13002b251
Add "GLTextItem" (#1776)
* Add GLTextItem

* Fixed DocString.

* Delete unnecessary function.

* Add `from .items.GLTextItem import *`

* Add an example.

* [Combines two `isinstance()` into one.](https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046120)

* [Combines two `isinstance()` into one.](https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046120)

* [The long code has been broken up into separate lines.](https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046234)

* [Moved `pos`, `color`, `text`, and `font` to the `__init__` method.](https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633047216)

* Add `import initExample` and fix `mkQApp().exec_()` to `pg.exec()` (https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046878, https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046781)

* Fix `pg.exec()` to `pg.mkQApp().exec()`

* Revert "Fix `pg.exec()` to `pg.mkQApp().exec()`"

This reverts commit 67d397d803.

* Remove type-hints.

* Fix `glColor4d(float(self.color[0]), float(self.color[1]), float(self.color[2]), float(self.color[3]))` to `glColor4d(*self.color)`

* Add `value = fn.glColor(value)`

* Remove debug print.

* Add GLGridItem and GLAxisItem

* Remove if-check for "color" argument

* Draw text without using GLUT.

* Divide the text position by the device pixel ratio

* Fixed bare exceptions to ValueError and TypeError.

* Add 'GLTextItem.py' to utils.py.

* Fixed a bare exception to ArgumentErrror.

* Add `__all__ = ['GLTextItem']`
2021-06-05 08:19:54 -07:00
KIU Shueng Chuan ecc3563f6d special-case all-finite 2021-06-05 20:13:07 +08:00
KIU Shueng Chuan c8e6920443 use multiple polygons for "finite" 2021-06-05 15:09:59 +08:00
Ogi Moore 145ab2e9e3 Merge branch 'master' into test-polyline 2021-06-04 21:06:52 -07:00
Ogi Moore 55e42aabfd make numpy style docstring of arrayToQPath
The function had many comments/explanations, decided to convert to
numpy docstring style, which is the direction pyqtgraph is going in
as it stands
2021-06-03 22:53:09 -07:00
Ogi Moore 649757eb31 Remove use of QPolygonF in non-finite cases
With some experimentation, it was determined that when the QPainterPath
is drawn with a QPen that has a thickness greater than 1, the end result
is quite broken.  Due to us trying to exploit non-advertised behavior
we are removing this optimization step.
2021-06-03 22:53:09 -07:00
Ogi Moore 31b4210f4e
Merge branch 'master' into merge-test-data 2021-06-02 22:15:46 -07:00
njessurun c0ebf8a432 Fix #1814 2021-06-02 11:03:22 -04:00
Ogi Moore c0b9f3e26e
Merge pull request #1795 from pijyoi/avoid_writable_qimage
don't rely on QImage-wrapped buffer being writable
2021-06-01 23:05:01 -07:00
Ogi Moore 45cf6fa232 Remove comment about QImage data references
Comment was out of date and no longer relevant, removing at @pijyoi's
suggestion.
2021-06-01 22:50:02 -07:00
Nils Nemitz 39f705fd7f
Sanitize input for plotItem.showGrid (was documentation fix for plotItem.showGrid alpha setting) (#1809)
* documentation fix for plotItem.showGrid alpha setting

* revert to 0-1 scale
2021-06-01 22:43:58 -07:00
Ogi Moore 0da1958ff1
Merge pull request #1768 from pijyoi/rgb32_alpha_chan
Format_RGB32 will always have alpha equal 255
2021-06-01 22:25:08 -07:00
3DAlgoLab 28b1499f09
Force cameraPosition() to return Vector class. (#1799)
* Update GLViewWidget.py

Fix the wrong conversion of QVector3D to numpy array.

* new way to fix the conversion error

* Recover prev. version of pixelSize

Co-authored-by: Jaeyoon Jeong <diem389@gmail.com>
2021-06-01 22:21:50 -07:00
Ogi Moore 4264219144 Add PyQt6 version check for QByteArray creation 2021-06-01 22:01:58 -07:00
Ogi Moore f01f3d473f Have debug.printExc emits RuntimeWarning
Several bugs have snuck through due to being wrapped with printExc,
which would prevent the exception from raising, but printing the trace
to the console.  In pytest, this output is not captured at all, and is
invisible unless the -s parameter is added.

This PR changes the print statement to a runtime warning, which pytest
will capture.
2021-05-31 21:06:16 -07:00
Ogi Moore d859cec95a Replace uses of tempfile.mktemp with tempfile.NamedTemporaryFile
This issue was flagged as a security issue in the static code analyzer
2021-05-31 21:06:16 -07:00
Ogi Moore 1d55fde41a Suppress non-relevant deprecation warning 2021-05-31 21:06:16 -07:00
Ogi Moore 648b8c7df4 Fix issue with int comparson impacting Qt6 2021-05-31 21:06:16 -07:00
Ogi Moore a6971c768d Move and Update test-data repo into pyqtgraph repo
To reduce complexity, and make it easier to add more images and tests,
the images in the `test-data` repository should be merged with the main
repository.  Furthermore, we can remove a lot of the subprocess work in
the image_testing.py file, as we no longer need to have it interact with
git.

The images are not the same.  Images were regenerated with Qt6, and now
have proper big and little endian handling thanks to @pijyoi

Second commit is a slightly modified variant of
2e135ab282d6007b34a3854921be54d0e9efb241 authored by @pijyoi
it is to convert qimages to RGBA8888 for testing.  Image
files were regenerated images for the big/little handling

Fixed issue with bogus test from test_NonUniformImage and generated a
new image
2021-05-31 21:05:00 -07:00
KIU Shueng Chuan cabcf6cd29 pairs: allocate and manipulate dest polygon buffer directly 2021-05-27 23:31:05 -07:00
KIU Shueng Chuan 8f4104a9ab use qpolygonf underlying buffer as backstore 2021-05-27 19:07:50 -07:00
Ogi Moore 270fc59cab Insert NaN values for connect='pairs' in Qt6
Since the QPainterPath.addPolygon(QPolygonF) does not filter out the NaN
values, we can insert NaN values to create discontinuities in the Lines,
and thus supporting connect='pairs' functionality
2021-05-27 09:38:23 -07:00
Ogi Moore 78e678c1b9 Support connect=finite for qt6 2021-05-27 09:37:23 -07:00
Luke Campagnola e29f86578f
Revert Point.angle behavior change (#1806)
* Revert behavior change of Point.angle

* Propagate Point.angle revert
2021-05-27 08:51:06 -07:00
Martin Chase 1735effea7
fix click bug on removable ROIs; test (#1804) 2021-05-26 17:14:08 -07:00
Ogi Moore 62165bbe45 Revert "Speed up arrayToQPath when connect='pairs'"
This reverts commit d62d3b182f.

Through testing, this was shown to perform quite poorly.
2021-05-25 23:30:06 -07:00
Ogi Moore c6f1d2df94 Cleanup old code, conform comments to pep8 2021-05-25 22:32:26 -07:00
Ogi Moore 07ba7be2a4 Add basic tests for arrayToQPath 2021-05-25 22:32:26 -07:00
Ogi Moore d62d3b182f Speed up arrayToQPath when connect='pairs'
As discussed earlier, the process of QDataStream >> QPainterPath is
quite slow, so this commit makes an improvement on QPainterPath creation
for the case of connect='pairs' by using a naive method of moving the
path and drawing a line on the path.  This was the fastest method
identified during testing.
2021-05-25 21:58:58 -07:00
Ogi Moore 7860d641ab Perform finiteCheck on PlotCurveItem.setData
The check for NaN values in arrayToQPath is expensive, this change
attempts to do the check one time, and if no NaN values are present,
an optional flag is passed along telling arrayToQPath that the check
can be skipped
2021-05-25 21:58:58 -07:00
Ogi Moore f08d239578 Use QPolygonF for connect='all'
Since QDataStream >> QPainterPath is an expensive operation, we can
construct our QPainterPath from an open polygon instead but only if the
connect='all' mode is present.  Future optimizations work can likely
be had with constructing a polygon from each connected segment
2021-05-25 21:58:58 -07:00
KIU Shueng Chuan d220e8a6e9 Restructuring of QPainterPath ByteArray 2021-05-25 21:36:27 -07:00
Wyatt Ubellacker 7e5c90a7a4 Fixing GLMeshItem memory leak in face drawing on 64-bit Linux (#1783) 2021-05-23 18:31:49 -07:00
KIU Shueng Chuan 7499c3b375 clip values can be derived from lut shape
also makes it clear that indices won't be out of range
2021-05-22 11:34:20 +08:00
KIU Shueng Chuan 9426ef0391 don't rely on QImage-wrapped buffer being writable 2021-05-22 09:10:03 +08:00
KIU Shueng Chuan 03ddf92839 implement numba lookup 2021-05-22 08:23:47 +08:00
Martin Chase ac84f45787
callable luts still need to be put onto a substrate (#1791) 2021-05-20 07:22:49 -07:00
Kenneth Lyons bcb6a5d66a
Merge pull request #1779 from manschloemark/master
Use fallback minStep in dec mode SpinBox (Issue 1756)
2021-05-19 18:15:10 -07:00
Martin Chase a91953e93d
Bypass makeARGB in some cases (#1786)
* refactor out _ndarray_to_qimage()

* combine levels back with lut

* make use of Grayscale8, RGB888 and Indexed8 QImage formats

Grayscale8 and RGB888 images are those that are ready for display
without further processing.

* add Grayscale16

* apply the efflut early for uint16 mono/rgb, uint8 rgb

* ndarray indexing is faster than np.take

* handle uint16 rgb(a) with no levels same as levels=[0, 65535]

* add support for Format_RGBA64

* fix: support colormaps of shape (h, 1)

* check ImageItem uint8 and uint16 QImage formats

* uint16 mono with rgb lut -> RGBX8888

* got width and height swapped in array dimensions

* set ImageItem as row-major

* no need to form a 1d 32-bit lut for array indexing

you can index (y, x) into a lookup table of shape (nentry, 3) or
(nentry, 4) and get an output of shape (y, x, 3) or (y, x, 4)

* Revert "no need to form a 1d 32-bit lut for array indexing"

This reverts commit 45cf3100de.

* distinguish between levels_lut and colors_lut

this allows uint16 images with user lut to be rendered as
Format_Indexed8

* uint8 (1-chan) images should always combine to efflut

this efflut will then be used for Indexed8 format color table.

previously, we would be taking a performance hit with doing a numpy
lookup with levels_lut.

* adapt benchmarks/makeARGB.py to renderImageItem.py

* restructure uint8 and uint16 codepaths

* normalize 1-chan images to ndim==2 earlier up

* refactor long code into functions

* bug: qimage may not be assigned

* fix: assign to self.qimage only if not None

* for uint16, do rescale rather than do levels_lut lookup

* cases 2,3 are already handled

i.e. no more using lut to do rescale of uint16 image data.

* rescale rgb images by computation, not by memory lookup

* setImage() does not take an output argument

* try to be cupy compatible

use "xp" instead of numpy module

* add numba to benchmarking

* fix: lut_big is dtype uint8 with more than 256 entries

* bug: applying colors_lut needs C-order

* support float with no nans

* fix: variable could be uninitialized

* add float32 format tests

* avoid explicitly forcing to C-contiguous

* cache effective lut only if combination took place

every one of the four branches now does its own return.
this makes it easier to follow.

* fix cupy benchmark : typo in renderQImage

* remove for loop of 1 iteration

* use float32 for floating point benchmark

* superceded by renderImageItem.py

* lint

* benchmark without lut conversion

* put the lut onto the substrate

* fix editor complaints

* handle lack of cupy

* leading underscores imply privacy

Co-authored-by: KIU Shueng Chuan <nixchuan@gmail.com>
2021-05-19 17:21:12 -07:00
Mark Schloeman c9ea25eed6 SpinBox in dec mode sets minStep to step as fallback 2021-05-16 17:37:33 -04:00
KIU Shueng Chuan dfddb39ce0 Revert "add QApplication.exec() to Qt5 bindings"
This reverts commit 2dad9862cb.
2021-05-14 06:16:21 +08:00
KIU Shueng Chuan 0fb0209e43 Revert "provide QApplication.exec() for PySide6 6.0"
This reverts commit 3eb69e6d9b.
2021-05-14 06:16:21 +08:00
KIU Shueng Chuan 0754602c3c fix in-library uses of exec_() 2021-05-14 06:16:21 +08:00
KIU Shueng Chuan 61badc88b3 implement pg.exec() 2021-05-14 06:16:21 +08:00
KIU Shueng Chuan 381147450d pass through any AttributeError 2021-05-13 14:43:28 +08:00
KIU Shueng Chuan 210203d628 don't print out expected Exception 2021-05-13 13:58:06 +08:00
KIU Shueng Chuan 3eb69e6d9b provide QApplication.exec() for PySide6 6.0 2021-05-13 09:48:47 +08:00
KIU Shueng Chuan 2dad9862cb add QApplication.exec() to Qt5 bindings 2021-05-13 09:02:42 +08:00
KIU Shueng Chuan 3b32e27083 RemoteGraphicsView.py : fix deprecated mouse positions 2021-05-13 08:57:15 +08:00
KIU Shueng Chuan 70c123a95c fix localPos() deprecated warnings 2021-05-13 08:42:45 +08:00
KIU Shueng Chuan 60661f586f fix: QVector3D has no copy constructor 2021-05-13 08:23:06 +08:00
KIU Shueng Chuan 0503f96121 Format_RGB32 will always have alpha equal 255
this also fixes the assumption that we are on little-endian.

In [18]: qimg = QtGui.QImage(1, 1, QtGui.QImage.Format.Format_RGB32)

In [19]: qimg.fill(QtCore.Qt.GlobalColor.transparent)

In [20]: np.frombuffer(qimg.bits(), dtype=np.uint8)
Out[20]: array([  0,   0,   0, 255], dtype=uint8)
2021-05-07 18:09:02 +08:00
Nils Nemitz bfc63bb730
Make plotting with gradients more fun (#1742)
* added convenience functions to better handle plotting with gradients

* docstring correction, example name correction

* retrying to get  documentation format right

* another attempt at cleaning up docs

* Don't hardcode timer type (and docs fixing attempt)

* more docstring re-formatting

* linebreaks in docstrings

* more documentation adjustments

* documentation pass

* some corrections to documentation

* more adjustments to documentation

* again?

* removed some whitespace and redundant blank lines, changed some checks '== None' to 'is None'

* fixed mis-spelling QColor as Qcolor
2021-05-06 23:20:21 -07:00
Martin Chase 2fb7cdafbd
more complete test yields more complete behavior (#1765) 2021-05-05 18:07:34 -07:00
Martin Chase fa1be1e5bf
show and hide properly for maxTraces; +test (#1764) 2021-05-05 17:08:04 -07:00
Kenneth Lyons cafe079910
Support horizontal HistogramLUT{Item,Widget} (#1757)
* Improve HistogramLUTItem docs, a few cosmetic changes

* Initial implementation of horizontally-oriented HistogramLUTItem

- Also adds support in HistogramLUTWidget
- Fixes AxisItem orientation bug for vertical orientation
- Make use of GradientEditorItem orientation (fixes another bug for
  vertical orientation)
- Use horizontal orientation in an example for demonstration

* Remove unused HistogramLUTItem option

* A few more minor fixups

* Copy paste bug

* Use f-strings

* Update from review and a couple more minor updates

* Woops

* Add doc for orientation arg

* Add top/bottom orientation to doc. Expand on levelMode doc a bit
2021-05-04 21:25:42 -07:00
shahmustafa54 e1b1410260 Fixed typo in InfiniteLine (sigclicked vs. sigClicked) 2021-05-04 06:03:17 +05:00
Ogi Moore 2fd5337215 Run processEvents twice to make sure plot is redrawn 2021-05-01 18:05:33 -07:00
Martin Chase 85e2574230
useCupy option should be settable after ImageItem init (#1749)
* do not cache the cupy so the config option can be set later

* getCupy will always return None if the option is not set

* test of failing behavior

* divorce skip from option; restore option after test
2021-04-30 10:41:11 -07:00
Fernando Bordignon 7dc4823cc6
Update symbols documentation and inverted up and down arrows of scatterplotitem (#1747) 2021-04-29 19:34:19 -07:00
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
Nils Nemitz a7bc2b9a63
clean-up of PlotDataItem downsample methods (#1725)
* clean-up of PlotDataItem downsample methods

* high end of range at low end, not zero

Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2021-04-28 22:07:24 -07:00
Martin Chase 4ee1fe4388
fix bug when plotting boolean arrays (#1748)
* test and fix for plotting boolean arrays

* smaller is faster

* oh, that bool went away

* tests should keep up with optimizations
2021-04-28 21:35:27 -07:00
Ogi Moore a534132c62
Various performance improvements to pg.Point (#1741)
This change makes use of QPointF methods which perform faster than the python
equivalent methods.  Furthermore, some tests are added.

* Set __slots__ to empty tuple for pg.Point
* Make Point.angle() behave as Vector.angle()
2021-04-28 21:29:47 -07:00
KIU Shueng Chuan 306e9c2498 fix: cprint of remote output needs decode() 2021-04-28 16:38:15 +08:00
Ogi Moore 2d8d1d6d32 Add tmp_module fixture for test_reload 2021-04-25 21:36:42 -07:00
Ogi Moore 7c48233bfa Remove unreachable code 2021-04-25 21:36:23 -07:00
Ogi Moore 38dccf8642 Fix indentation bug with flowchart 2021-04-25 20:10:54 -07:00
Ogi Moore 4d388ee633 Use open context-manager instead of file.open()
Static code checker identified multiple places where a file is opened
but is not necessarily closed.  This commit addressed that with the
exception of RemoteGraphicsView.py
2021-04-25 17:05:05 -07:00
Ogi Moore cf95964678
Merge pull request #1738 from pijyoi/fix_font
use Format_RGB32 when using QImage as paint device
2021-04-24 09:43:42 -07:00
Ogi Moore d9a3774f6c
Merge pull request #1739 from pijyoi/manual_form
Export dialog: ParameterTree needs 2 columns
2021-04-24 09:41:40 -07:00
Ogi Moore 6a708dc203
Merge pull request #1724 from j9ac9k/use-math-module-for-single-values
Use math module methods for scalars
2021-04-23 23:10:17 -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 329423f525 Use QTransform.rotateRadians when appropriate
In a few places in the library, we are doing the conversion from radians
to degrees just so we can call QTransform.rotate(), but there is a
QTransform.rotateRadians() method which would be more suitable, thus
making it so we do not have to handle the conversions ourselves
2021-04-23 22:43:57 -07:00
Ogi Moore e1415cb3a8 Use np.pi or math.pi instead of just pi 2021-04-23 22:43:57 -07:00
Ogi Moore 6a386e723b Fix overflow warning in QColor by using np.isfinite 2021-04-23 22:43:57 -07:00
Ogi Moore 3ea92736b8 Do not use list comprehensions with any or all
python any and all are able to break early the moment they come across a
member of the iterable that meets the condition; but having a list
comprehension nested within breaks that ability to exit early, as the
list comprehension has to finish being constructed first before it can
be evaluated
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
KIU Shueng Chuan e3372fddc5 specify that ParameterTree needs 2 columns in .ui 2021-04-24 11:21:12 +08:00
Ogi Moore c4a1cf11a1 Use clip_array or clip_scalar instead of np.clip
Significant performance issues have been identified with np.clip
and thus clip_array was created to speed up the operation.  In addition
clip_scalar was created to clip a scalar value between two other values
this commit replaces many uses of np.clip from operating on scalars to
using clip_scalar instead
2021-04-23 11:53:00 -07:00
Ogi Moore 85c726e49a Replace uses of np.log on scalers with math.log 2021-04-23 11:53:00 -07:00
Ogi Moore f8cefa6284 Use hypot method to avoid over/underflow errors
Use hypot instead of manual calculation
2021-04-23 11:53:00 -07:00
Ogi Moore b0a3849960 Use math module methods for singular values
Using numpy methods that are intended for vectorized operations is
substantially slower than using the math module, so when feasible the
math module methods should be used.
2021-04-23 11:53:00 -07:00
KIU Shueng Chuan fbc86cd2c5 use Format_RGB32 when using QImage as paint device
this allows sub-pixel font antialiasing to take place.
2021-04-23 18:54:21 +08:00
Ogi Moore a9161e0794
Merge pull request #1735 from pijyoi/fix_dpr
unify _dpiRatio() and devicePixelRatio()
2021-04-22 09:52:09 -07:00
KIU Shueng Chuan 51871cd01e be hidpi-aware for remote rendering 2021-04-22 17:26:46 +08:00
KIU Shueng Chuan f4ed46773f unify _dpiRatio() and devicePixelRatio() 2021-04-22 11:51:10 +08:00
Martin Chase d531a808e1
allow gradient position to be configured on a histogram (#1729)
* NEW features for HistgramLUTItem

* gradientPosition=('left', 'right')
* only paint if item is visible (is faster)
* link hisogram to other histograms

* fixes to be able to merge

 * drop linkHistogram (rgba needs to be better integrated)
 * make sure defaults to same as current behavior
 * draw connecting lines correctly on each side
 * add example use
2021-04-20 19:57:15 -07:00
Nils Nemitz a6f9a2be12
ColorMap: keep RGBA values as uint8, clean up docstrings (#1722)
* keep RGBA values as uint8, clean up docstrings

* ColorMap docstring correction

* enum mapping fix 2
2021-04-19 23:03:44 -07:00
Nils Nemitz 515ae5f6e3 add axisOrder='col-major' 2021-04-17 18:18:14 +09:00
Ogi Moore 342fbb053f Avoid implicit int conversion for mouse buttons 2021-04-15 22:50:50 -07:00
Ogi Moore 52de9554bb Emit warning about pyside2 bug preventing loading 2021-04-15 22:50:16 -07:00
Ogi Moore 5c67f03b0e skip test without generating warning 2021-04-15 21:02:49 -07:00
Ogi Moore 314e4eb480 Unescaped sequence and fix typo 2021-04-15 21:02:29 -07:00
Martin Chase 6fed6d42b3
Protect makeARGB with tests and benchmarks (#1697)
* update to working

* cupy tests, too

* doubling up and down

* add more realism to the benchmarks

* name to reflect scale

* use different numbers to mean different numbers

(that sure does sound tautological)

* more sensible: order, error

* thorough check of lots of makeARGB arg combos

* docstring for tool usage

* no print needed

* better error messages

* test makeARGB using cupy, too

* skip without cupy available

* switch from conda to venv

* skip cupy runs when not available

* use endian-proof makeARGB shim in tests

* generate the asv conf to suit the system

* document running asv

* comments for future matrix goals

* put all makeARGB tests together; name for clarity

* subprocess.check_output is standard for all supported pythons

* better handle lack of git version

* use makeARGB shim

* small fixes and improvements
2021-04-15 15:51:21 -07:00
Martin Chase a465f93d9b
small TargetItem fixes (#1715)
* angle is just an int, not a method

* more TargetItem use in the example

* offset is needed before super sometimes

* use setLabel, too
2021-04-14 10:44:03 -07:00
Christopher Mullins 10c1e83cd7 Expose the `clickable` property of `PlotDataItem`. (#519)
* Fix the `clickable` property of `PlotDataItem`.

Currently if you attempt to set the `clickable` property of a PlotDataItem,
this property is silently ignored. The expected behavior is to set the
`clickable` property of the underlying PlotCurveItem.

* Use setCurvesClickable and curvesClickable instead

* curve is singular
2021-04-13 22:31:26 -07:00
Ogi Moore 5a08650853
Improve target item - incorporate bits from PR 313 (#1318)
Overhaul TargetItem based on @lesauxvi 's PR #313
2021-04-10 22:42:44 -07:00
Ogi Moore bb90ef1ec9
Merge pull request #1707 from pijyoi/pyqt61_compat
add PyQt6 6.1 forwards compatibility
2021-04-10 20:27:04 -07:00
KIU Shueng Chuan 2aed5c36d5 no need to reconstruct PyQt6 enums
PyQt6 can serialize / deserialize enums and flags w/o us manually
casting them to int.

In PyQt6 6.0, it was okay to pass the already deserialized flag
back to the class constructor.
In PyQt6 6.1, the flags MouseButtons and KeyboardModifiers have
been renamed to MouseButton and KeyboardModifier respectively.

skipping the reconstruction allows it to work on both PyQt6 6.0 and 6.1.
note that this was already done in deserialize_mouse_event()
2021-04-11 09:53:49 +08:00
KIU Shueng Chuan 64702981d4 temporarily let PyQt6 6.1 run on PyQt6 6.0 ui files 2021-04-11 09:02:58 +08:00
KIU Shueng Chuan 4699bbad6b fix keyboard modifiers default value 2021-04-11 09:00:52 +08: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
Martin Chase 0f94c17d86
Fix roi get array region (#1700)
* ROI.py, getArrayRegion: Fix return mapped coordinates

The *getArrayRegion* method is defined as returning a tuple of the points
in the selected region and the mapped coordinates if the
*returnMappedCoords* keyword argument is set to True in the parent class
*ROI*.

In the *EllipseROI* class, *getArrayRegion* was overriden, however it
ignores the *returnMappedCoords* keyword argument, leading to unintended
bugs because of the change in interface between the parent class and
the subclass.

This patch fixes the above bug.
If *returnMappedCoords* is set to False, then only *arr* containing the
array region is returned. If *returnMappedCoords* is set to True, a
tuple of the array region and the mapped coordinates is returned.

NB: At the time of this commit, the same bug is present in several classes
extending *ROI*. This commit only fixes the issue for the *EllipseROI* class.

* ROI.py, PolyLineROI.getArrayRegion: Fix return mapped coordinats

The *getArrayRegion* method is defined as returning a tuple of the
points in the selected region and the mapped coordinates if the
*returnMappedCoords* keyword argument is set to True in the parent class
*ROI*.

In the *PolyLineROI* class, *getArrayRegion* was overriden, however it
ignores the *returnMappedCoords* keyword argument, leading to unintended
bugs because of the change in interface between the parent class and the
subclass.

This patch fixes the above bug.  If *returnMappedCoords* is set to
False, then only *arr* containing the array region is returned. If
*returnMappedCoords* is set to True, a tuple of the array region and the
mapped coordinates is returned.

* remove merge conflict cruft

* lint

Co-authored-by: Malik Olivier Boussejra <malik@boussejra.com>
2021-04-08 13:43:30 -07:00
Kyle Sunden 711ad8afaa
Merge pull request #1696 from j9ac9k/0.12.1-changelog
Add changelog for 0.12.1
2021-04-06 20:52:46 -05:00
Kyle Sunden 03b7aa7860
Update version number for release 2021-04-06 20:41:32 -05:00
Ogi Moore 3ed206fa70
Merge pull request #1690 from ntjess/master
revert to old behavior: default created from value if not present
2021-04-06 13:07:10 -07:00
Ogi Moore d4c5025289 Implement suggested changes from ixjlyons 2021-04-06 11:51:10 -07: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
Nils Nemitz 758c038411
Add ColorBarItem for simplified image level adjustment (#1596)
* Initial implementation of ColorBarItem

* initial commit

* fixed missing indent

* docstring extension and corrections

* Converted example to match others / run as part of tests

* load local color maps instead of importing from colorcet

* clean up window creation code

* horizontal color bar and clean-up

* switched to mkQApp initialization

* cleaned up some comments
2021-04-05 20:50:52 -07:00
Nils Nemitz 929f3bda0d
make sure dynamic range limiter runs even when there isn't previous data (#1691) 2021-04-05 15:46:28 -07:00
Dennis Göries b8cf3dded4
DateAxisItem: Account for daylight saving time (#1694)
* DateAxisItem: Account for daylight saving time

* Use  logic more visible in utcoffset

* Rename getOffsetFromUtc function
2021-04-05 15:45:08 -07:00
Nathan Jessurun 58d126dcf3 fixes tests 2021-04-03 20:31:04 -04:00
Nathan Jessurun 4b002c06ba revert to old behavior: default created from value if not present 2021-04-03 17:07:02 -04:00
KIU Shueng Chuan 02a48afc60 test_makeARGB() : normalize to B,G,R,A 2021-04-01 08:38:10 +08:00
KIU Shueng Chuan 17e2f0f5f2 fix makeARGB() endian ordering 2021-04-01 08:38:08 +08:00
KIU Shueng Chuan 179b27ad8c image_testing.py: swap red and blue channels 2021-04-01 08:32:31 +08:00
Ogi Moore 4dc76ed90e
Merge pull request #1617 from pijyoi/fastpath_argb
Optimize makeARGB for ubyte images
2021-03-26 14:22:56 -07:00
Ogi Moore 1a597b80b7
Merge pull request #1662 from NilsNemitz/cast-to-int_in_ImageView_QSplitter.setSizes
added cast to int so that QSplitter.setSizes works on Python 3.10
2021-03-26 12:39:38 -07:00
Nils Nemitz 028f9d12a2 cast splitter settings to int in Canvas.py 2021-03-27 04:30:51 +09:00
Ogi Moore 21605faa44
Merge pull request #1666 from NilsNemitz/revert_styleUpdate_reduction
revert style change reduction in PlotDataItem
2021-03-26 12:12:41 -07:00
Nils Nemitz d8d5d49f04 revert style change reduction in PlotDataItem 2021-03-27 03:51:44 +09:00
Daniel Lidstrom fb3a8b62bd Don't pass brush to fn.mkPen 2021-03-26 11:36:30 -07:00
Nils Nemitz 2b1e24bf11 added cast to int 2021-03-26 18:47:38 +09:00
KIU Shueng Chuan b3dc090373 implement fastpath for makeARGB 2021-03-26 04:07:19 +08:00
Kyle Sunden 43532aa802 Post release 0.12.0 2021-03-25 14:25:30 -05:00
Kyle Sunden d2a1bcf920 Update version to 0.12.0 2021-03-25 14:04:14 -05:00
Ogi Moore 3b620836c4
Merge pull request #1651 from j9ac9k/Use_collections.abc
collections.abc not just collections
2021-03-23 11:56:02 -07:00
Nils Nemitz 954c7342dd
Fix to accidentally disabled style updates in PlotDataItem (#1653)
* allowed style updates to once again update the style of curve and scatter plot, added tests

* tests interleave assign and assert to guard against delayed assignment

* > > > now 100% more camels < < <
2021-03-23 11:54:15 -07: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
Ogi Moore 5b278855d6 Switch to camelCase functions 2021-03-23 11:07:19 -07:00
Ogi Moore 675516e0b1 collections.abc not just collections 2021-03-22 22:17:28 -07:00
Ogi Moore 4951bd743e
Replace main stanza with PyQt6 compatable variant (#1645)
* Replace main stanza with PyQt6 compatable variant

* Use fn.mkQApp instead

* remove needless comments
2021-03-22 11:17:12 -07:00
Ogi Moore 69be66699a
Merge pull request #1650 from NilsNemitz/add_clip_scalar_function
Do not use clip_array on scalars (use clip_scalar instead)
2021-03-22 11:16:50 -07:00
Ogi Moore 517d243166
Remove unhelpful warnings (#1646)
* Remove warning about existing QApplication

* Remove reference to weave which we do not use

* Do away with opengl warning

* Remove weaveDebug config option
2021-03-22 11:12:01 -07:00
Nils Nemitz 2c82a84f68 Do not use clip_array on scalars (use clip_scalar instead) 2021-03-23 01:08:31 +09:00
Nils Nemitz a1eca4e2dd
handle empty adjanceny array (#1647) 2021-03-21 21:14:19 -07: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
Nils Nemitz d0f5a6686f
PlotDataItem: Fix view range <-> dynamic range limit pathology and switch to np.umath.clip (#1637)
* 'no offscreen clip' optimization and switch to np.umath.clip

* swapped out clipping code for new functions.array_clip
2021-03-20 22:16:15 -07:00
Nils Nemitz 574c2d24f2
Stop PlotDataItem from always sending full style information to PlotCurveItem / ScatterPlotItem (#1619)
* skip unneded style updates in PlotDataItem

* removed unwanted file

* obliviated stray debug statement
2021-03-19 22:54:53 -07:00
Nils Nemitz 5fa3901c00
Fix transformations in GradientLegend (#1639)
* rebuilt transformations

* restored drawing order to bg > bar > labels (and removed some print statements)
2021-03-19 22:06:18 -07:00
KIU Shueng Chuan 8d74dfe11b refactor code to replace np.clip 2021-03-20 08:09:29 +08:00
Ogi Moore 3f9e56f62e
Merge pull request #1630 from pijyoi/lut_combine
combine levels and lut only if both are present
2021-03-14 08:58:19 -07:00
KIU Shueng Chuan 56b54344e2 workaround np.clip regression since numpy 1.17 2021-03-14 16:01:29 +08:00
KIU Shueng Chuan 5df14aec1d combine levels and lut only if both are present
previously, if levels was present but lut was not, levels would be
converted into lut.
2021-03-13 16:27:20 +08:00
Ogi Moore c5a1174f04
Merge pull request #1605 from pijyoi/clean_shutdown
let examples have a chance to exit normally
2021-03-06 20:18:50 -08:00
KIU Shueng Chuan df64be371a remove PySide from _loadUiType()
bug:
- QT_LIB == "PYSIDE" should have been QT_LIB == PYSIDE
2021-03-03 10:44:23 +08:00
KIU Shueng Chuan 30a64d5f81 Qt.py : remove Qt4 2021-03-03 10:44:23 +08:00
KIU Shueng Chuan d82f28d390 install sys excepthook for PyQt6 2021-03-03 09:42:16 +08:00
Ogi Moore fb6ae0ff2c
Merge pull request #1613 from chrismullins/parameter-unpacking
Add keys() method to Parameter class
2021-03-02 11:05:47 -08:00
Kiu Shueng Chuan 5f6be29f66 connect paletteChanged to standalone function 2021-03-02 05:57:17 +08:00
Chris Mullins 9ed51cd1e2 Add keys() method to Parameter class
This returns the names attribute, allowing **unpacking of Parameter subclasses.
2021-02-28 03:00:19 +00:00
Ogi Moore cd73aeed0e
Merge pull request #1598 from outofculture/selfless-lambdas
Remove references to self from lambdas
2021-02-23 09:40:57 -08:00
KIU Shueng Chuan 61616ffad9 remove calls to setGraphicsSystem
in fact all are no-ops
2021-02-22 19:17:53 +08:00
Martin af82858bc8 make these tiny methods with little excuse to exist private 2021-02-21 22:31:13 -08:00
Martin 68fa95686b fix typo 2021-02-21 07:05:24 -08:00
Martin 7f4f677ce1 lambdas which reference self prevent GC 2021-02-21 06:49:07 -08:00
KIU Shueng Chuan 0dc17ef546 RawImageGLWidget follow same style as RawImageWidget
i.e. row-major convention is used internally and user inputs are
converted at the point of entry.
2021-02-20 18:58:26 +08:00
KIU Shueng Chuan 5a29373572 fix: make transpose work for either ndim 2 or 3
at the same time, increase performance by using
makeQImage(copy=False, transpose=False)
2021-02-20 18:42:13 +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
Martin b7e560a7ea fix imports
* metaarray is not used
* PlotCurveItem and ScatterPlotItem needed to be imported
* sort
2021-02-19 11:33:06 -08:00
Martin b9086f1023 no "i" variable anymore 2021-02-19 11:11:38 -08:00
Ogi Moore d9eb8e1afb
Merge pull request #1575 from pijyoi/reduce_shim
Reduce number of shims for PyQt6
2021-02-19 09:40:06 -08:00
Rafael Irgolic 6da60ccec8 Qt: Remove some Qt4 shims 2021-02-18 19:12:32 +00:00
Rafael Irgolic ae54e27ff6 app.dark_mode => app.property('darkMode') 2021-02-18 19:02:18 +00:00
Ogi Moore 765032fc0b Do not upload texture every paintGL call 2021-02-16 22:19:38 -08:00
Ogi Moore 0b26ef3644 RawImageWidget uses imageAxisOrder config option 2021-02-16 22:19:13 -08:00
KIU Shueng Chuan 2719922584 RawImageWidget.py : fix port to QOpenGLWidget
Qt5 docs specify differences between QGLWidget and QOpenGLWidget:
"...when invoking paintGL().
 QOpenGLWidget sets up the viewport via glViewport().
 It does not perform any clearing."
2021-02-16 09:15:37 +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
Martin Chase 5210c55e67
Equilateral Triangle ROI (#1581)
* feature TriangleROI

Added equilateral  TriangleROI.
getArrayRegion is not working yet

* show off (and implicitly test) our new TriangleROI

* the PolyLineROI.getArrayRegion can be used by TriangleROI

refactor the actual logic to live on ROI

* refactors for readability

* variable names
* lint
* docstring type and purpose

Co-authored-by: Fekete Imre <feketeimre87@gmail.com>
2021-02-15 06:06:55 -08:00
Ogi Moore 825286066a only cast to float32 when safe to do so 2021-02-14 17:43:32 -08:00
Ogi Moore 4ac8e39aea Remove duplicate import and remove whitespace 2021-02-14 12:05:22 -08:00
Ogi Moore 5bfe8d5a46
Merge pull request #1572 from outofculture/arbitrary-scale-center
Arbitrary scale center ROI
2021-02-14 08:49:03 -08:00
KIU Shueng Chuan a1f9100ef1 shim only the keys we actually use 2021-02-14 07:56:05 +08:00
KIU Shueng Chuan 6ad1d752fe use QKeySequence to detect platform dependent copy keys 2021-02-14 07:46:20 +08:00
KIU Shueng Chuan 968286a1cf remove drag and drop shims
used only in one place in the codebase
2021-02-14 07:44:00 +08:00
KIU Shueng Chuan f4d685f7bd remove QDialog.exec_ shim
only used by PrinterExport.py which is currently disabled
2021-02-14 07:36:41 +08:00
Ogi Moore 6c5c0b590f Skip test_reload on python 3.10+ 2021-02-13 10:57:38 -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
Ogi Moore 955f1c37a6 Use QPointF instead of QPoint for float input 2021-02-13 10:57:38 -08:00
Ogi Moore fc550aab86 keep testing deprecated objects, catch warnings 2021-02-12 13:08:00 -08:00
Ogi Moore 36d89fa3a5 Have test_PlotCurveItem use GraphicsLayoutWidget and not the deprecated GraphicsWindow 2021-02-12 13:08:00 -08:00
Ogi Moore d14a90112c Have test_svg use GraphicsLayoutWidget not the Deprecated GraphicsWindow 2021-02-12 13:08:00 -08:00
Ogi Moore 4fcea2762f Have NonUniformImage test use GraphicsLayoutWidget not deprecated GraphicsWindow 2021-02-12 13:08:00 -08:00
Ogi Moore 45329aac51 Remove unneeded pytest.skipif decorator 2021-02-12 13:08:00 -08:00
Ogi Moore b45386ebc5 Have __init__.plot() use PlotWidget, not deprecated PlotWindow 2021-02-12 13:08:00 -08:00
Ogi Moore ff71b6be6b Add actual deprecation warnings 2021-02-11 21:34:02 -08:00
Ogi Moore bd548e00c9 Restore shimmed Qt4 methods, with deprecation warnings 2021-02-11 20:06:38 -08:00
lidstrom83 d7668f91b3
Fix ScatterPlotItem performance regression (#1569)
* Fix ScatterPlotItem performance regression

* Add hover benchmark to ScatterPlotSpeedTest.py

* Removed a performance regression from GraphicsView

* Removed some tests failing due to the last commit
2021-02-11 08:36:52 -08:00
KIU Shueng Chuan 659392d4bb don't rely on QImage being non-const
the previous formulation creates an ndarray and then creates an QImage
over it w/o copying. this relies on the QImage thus created being
non-const.

if the QImage was (unintentionally) created as const, the subsequent
QPainter render on the const QImage would trigger a COW. i.e. the
original underlying ndarray wouldn't be updated.

this is only an issue for PyQt bindings where const QImages can be
created.
2021-02-11 10:38:19 +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
Kyle Sunden 17b1b82ae9 Handle case of 0-d array in infinite line setPos 2021-02-10 13:59:37 -06:00