Skip to content

Fix recarray support in PlotDataItem#3278

Merged
j9ac9k merged 2 commits intopyqtgraph:masterfrom
ixjlyons:pdi-recarray
Mar 21, 2025
Merged

Fix recarray support in PlotDataItem#3278
j9ac9k merged 2 commits intopyqtgraph:masterfrom
ixjlyons:pdi-recarray

Conversation

@ixjlyons
Copy link
Copy Markdown
Member

@ixjlyons ixjlyons commented Mar 8, 2025

Fixes #3275

I'm not sure if this ever worked. As far as I know, recarray hasn't supported this kind of membership check, and it doesn't make sense semantically for normal ndarray.

During my testing, I figured normal arrays with named fields might also be worth supporting. The dataType helper function identifies them as "recarray", so the modified code path handles both. Only the recarray subclass implements attribute access to the fields, otherwise getattr(data, "x", None) would've been slightly more concise.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Mar 9, 2025

I think I came across this not working when doing the documentation for PlotDataItem a while back... I don't have a particularly strong opinion about whether or not PlotDataItem should accept recarray or not, but I am of the opinion that setData accepts data in way too many formats, and we should start deprecating some of the more weird ones (or at the very least, having tests to test all the supported input cases).

I'm trying to think of a good argument for why recarray should be supported that doesn't involve "well, it isn't that much code". Is there a functionality that is unlocked by supporting it.

@ixjlyons
Copy link
Copy Markdown
Member Author

ixjlyons commented Mar 9, 2025

I'm trying to think of a good argument for why recarray should be supported that doesn't involve "well, it isn't that much code". Is there a functionality that is unlocked by supporting it.

@hjholmberg care to weigh in on this?

@hjholmberg
Copy link
Copy Markdown

I was using recarray as a convenient way to store extra information for each data point. I have no particular reason for supporting it because (as pijyoi said) it's very easy to just pass in data.x and data.y instead.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Mar 21, 2025

Merging as this fixes an issue that we have in our documentation as working (but doesn't). The discussion about whether we should support this is for another time. Thanks for the report @hjholmberg and thanks for the fix @ixjlyons

@j9ac9k j9ac9k merged commit a5ff89e into pyqtgraph:master Mar 21, 2025
36 checks passed
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.

TypeError when using a record array to plot data

4 participants