Re: [Numpy-discussion] isfortran compatibility in numpy 1.10.

2015-11-02 Thread Sebastian Berg
I bet it has all been said already, but to note just in case. In numpy itself 
we use it mostly to determine the memory order of the *output* and not for 
safty purpose. That is the macro of course and I think yelling people to use 
flags.fnc in python is better.
 
- Sebastian


On Mon Nov 2 08:52:01 2015 GMT+0330, Sturla Molden wrote:
> Charles R Harris  wrote:
> 
> >1. Return `a.flags.f_contiguous`. This differs for 1-D arrays, but is
> >most consistent with the name isfortran.
> 
> If the idea is to determine if an array can safely be passed to Fortran,
> this is the correct one.
> 
> >2. Return `a.flags.f_contiguous and a.ndim > 1`, which would be backward
> >compatible.
> 
> This one is just wrong.
> 
> A compromize might be to raise an exception in the case of a.ndim<2. 
> 
> Sturla
> 
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
> 
>
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] isfortran compatibility in numpy 1.10.

2015-11-02 Thread Charles R Harris
On Mon, Nov 2, 2015 at 11:28 AM, Sebastian Berg 
wrote:

> I bet it has all been said already, but to note just in case. In numpy
> itself we use it mostly to determine the memory order of the *output* and
> not for safty purpose. That is the macro of course and I think yelling
> people to use flags.fnc in python is better.
>

Probably all the Numpy uses of `PyArray_ISFORTRAN` should be audited. My
guess is that it will be found to be incorrect in some (most?) of the
places.

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] isfortran compatibility in numpy 1.10.

2015-11-01 Thread Sturla Molden
Charles R Harris  wrote:

>1. Return `a.flags.f_contiguous`. This differs for 1-D arrays, but is
>most consistent with the name isfortran.

If the idea is to determine if an array can safely be passed to Fortran,
this is the correct one.

>2. Return `a.flags.f_contiguous and a.ndim > 1`, which would be backward
>compatible.

This one is just wrong.

A compromize might be to raise an exception in the case of a.ndim<2. 

Sturla

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] isfortran compatibility in numpy 1.10.

2015-10-30 Thread Charles R Harris
Hi All,

The isfortran function calls a.fnc (Fortran-Not-C), which is implemented
as  F_CONTIGUOUS &&  !C_CONTIGUOUS. Before relaxed stride checking
contiguous multidimensional arrays could not be both and continguous 1-D
arrays were always CONTIGUOUS, but this is not longer the case.
Consequently current isfortran breaks backward compatiblity. There are two
suggested solutions

   1. Return `a.flags.f_contiguous`. This differs for 1-D arrays, but is
   most consistent with the name isfortran.
   2. Return `a.flags.f_contiguous and a.ndim > 1`, which would be backward
   compatible.

It is also possible to start with 2. but add a FutureWarning and later move
to 1, which it my preferred solution. See gh-6590
 for the issue.

Thoughts?
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] isfortran compatibility in numpy 1.10.

2015-10-30 Thread Travis Oliphant
As I posted to the github issue, I support #2 as it is the original
meaning. The most common case of isfortran that I recall was to support
transpositions that needed to occur before calling Fortran-compiled linear
algebra routines.

However, with that said, you could also reasonably do #1 and likely have no
real problem --- because transposing a 1-d array doesn't have any effect.

In NumPy 1.0.1, isfortran was intended to be True only for arrays with
a.ndim > 1. Thus, it would have been possible for someone to rely on that
invariant for some other reason.

With relaxed stride checking, this invariant changed because isfortran was
implemented by returning True if the F_Contiguous flag was set but the
C_Contiguous flag was not (this was only ever previously possible for
a.ndim > 1).

If you choose to go with #1, please emphasize in the release notes that
isfortran now does not assume a.ndim > 1 but is simply short-hand for
a.flags.f_contiguous.

-Travis



On Fri, Oct 30, 2015 at 5:12 PM, Charles R Harris  wrote:

> Hi All,
>
> The isfortran function calls a.fnc (Fortran-Not-C), which is implemented
> as  F_CONTIGUOUS &&  !C_CONTIGUOUS. Before relaxed stride checking
> contiguous multidimensional arrays could not be both and continguous 1-D
> arrays were always CONTIGUOUS, but this is not longer the case.
> Consequently current isfortran breaks backward compatiblity. There are two
> suggested solutions
>
>1. Return `a.flags.f_contiguous`. This differs for 1-D arrays, but is
>most consistent with the name isfortran.
>2. Return `a.flags.f_contiguous and a.ndim > 1`, which would be
>backward compatible.
>
> It is also possible to start with 2. but add a FutureWarning and later
> move to 1, which it my preferred solution. See gh-6590
>  for the issue.
>
> Thoughts?
>
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


-- 

*Travis Oliphant*
*Co-founder and CEO*


@teoliphant
512-222-5440
http://www.continuum.io
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion