Skip to content

convert connect='finite' to connect=ndarray#1286

Closed
pijyoi wants to merge 3 commits intopyqtgraph:masterfrom
pijyoi:fix_connect_finite
Closed

convert connect='finite' to connect=ndarray#1286
pijyoi wants to merge 3 commits intopyqtgraph:masterfrom
pijyoi:fix_connect_finite

Conversation

@pijyoi
Copy link
Copy Markdown
Contributor

@pijyoi pijyoi commented Jun 29, 2020

Qt no longer accepts non-finite values for plotting as seen here:
https://github.com/qt/qtbase/blob/f6b7b64ed0168038e365b936a1daea9b3bcda335/src/gui/painting/qpainterpath.cpp#L2537

This would prevent PlotCurveItem.setData(connect='finite') from working.

This commit converts a call using connect='finite' to the equivalent call using connect=ndarray with all the non-finite elements removed.

Related to PR #1058
Related to issue #1057

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jun 29, 2020

Thanks for the PR @pijyoi

From a glance, it looks like this PR would actually implement what PR #1058 is trying to achieve?

@pijyoi
Copy link
Copy Markdown
Contributor Author

pijyoi commented Jun 29, 2020

It is trying to solve a smaller scope than PR #1058.
I think PR #1058 wants to allow NaNs in the plot data; whereas this PR only wants to fix it for the use-case connect='finite', where NaNs / Infs are delimiters and not part of the plot data.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jun 29, 2020

Looks like in merging #1283 we created a merge conflict

@pijyoi pijyoi force-pushed the fix_connect_finite branch from 41a8022 to c0a8bd4 Compare June 29, 2020 23:56
@pijyoi
Copy link
Copy Markdown
Contributor Author

pijyoi commented Jun 30, 2020

I have rebased and also modified the code to output the new ndarray syntax required by #1283

@summoningdark
Copy link
Copy Markdown

This fixes my problem in #1057 with a slight modification. Line 1490:
connect[np.where(~msk)[0] + 1] = 0
can cause an IndexError if the last value in msk is false, since connect and msk have the same number of elements. Making connect one longer than msk, and then cutting off the last value in line 1493 seems to solve it.
connect = np.ones_like(msk) => connect = np.ones(len(msk)+1)
connect = connect[msk] => connect = connect[0:-1][msk]

@pijyoi
Copy link
Copy Markdown
Contributor Author

pijyoi commented Jul 14, 2020

@summoningdark , thanks for the fix. I have incorporated it.
It is my understanding however that PR #1287 supersedes this PR as it fixes all the connect kinds.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jul 14, 2020

@pijyoi i assigned @campagnola to these issues given he's the author of 1 of the PRs and the low level nature of these changes. Last I heard he wanted to do some performance evaluations on the proposals (iow we haven't forgotten about this PR (or the other ones), a solution with these fixes will be in the next release.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Nov 23, 2020

Hi @pijyoi with merging #1287 I believe the base issue that this PR was meant to address is now resolved. Sorry this took us so long to follow up on. I'm going to close out this PR, but if something isn't working as expected, or this PR covers a use-case that #1287 does not, let me know and I'll re-open.

@j9ac9k j9ac9k closed this Nov 23, 2020
@pijyoi pijyoi deleted the fix_connect_finite branch January 16, 2021 09:03
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.

4 participants