-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
DOC: Prepend ma.
to references in numpy.ma
#16736
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
Conversation
(from the conversation in #16300 ) @rossbar It's enough to replace to "This function is ..." only when the function simply copies the docstring in |
numpy/ma/core.py
Outdated
@@ -5605,7 +5605,7 @@ def sort(self, axis=-1, kind=None, order=None, | |||
-------- | |||
numpy.ndarray.sort : Method to sort an array in-place. | |||
argsort : Indirect sort. |
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.
should add prefix too.
numpy/ma/core.py
Outdated
@@ -5605,7 +5605,7 @@ def sort(self, axis=-1, kind=None, order=None, | |||
-------- | |||
numpy.ndarray.sort : Method to sort an array in-place. | |||
argsort : Indirect sort. | |||
lexsort : Indirect stable sort on multiple keys. | |||
numpy.lexsort : Indirect stable sort on multiple keys. | |||
searchsorted : Find elements in a sorted array. |
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.
should add prefix too.
numpy/core/fromnumeric.py
Outdated
@@ -3148,8 +3148,8 @@ def size(a, axis=None): | |||
See Also | |||
-------- | |||
shape : dimensions of array |
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.
should be numpy.ma.shape.
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.
should be numpy.ma.shape.
This is the docstring for np.size
, so it should be referencing functions from the numpy
namespace, not np.ma
I think.
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.
@Qiyu8 the reason I suggested @takanori-pskq split this off from #16300 was to see if we could find a way to make the links work in np.ma
without having to prepend numpy
to everything, so as not to clutter up the docstring for the numpy functions.
Perhaps it's worth looking at the getdoc
method of the _frommethod
and/or _convert2ma
classes? Again, I'm not too familiar with the details of how np.ma
is documented, so please share any ideas. I just think it's worth exploring if we can fix some of these broken links in np.ma
without having to touch the docstrings for the corresponding np
objects.
numpy/core/fromnumeric.py
Outdated
@@ -3148,8 +3148,8 @@ def size(a, axis=None): | |||
See Also | |||
-------- | |||
shape : dimensions of array |
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.
should be numpy.ma.shape.
This is the docstring for np.size
, so it should be referencing functions from the numpy
namespace, not np.ma
I think.
Some functions use neither |
This would work, though then you'd be automatically overriding any references to |
What is the status of this experiment? |
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.
Thanks for the ping @mattip
tl;dr - upside: fixes some broken links | downside: makes some See Also
sections uglier and in some cases redirects away from ma
functions when they would be a better fit.
I'm still ambivalent about this. See the proposed changes to the See Also
section of var
. Currently, the ma.var
docs link to the ma
versions of std
and mean
in the See Also
section: https://numpy.org/devdocs/reference/generated/numpy.ma.var.html. With this change, those links will instead point to the numpy
counterparts, rather than numpy.ma
. This also clutters-up the See Also
sections in the core functions, as prepending numpy.
is not necessary to make those links work.
The real problem stems from how ma
docs are generated. Ideally there would be a solution that would add e.g. .. currentmodule
's etc. where appropriate when the ma
docs are being generated, but there doesn't seem to be a one-size-fits-all solution.
There seems to be a nice push to get #13114 closed (big +1 IMO), so I'm okay accepting this as-is to further that goal and revisiting to fix the details later on.
Could this be done with a custom template option in the autosummary in doc/source/referencemaskedarray.baseclass.rst? |
I'll try using template. |
Now I work to fix this problem in #17515 . |
98a704e
to
669e9b8
Compare
Modified to prepend |
669e9b8
to
3904e99
Compare
numpy.
to references in numpy.ma
ma.
to references in numpy.ma
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.
Looks good, the template works as expected.
Thanks @takanori-pskq. |
Related #13114 : separated from #16300 for further discussion