[pythran] Re: ndarray

  • From: Neal Becker <ndbecker2@xxxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Fri, 29 Aug 2014 18:32:03 -0400

Silently producing wrong results is a bad thing

with ndarray, the c++ code can specify the minimum # contiguous dimensions
it will accept.  If it expects a dense array, for example,
and is passed an array that is not contiguous,

then boost::python will complain about being unable to convert.  Not a very
good error message, but at least you get a message.

You could even put 2 versions of your routine (or for that matter, M
versions) - such as one that accepts only dense arrays and another that
works for general strides.

At a minimum, an error message should be produced at runtime.

The best behavior would be for pythran to handle both strided and
non-strided arrays correctly, and as efficiently as possible.  But I have
no idea how difficult that would be.

On Fri, Aug 29, 2014 at 4:50 PM, serge Guelton <sguelton@xxxxxxxxxxxxx>

> > Just for information. On your example:
> >
> > #export sum(int[])
> > def sum (x):
> >
> > We will *assum* that x is contiguous.
> >
> > If you use : sum(a[::2]), you will have an incorrect output.
> > It can be fix if you need this kind of use.
> Correct. We should open a ticket on this one...

*Those who don't understand recursion are doomed to repeat it*

Other related posts: