Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simplify/robustify segment-point distance calculation. #24840

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

Merged
merged 1 commit into from
Jan 1, 2023

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Dec 29, 2022

The version in poly_editor is relatively simple because it only supports array inputs and doesn't vectorize over any input.

The version in proj3d is private so the API can be changed, but it needs (currently) to at least support non-array inputs and to vectorize over p.

  • Rename the parameters to make the difference between the "segment ends" (s0, s1) and the "point" (p) parameters clearer.
  • Switch p to support (N, ndim) inputs instead of (ndim, N) (consistently with most other APIs); adjust test_lines_dists accordingly.
  • Use vectorized ops everywhere, which also caught the fact that previously, entries beyond the third in (what was) p1, p2 would be silently ignored (because access was via p1[0], p1[1], p2[0], p2[1]). Instead now the vectorized version naturally extends to any number of dimensions. Adjust format_coord and test_lines_dists_nowarning accordingly.
  • Also support vectorizing over s0, s1, if they have the same length as p (this comes basically for free).

PR Summary

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

The version in poly_editor is relatively simple because it only supports
array inputs and doesn't vectorize over any input.

The version in proj3d is private so the API can be changed, but it needs
(currently) to at least support non-array inputs and to vectorize over
`p`.

- Rename the parameters to make the difference between the "segment
  ends" (`s0, s1`) and the "point" (`p`) parameters clearer.
- Switch `p` to support (N, ndim) inputs instead of (ndim, N)
  (consistently with most other APIs); adjust test_lines_dists
  accordingly.
- Use vectorized ops everywhere, which also caught the fact that
  previously, entries beyond the third in (what was) `p1, p2` would be
  silently ignored (because access was via `p1[0]`, `p1[1]`, `p2[0]`,
  `p2[1]`).  Instead now the vectorized version naturally extends to any
  number of dimensions.  Adjust format_coord and
  test_lines_dists_nowarning accordingly.
- Also support vectorizing over `s0`, `s1`, if they have the same length
  as `p` (this comes basically for free).
@dstansby dstansby added this to the v3.7.0 milestone Jan 1, 2023
@dstansby dstansby merged commit ecf2c88 into matplotlib:main Jan 1, 2023
@anntzer anntzer deleted the sd branch January 1, 2023 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants