Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Inline and optimize ContourLabeler.get_label_coords.#19018
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ff2fe6b
to39d6d98
Comparelib/matplotlib/contour.py Outdated
# If all candidates are `too_close()`, just use the straightest part. | ||
idx = adist[0] | ||
x, y = xx[idx, hbsize], yy[idx, hbsize] | ||
return x, y, hbsize % ctr_size |
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.
Is this supposed to not useidx
like line 308? It may beadist[0]
, but that doesn't mean thatidx
is 0.
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.
indeed, reordered the logic a bit
`get_label_coords` is clearly an internal helper to `locate_label`; e.g.the `distances` parameter needs to be filled in with a very specificarray that's internally computed by `locate_label`. Inline it, whichalso makes clearer the possibility to save some further computation for`locate_label` to return a linearized index (the part that was commented"There must be a more efficient way..."; indeed converting the array toa list of tuples to get back the index seems pretty inefficient).Also better document the implementation of `get_label_coords` (I'm notactually changing any of the code logic).
get_label_coords
is clearly an internal helper tolocate_label
; e.g.the
distances
parameter needs to be filled in with a very specificarray that's internally computed by
locate_label
. Inline it, whichalso makes clearer the possibility to save some further computation for
locate_label
to return a linearized index (the part that was commented"There must be a more efficient way..."; indeed converting the array to
a list of tuples to get back the index seems pretty inefficient).
Also better document the implementation of
get_label_coords
(I'm notactually changing any of the code logic).
PR Summary
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).