<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 6, 2020 at 3:31 PM Eric Wieser <<a href="mailto:wieser.eric%2Bnumpy@gmail.com">wieser.eric+numpy@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">When I added this function, it was always my intent for it to be consumed by downstream packages, but as Sebastian remarks, it wasn't really desirable to put it in the top-level namespace.</div></div></blockquote><div><br></div><div>This is a nice function indeed, +1 for making it public.</div><div><br></div><div>Regarding namespace, it would be nice to decouple the `numpy` and `numpy.lib` namespaces, so we can put this in `numpy.lib` and say that's where library author functions go from now on. That'd be better than making all `numpy.lib.*` submodules public.</div><div><br></div><div>Cheers,<br></div><div>Ralf</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div><br></div><div>I think I would be reasonably happy to make the guarantee that it would not be removed (or more likely, moved) without a lengthy deprecation cycle.</div><div><br></div><div>Perhaps worth opening a github issue, so we can keep track of how many downstream projects are already using it.</div><div><br></div><div>Eric</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 5 Apr 2020 at 15:06, Sebastian Berg <<a href="mailto:sebastian@sipsolutions.net" target="_blank">sebastian@sipsolutions.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, 2020-04-05 at 00:43 -0400, Warren Weckesser wrote:<br>
> On 4/4/20, Warren Weckesser <<a href="mailto:warren.weckesser@gmail.com" target="_blank">warren.weckesser@gmail.com</a>> wrote:<br>
> > It would be handy if in scipy we can use the function<br>
> > `numpy.lib.shape_base.normalize_axis_index` as a consistent method<br>
> > for<br>
> > validating an `axis` argument.  Is this function considered part of<br>
> > the public API?<br>
> > <br>
> > There are modules in numpy that do not have leading underscores but<br>
> > are still usually considered private.  I'm not sure if<br>
> > `numpy.lib.shape_base` is one of those.  `normalize_axis_index` is<br>
> > not<br>
> > in the top-level `numpy` namespace, and it is not included in the<br>
> > API<br>
> > reference<br>
> > (<br>
> > <a href="https://numpy.org/devdocs/search.html?q=normalize_axis_index&check_keywords=yes&area=default" rel="noreferrer" target="_blank">https://numpy.org/devdocs/search.html?q=normalize_axis_index&check_keywords=yes&area=default</a><br>
> > ),<br>
> > so I'm not sure if we can safely consider this function to be<br>
> > public.<br>
> > <br>
<br>
I do not see a reason why we should not make those functions public.<br>
The only thing I see is that they are maybe not really required in the<br>
main namespace, i.e. you can be expected to use::<br>
<br>
    from numpy.something import normalize_axis_tuple<br>
<br>
I think, since this is a function for library authors more than end-<br>
users. And we do not have much prior art around where to put something<br>
like that.<br>
<br>
Cheers,<br>
<br>
Sebastian<br>
<br>
<br>
<br>
> > Warren<br>
> > <br>
> <br>
> Answering my own question:<br>
> <br>
> "shape_base.py" is not where `normalize_axis_index` is originally<br>
> defined, so that module can be ignored.<br>
> <br>
> The function is actually defined in `numpy.core.multiarray`.  The<br>
> pull<br>
> request in which the function was created is<br>
> <a href="https://github.com/numpy/numpy/pull/8584" rel="noreferrer" target="_blank">https://github.com/numpy/numpy/pull/8584</a>. Whether or not the function<br>
> was to be public is discussed starting here:<br>
> <a href="https://github.com/numpy/numpy/pull/8584#issuecomment-281179399" rel="noreferrer" target="_blank">https://github.com/numpy/numpy/pull/8584#issuecomment-281179399</a>.  A<br>
> leading underscore was discussed and intentionally not added to the<br>
> function.  On the other hand, it was not added to the top-level<br>
> namespace, and Eric Wieser wrote "Right now, it is only accessible<br>
> via<br>
> np.core.multiarray.normalize_axis_index, so yes, an internal<br>
> function".<br>
> <br>
> There is another potentially useful function, `normalize_axis_tuple`,<br>
> defined in `numpy.core.numeric`.  This function is also not in the<br>
> top-level numpy namespace.<br>
> <br>
> So it looks like neither of these functions is currently intended to<br>
> be public. For the moment, I think we'll create our own utility<br>
> functions in scipy.  We can switch to using the numpy functions if<br>
> those functions are ever intentionally made public.<br>
> <br>
> Warren<br>
> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
> <br>
<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div></div>