* 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>
this lets us support the various bindings w/o having to add binding
specific code.
it breaks PyQt4 support since PyQt4 template files are suffixed as
"_pyqt" rather than "_pyqt4"
QFont.setBold(True) calls QFont.setWeight(QFont.Weight.Bold)
in Qt 5, QFont.Weight.Bold == 75
in Qt 6, QFont.Weight.Bold == 700
in PySide6, QFont.setWeight() no longer accepts an integer value.
* extend ColorMap functionality for palette management
* manual merge with changes in master branch
* extend ColorMap functionality for palette management
* manual merge with changes in master branch
* light mode / dark mode swapping demo
* color map updates
* added ColorCET and Matplotlib import for color maps
* minor cleanup
* restored lost indent
* Code cleanup
* Add colorcet as optional dependency
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
* LegendItem: Introduce itemStyles and provide ToggleItem
Show example
* Minor cleanup of the legend item and test
* Make ItemSample customizable
* Remove example modifications
* Changes for sampleType according to review
* Added hovering demo to ScatterPlot example
* Use Qt's serialization for SymbolAtlas.symbolMap keys
Yields significant performance improvements when updating the scatter plot's options. See e.g. the plot hover example.
* Further optimized scatter plot picking
* Fix ScatterPlot example tool tip
* Clean up while I'm here
* Compatibility
* Some simple optimizations for ScatterPlotItem
Speedups for ScatterPlotSpeedTest.py:
~50% without pxMode
~ 0% pxMode with useCache
~30% pxMode without useCache
* ~3x speedup in scatter plot speed test with pxMode
* More optimization low-hanging fruit for the scatter plot
* Removed hover example to lazily pass tests
* Avoid segfault
* Re-add hover example to ScatterPlot.py
* Switch to id-based keying for scatter plot symbol atlas
- Use cases exist where serialization-based keying is a significant bottleneck, e.g. updating without atlas invalidation when a large variety pens or brushes are present.
- To avoid a performance hit, the onus is on the user to carefully reuse pen and brush objects.
* Optimized caching in scatter plot hovering example
* Fixed and optimized scatter plot hovering example
* Minor scatter plot optimization
* Cleanup
* Store hovered points in a set for the hovering example
* Keep a limited number symbol atlas entries around for future reuse
* Added a docstring note to remind the user to reuse QPen and QBrush objects for better performance
* Tidied up hovering example
* Typo
* Avoid unnecessary atlas rebuilds
* Refactored SymbolAtlas
* Efficient appending to SymbolAtlas
* SymbolAtlas rewrite
* Cleanup and profiling
* Add randomized brushes to speed test
* Add loc indexer to ScatterPlotItem
* Profile ScatterPlotItem.paint to identify bottlenecks
* Reuse targetRect to improve paint performance
* Readability improvements (opinionated)
* Only need to set x and y of targetRect
- w and h can stay set to 0 (not entirely sure why)
- this is a bit faster than setting all of x, y, w, h
* Minor renaming
* Strip off API changes and leave to another PR
* Renaming
* Compatibility
* Use drawPixmap(x, y, pm, sx, sy, sw, sh) signature to avoid needing to update QRectFs
* Use different drawing approaches for each Qt binding for performance reasons
* Fix a bug introduced two commits ago
Incidentally, I think there is a similar bug in the main branch currently.
* Minor performance and readability improvements
* Strip out source and target QRectF stuff
* Bring source and target QRectF stuff back in a less coupled way
* Leave deprecating getSpotOpts for another PR
* Compatibility fix
* Added docstrings and use SymbolAtlas__len__ where possible
* Fix export issue
* Add missing import
* Add deprecation warnings
* Avoid using deprecated methods
* Fix and cleanup max spot size measurements
* Make creation of style opts entries explicit
* Add hovering API to ScatterPlotItem
* Compatibility
* Marshal pen and brush lists in setPen and setBrush
* Fixed platform dependent bug
* Fix TickSliderItem: Avoid ghost ticks | Improved customPlot.py code
If `TickSliderItem.setTickValue` was called when a full repaint of the `TickSliderItem` was
not already scheduled, the tick was visible at the old and the new position. This could e.g. be seen
when using the autoscale button in the `customPlot.py` example.
Further, code from `customPlot.py` is improved to make use of `Tick.setVisible` instead of adding and
removing ticks based on their visibility.
* customPlot.py: Explain bool conversion
Co-authored-by: 2xB <2xB@users.noreply.github.com>
* Fix examples\customPlot.py: Not object-oriented
Copy-paste error: I referenced a specific object instead of self. Fixed.
* Fix examples\customPlot.py: Allow calling setTicks more than once
This fixes a bug where TickSliderItem is expected to return ticks.keys() but while it returns ticks.items().
Also: Minor code correction.
* Fix examples\customPlot.py: Avoid scaling differences
Consider padding of TickSliderItem for link between ViewBox and ticks
Co-authored-by: 2xB <2xB@users.noreply.github.com>
* TickSliderItem: allowRemove property added
Following #744, this PR suggests the addition of a property
`allowRemove` to `TickSliderItem` and therefore also to
`GradientEditorItem`. It sets the default of whether ticks can
be removed by the user and therefore contemplates `allowAdd`.
I would be interested in other opinions on this design decision,
as #744 suggests to reuse `allowAdd` for the prohibition of
tick removal.
I personally suggest this solution, since it does not change
the effect of the current API.
Fix#744
* customPlot.py: Added markers to example using TickSliderItem
* examples\GradientWidget.py: Demonstrate use of allowRemove
Co-authored-by: 2xB <2xB@users.noreply.github.com>
* Fix examples/customPlot.py: mouseDragEvent misses axis argument
Fixes#1277
* customPlot.py: Update methodolgy to disable menu
If there's an argument for this, we should use it
* customPlot.py: Show how to disable axis interaction
* Fix ViewBox: Moving axis in RectMode not implemented => use normal move mode
Grabbing an axis in RectMode leads to the zoom rectangle being displayed
in unreasonable positions. In this case, fall back to normal mode.
* customPlot.py: Only disable right-click zoom for demonstration
In cases where continuous zooming is not wished (e.g. in case of
complicated rebinning after zooming), this might come in handy
and there is no reason not to show it.
Co-authored-by: 2xB <2xB@users.noreply.github.com>
* 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
* example app now workw with Qt4 and Python2 again
* Example App is now part of the test suite
* Add initExample
* No scary warning when launching examples
* Fix scary examples.__main__ warning
* Use courier new font as its on all platforms
* Remove commented out code
* Add newline
* Updated docs, example app now tested
* Non-relative import for example app
* Proper importing now
* Add "lstep" and "rstep" step Modes
stepMode is currently either True or False. If it is True,
it requires the user to make len(x) = len(y)+1. This is
inconvenient because it makes it difficult to change the
stepMode on a given curve (just as one would change, e.g.,
its color).
This commit extends the current situation by introducing
two more step modes: "lstep" and "rstep", which do not require
passing an extra x value. In turn, this modes associate each
y value to either the left or the right boundary of the step.
For example, the "rstep" mode is handy when plotting "life"
digital signals in which x,y data pairs are appended as they
are read.
This commit does not modify the behaviour in case of stepMode=True
* Replace step mode names: lstep,rstep -> left,right
* Improve docs for stepMode
Reword docstring and add it to PlotDataItem class too
* Document left and right stepModes as added in v 0.12.0
TODO: confirm the exact version number to use here
* Add comments stress the need for "is True"
Some conditional statements in the code regarding stepMode are
done with "is True". This is actually required since other
possible values such as "left" also evaluate as true but should
not be caught.
* Deprecate boolean API for stepMode
Introduce stepMode="mid" as a replacement of stepMode=True,
but keeping full backwards compatibility with the old API.
Adapt docs, examples and tests accordingly.
* Raise ValueError on unsupported stepMode values
* Rename "mid" step mode to "center"
* Remove "added in 0.12.0" note
See https://github.com/pyqtgraph/pyqtgraph/pull/1360#discussion_r502746919
* Add deprecation warning when stepMode=True
Issue a DeprecationWarning if stepMode=True is being passed to the
constructor or setData() of PlotDataItem or PlotCurveItem.
Note: warnings module is imported locally so that it is esier to
remove once this check is no longer needed.
* Fix wrong syntax in last commit
Fix usage of "default" kwarg in dict.get()
DeprecationWarning is for invalid escape sequence ('\'). Decided to use
raw strings rather than double-backslashes because the text processing
is using raw strings anwyay.
* NEW options for LegendItem
* * changed 'drawFrame' into 'frame'
* added **kwargs to plotItem.addLegend
* added (frame=False, colCount=2) in legend example
* more elegant solution for legend.getLabel
* repaired getLabel
ItemSample.item == plotitem
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
* Added arrow symbols for the ScatterPlotItem
* Fixed arrows rotation in scatter plots
* Added new symbols to example
Co-authored-by: Miguel Sánchez de León Peque <msdeleonpeque@gmail.com>
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>
* Do not wrap PlotView/ImageView
There is no need to wrap PlotView/ImageView into QMainWindow, since
only purpose of the QMainWindow is some default menu toolbar & menu
handling, that is not used by PyQtGraph anyway.
Moreover, every parent-less Qt widget can become window, so this
change just use PlotView/ImageView as windows, removing extra
complexity, eg. method forwarding, self.win property.
Another benefit of this change, it that these windows get initial
dimensions and titles as they were designed in .ui file.
* Properly cleanup on ImageView.close()
We should not close explicitly child widgets or clear scene, otherwise
Qt will deallocate children views, and cause "wrapped C/C++ object of
type ImageItem has been deleted" error next time we call close()
and/or some other methods.
All children, including self.ui.roiPlot, self.ui.graphicsView will be
closed together with its parent, so there is no need to close them
explicitly.
So the purpose of close it to reclaim the memory, but not to make the existing ImageView object dysfunctional.
* Remove references to plot & image windows after close
PyQtGraph images and plots module list variables are currently holding
references to all plots and image windows returned directly from main
module. This does not seem to be documented however, and causes the Qt
windows to be not released from memory, even if user releases all own
references.
This change removes the references from images/plots list once window
is closed, so when there is no other reference, window and all related
memory is reclaimed.
* Change all UI forms title from Form to PyQtGraph
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
* Add DateAxisItem
* Change style to camelCase
* Fix missing first tick for negative timestamps
* Add ms precision, auto skipping
Auto skipping allows a zoom level to skip ticks automatically if the
maximum number of ticks/pt is exceeded
* fixes suggested by @goetzc
* workaround for negative argument to utcfromtimestamp on windows
* attachToPlotItem method
* default date axis orientation
* Use new DateAxisItem in Plot Customization example
* attachToPlotItem bugfix
* examples of DateAxisItem
* modified description of customPlot example
* added descriptions to the new examples, reformatted their code, included the first one into utils.py
* typo
* Refactored code for setting axis items into new function
Replaces "DateAxisItem.attachToPlotItem"
* Fix string comparison with ==
* Doc: Slightly more text for DateAxisItem, small improvement for PlotItem
* Make PlotWidget.setAxisItems official
* Fix typo in docstring
* renamed an example
* merge bug fix
* Revert "merge bug fix"
This reverts commit 876b5a7cdb.
* Real bug fix
* support for dates upto -1e13..1e13
* Automatically limit DateAxisItem to a range from -1e12 to 1e12 years
Very large years (|y|>1e13) cause infinite loop, and since nobody
needs time 100 times larger than the age of the universe anyways,
this constrains it to 1e12.
Following suggestion by @axil:
https://github.com/pyqtgraph/pyqtgraph/pull/1154#issuecomment-612662168
* Also catch ValueErrors occuring on Linux before OverfloeErrors
While zooming out, before hitting OverflowErrors, utctimestamp
produces ValueErrors (at least on my Linux machine), so they
are also catched.
* Fix: Timestamp 0 corresponds to year 1970
For large years, x axis labels jump by 1970 years if it is not
accounted for timestamp 0 to be equal to year 1970.
* Fix: When zooming into extreme dates, OSError occurs
This commit catches the OSError like the other observed errors
* Disable stepping below years for dates outside *_REGULAR_TIMESTAMP
2 reasons: First: At least on my Linux machine, zooming into
those dates creates infinite loops. Second: Nobody needs
sub-year-precision for those extreme years anyways.
* Adapt zoom level sizes based on current font size and screen resolution
This is somewhat experimental. With this commit, no longer 60 px are
assumed as width for all zoom levels, but the current font and
display resolution are considered to calculate the width of ticks in
each zoom level. See the new function `updateZoomLevels` for
details.
Before calling this function, overridden functions `paint` and
`generateDrawSpecs` provide information over the current display
and font via `self.fontScaleFactor` and `self.fontMetrics`.
* Meaningful error meassage when adding axis to multiple PlotItems
As @axil noted in the DateAxisItem PR, currently users get a
segmentation fault when one tries to add an axis to multiple
PlotItems. This commit adds a meaningful RuntimeError message
for that case.
* setZoomLevelForDensity: Refactoring and calculating optimal spacing on the fly
* DateTimeAxis Fix: 1970 shows when zooming far out
* Refactoring: Make zoomLevels a customizable dict again
* updated the dateaxisitem example
* Fix: Get screen resolution in a way that also works for Qt 4
This is both a simplification in code and an improvement in backwards compatibility with Qt 4.
* DateAxisItem Fix: Also resolve time below 0.5 seconds
* unix line endings in examples
* DateTimeAxis Fix: For years < 1 and > 9999, stepping broke
Stepping was off by 1970 years for years < 1 and > 9999,
resulting in a gap in ticks visible when zooming out. Fixed by
subtracting the usual 1970 years.
* DateTimeAxis Fix: Zooming out too far causes infinite loop
Fixed by setting default limits to +/- 1e10 years. Should still
be enough.
* improved second dateaxisitem example
* 1..9999 years limit
* DateTimeAxis: Use OrderedDict to stay compatible with Python < 3-6
* DateAxisItem: Use font height to determine spacing for vertical axes
* window title
* added dateaxisitem.rst
* updated index.rst
Co-authored-by: Lukas Heiniger <lukas.heiniger@sed.ethz.ch>
Co-authored-by: Lev Maximov <lev.maximov@gmail.com>
Co-authored-by: 2xB <2xB@users.noreply.github.com>