Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow arbitrary transforms #2326

Draft
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

outofculture
Copy link
Contributor

This PR refactors the existing data transforms (derivative, fft, log, etc.) into a generic data transform API. The old methods are deprecated with no set date to allow for adequate testing of the new architecture.

Included are also 2 examples of more complicated transforms which take parameters.

also add beginnings of docs
necesitates moving some PlotDataItem tests into the PlotItem tests, sorta
Conflicts:
	pyqtgraph/graphicsItems/PlotDataItem.py - unrelated additions and modifications at the same lines
DeprecationWarning, stacklevel=2
)
if state:
from .PlotItem.PlotItem import _fourierTransform

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
pyqtgraph.graphicsItems.PlotItem.PlotItem
begins an import cycle.
pyqtgraph/graphicsItems/PlotDataItem.py Dismissed Show dismissed Hide dismissed
pyqtgraph/graphicsItems/PlotDataItem.py Dismissed Show dismissed Hide dismissed
pyqtgraph/graphicsItems/PlotDataItem.py Dismissed Show dismissed Hide dismissed
pyqtgraph/graphicsItems/PlotDataItem.py Dismissed Show dismissed Hide dismissed
'fftMode': False,
'logMode': [False, False],
'derivativeMode': False,
'phasemapMode': False,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These opts might be something users depend on? I hope not. Deprecating these would be tricky.

check.toggled.connect(self._handleDataTransformChecked)
check.toggled.emit(False) # registers with all the data items and axes

# :MC: removeDataTransformOption was left unimplemented. Here are the concerns it will need to cover:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most glaring shortcoming of this PR; it feels like removing transform options from a particular plot is something users are going to want to do. That said, the notes about why it wasn't included do make for a good starting point if someone decides to add this as a feature later.

PlotItem.addDefaultDataTransformOption(
translate("Form", "dy/dx"),
_diff,
order=60,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ordering mechanism is a bit sloppy. I wish I had a better idea for it.

Conflicts:
	pyqtgraph/graphicsItems/PlotItem/PlotItem.py - imports
	pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt5.py - rm v. modify
	pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside2.py - rm v. modify
	pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside6.py - rm v. modify
@outofculture outofculture marked this pull request as draft October 1, 2022 18:57
@outofculture
Copy link
Contributor Author

I'm setting this aside while we work on a new architecture to better handle non-linear transforms

@@ -6,7 +6,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from ..Qt import QtCore, QtGui, QtWidgets

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'QtGui' is not used.
@@ -6,7 +6,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from ..Qt import QtCore, QtGui, QtWidgets

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'QtGui' is not used.

import pyqtgraph as pg
from pyqtgraph.graphicsItems.ScatterPlotItem import name_list
from pyqtgraph.Qt import QtWidgets, QtCore

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'QtCore' is not used.
# this is a shallow copy
return self._objs[:self._size]

def drawargs(self):

Check notice

Code scanning / CodeQL

Returning tuples with varying lengths Note

PrimitiveArray.drawargs returns
tuple of size 1
and
tuple of size 2
.
profiler = debug.Profiler()

if options is None:
options = {}

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable options is not used.
Comment on lines 258 to 259
# if hasattr(item, 'setExportMode'):
# item.setExportMode(False)

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
@j9ac9k
Copy link
Member

j9ac9k commented Apr 2, 2024

oof, that's quite the git mess 😬

Conflicts:
	pyqtgraph/graphicsItems/PlotDataItem.py - how nonfinite is handled
	pyqtgraph/graphicsItems/PlotItem/PlotItem.py - boring conflicts
	pyqtgraph/parametertree/Parameter.py - boring conflicts
	tests/graphicsItems/test_PlotDataItem.py - deleted test on nonfinites that I got working
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants