-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix containment and subslice optim. for steps. #6645
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
Fix containment and subslice optim. for steps. #6645
Conversation
matplotlib#6497 set the `_path` attribute of Line2D to the actually drawn path even if the drawstyle is `steps-*`; however containment tests and the subslice optimization for very long paths were not updated accordingly (see matplotlib#6615). This patch fixes the issues. Note that `contains` returns, for events in a horizontal segment of a "steps-mid" drawstyle plot, the index of the point in the segment, regardless of whether the event occured to the left or the right of that point.
_steps = self._path._interpolation_steps | ||
_path = Path(self._xy[subslice, :], _interpolation_steps=_steps) | ||
xy = STEP_LOOKUP_MAP[self._drawstyle](*self._xy[subslice, :].T) | ||
_path = Path(np.asarray(xy).T, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test image for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Remove duplicated test as well.
@@ -4460,12 +4460,6 @@ def test_ls_ds_conflict(): | |||
linestyle='steps-pre:', drawstyle='steps-post') | |||
|
|||
|
|||
@cleanup | |||
def test_ls_ds_conflict(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is duplicated (see the lines just above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that is a good reason to remove it.
#6497 set the
_path
attribute of Line2D to the actually drawn patheven if the drawstyle is
steps-*
; however containment tests and thesubslice optimization for very long paths were not updated accordingly
(see #6615). This patch fixes the issues.
Note that
contains
returns, for events in a horizontal segment of a"steps-mid" drawstyle plot, the index of the point in the segment,
regardless of whether the event occured to the left or the right of
that point.