[Numpy-discussion] np.array execution path
Sebastian Berg
sebastian at sipsolutions.net
Sun Sep 23 17:45:30 EDT 2012
On Sun, 2012-09-23 at 18:54 +0100, Nathaniel Smith wrote:
> On Sat, Sep 22, 2012 at 10:24 PM, Sebastian Berg
> <sebastian at sipsolutions.net> wrote:
> > In case you are interested, the second (real odditiy), is caused by
> > ISFORTRAN and IS_F_CONTIGUOUS mixup, I have found three occurances where
> > I think ISFORTRAN should be replaced by the latter. Check also:
> >
> > https://github.com/seberg/numpy/commit/4d2713ce8f2107d225fe291f5da6c6a75436647e
>
> So I guess we have this ISFORTRAN function (also exposed to
> Python[1]). It's documented as checking the rather odd condition of an
> array being in fortran-order AND having ndim > 1. Sebastian, as part
> of polishing up some of our contiguity-handling code, is suggesting
> changing this so that ISFORTRAN is true for an array that is (fortran
> order && !C order). Off the top of my head I can't think of any
> situation where *either* of these predicates is actually useful. (I
> can see why you want to check if an array is in fortran order, but not
> why it'd be natural to check whether it's in fortran order and also
> these other conditions together in one function call.) The problem is,
> this makes it hard to know whether Sebastian's change is a good idea.
>
> Can anyone think of legitimate uses for ISFORTRAN? Or should it just
> be deprecated altogether?
Maybe I am missing things, but I think ISFORTRAN is used to decide the
order in which a new array is requested when "Anyorder" is used.
In some use cases it does not matter, but for example in these cases
(where the new array has a different shape then the original) it would
change if you just changed ISFORTRAN:
a = np.ones(4) # C/F-Contig
a.reshape(2,2, order='A')
np.add.outer(a, a, order='A')
These would return Fortran order instead of C if ISFORTRAN did not check
dimension > 1 (or equivalently !c-contig).
>
> -n
>
> [1] http://docs.scipy.org/doc/numpy/reference/generated/numpy.isfortran.html
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list