[Numpy-discussion] Depreciating asfortranarray and ascontiguousarray
Travis Oliphant
teoliphant at gmail.com
Fri Oct 26 19:47:00 EDT 2018
I see now the original motivation as the unfortunate situation that mxnet
authors did not understand that np.ascontiguousarray returned an array of
at least one dimension and perhaps used that one API to assume that NumPy
did not support 0-d arrays --- which NumPy does indeed support.
Certainly that situation would motivate a documentation change to help
steer other future users from making the same incorrect assumption, but
deprecation is a separate question entirely. I do not agree at all with
the trend to remove functions from NumPy API prior to a dedicated NumPy 2.0
effort. This breaks the idea of semantic versioning for NumPy.
These functions do, in fact, have a use and were very much intended to
produce one-dimensional arrays --- in order to be used prior to calling C
or Fortran code that expected at least a 1-d array. A lot of the SciPy
wrapping code needed this behavior. It is a misinterpretation to assume
this is buggy or unintended.
Improving the documentation to warn about the behavior for 0-d arrays could
indeed be useful.
-Travis
On Fri, Oct 26, 2018 at 6:27 PM Stephan Hoyer <shoyer at gmail.com> wrote:
> On Fri, Oct 26, 2018 at 3:48 PM Sebastian Berg <sebastian at sipsolutions.net>
> wrote:
>
>> On Fri, 2018-10-26 at 13:25 -0700, Stephan Hoyer wrote:
>> > On Fri, Oct 26, 2018 at 12:55 PM Alex Rogozhnikov <
>> > alex.rogozhnikov at yandex.ru> wrote:
>> > >
>> > > The conservative way to handle this would be to do a deprecation
>> > > cycle, specifically by issuing FutureWarning when scalars or 0d
>> > > arrays are encountered as inputs.
>> > > Sounds good to me. Behavior should be scheduled for numpy 1.18?
>> > >
>> >
>> > Yes, that sounds about right to me.
>> >
>>
>> Is there a way to avoid the future warning? An unavoidable warning in a
>> widely used function seems really annoying to me. Unless, the 0d thing
>> happens rarely, but then it might be the downstream users that get the
>> warning for no reason.
>>
>> - Sebastian
>>
>
> My suspicion is that 0d arrays are rarely used as arguments to
> ascontiguousarray / asfortranarray. But it's hard to say for sure...
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20181026/8d5db8fc/attachment-0001.html>
More information about the NumPy-Discussion
mailing list