Deprecate internal functions exposed in the public API of mplot3d#13030
Deprecate internal functions exposed in the public API of mplot3d#13030anntzer merged 8 commits intomatplotlib:masterfrom
Conversation
| ```````````` | ||
|
|
||
| Multiple internal functions that were exposed as part of the public API | ||
| of ``mpl_toolkits.mplot3d`` are deprecated. |
tacaswell
left a comment
There was a problem hiding this comment.
I am only requesting changes to make sure @WeatherGod has a chance to review this.
@WeatherGod should dismiss this review.
| return _proj_transform_vec(vec, M) | ||
|
|
||
|
|
||
| def _proj_transform_vec_clip(vec, M): |
There was a problem hiding this comment.
These deprecations might be a bit problematic. IIRC, some of these functions in proj3d.py are used elsewhere in 3rd party tools like mplcursors.
There was a problem hiding this comment.
particularly, the thing I am thinking of is any code that tries to infer the 3d coordinates from a 2D location, so that coordinates can be displayed in the interactive text display in the lower right-hand corner of the figure window.
There was a problem hiding this comment.
yeah, line2d_seg_dist() is what is used.
|
This PR's summary should have the list of deprecated functions updated, and the list needs to be included in the api changes notes. While I am fairly certain that most of these functions were never used, some were used. Deprecating these without providing a path forward for users is a bit jarring to me. |
|
mplcursors is definitely not using any of these. |
|
Thanks for the reviews! Will update the docs for API changes.
Well, the alternative is to keep them public, but then it would be difficult to change anything in mplot3d as currently, everything is public and different functions are tightly coupled. For instance, regarding
Which of the functions deprecated here should be kept public then? |
|
If @WeatherGod doesn't want any of these to be deprecated, I'd suggest walling off these functions to their own corner, duplicate them to private (underscore-prefixed) versions, modify the private versions accordingly, and make mplot3d internally use the internal version of all these functions. |
|
I am not against deprecating these functions, I just want to make sure there is a path forward documented, particularly for the few functions that are known to be used in-the-wild. |
|
The path forward documented is to copy-paste the old implementation... |
|
Where is that documented? And, for some of these deprecated functions, doing so would be wrong because they will call other internal functions. |
|
"... that will be documented..." |
|
I am 👍 on this modulo listing the function in the deprecation warning and adding a sentence that if you rely on these functions to vendor them. |
|
In addition, this PR is still incomplete because not all uses of the deprecated functions have been found and handled. Relying on pytest to find these for you is misleading because matplotlib's test coverage isn't the best. The one that I noticed off the bat is the use of |
WeatherGod
left a comment
There was a problem hiding this comment.
Need to find the remaining uses of the deprecated functions.
|
@rth Do you think you could finish up the work that needs to be done on this PR? It should not be a lot of work. |
|
Thanks for all the feedback.
Re-run
Added the list of all deprecated functions to the release notes and added a sentence suggesting vendoring. Please let me know if I need to do anything else. |
|
ping @WeatherGod We are hoping to tag 3.1 soonish and this should be in there... |
| self.eye = E | ||
| self.vvec = R - E | ||
| self.vvec = self.vvec / proj3d.mod(self.vvec) | ||
| self.vvec = self.vvec / proj3d._mod(self.vvec) |
| shade = np.array([np.dot(n / proj3d.mod(n), lightsource.direction) | ||
| if proj3d.mod(n) else np.nan | ||
| shade = np.array([np.dot(n / proj3d._mod(n), lightsource.direction) | ||
| if proj3d._mod(n) else np.nan |
| @cbook.deprecated("3.1") | ||
| def mod(v): | ||
| """3d vector length""" | ||
| return _mod(v) |
There was a problem hiding this comment.
All of these mod related things should be superceded by #13020, because it is straight-forward to just use np.linalg.norm().
|
@WeatherGod, if I understand correctly, all of your present reservations relate to the interaction with #13020, which @anntzer will rebase as needed. Is there anything that still needs to be fixed in this PR, apart from a rebase? |
|
Yes, sorry if I wasn't clear. Is the Travis failure unrelated to the PR? |
|
flake8 needs to pass! |
|
Sorry, merging master introduced the flake8 issue. Should be fixed now. |
|
thanks! |
mplot3dcurrently exposes most (if not all) internal functions as part of the public API, making changes very difficult. This deprecates some of these internal functions, which is a pre-requisite for #11577Following functions were deprecated,
In #11577, the following functions would also change of output type,
I'm not sure if I should deprecate these too, of it they should remain as part of the public API in the long term.
Note: also checked that no deprecated functions are used with,