[SciPy-Dev] adding chkfinite flags to linalg functions

Martin Teichmann lkb.teichmann@gmail....
Sat Sep 17 07:11:30 CDT 2011


Hi list,

I've been working on qr_multiply, as some of you might have already
known, and realized that more than 10% of the time is actually spent
in asarray_chkfinite, at which point I discovered this discussion and
just wanted to add my two cents.

I think it is a problem that should be tackled, but there are several
possible solutions:

* just say numpy.asarray_chkfinite=numpy.asarray. That works fine as
a hack if you know what you're doing

* adding the parameter chkfinite to all functions. That's uncool, I think,
hard to maintain on the long run.

* improving asarray_chkfinite. I think Fabian is working on that.
actually, the only thing needed would be a function isallfinite, since
I guess that most of the time is spent in the creation of the logical
array in isfinite(a).all().

* adding a ALLFINITE flag to ndarrays. Gaël correctly pointed out that
this is not as simple as it sounds, but it's nevertheless possible:
ALLFINITE would have to be a immutable flag at creation time of the
ndarray, and everytime one does something to the ndarray (possibly
via a view, to which the ALLFINITE flag has to be copied), we have
to check everything is finite. This solution would create a lot of work,
but also nice side-effects: even NaN-aware functions in numpy can
be very slow on some (actually very common) hardware, accidental
NaNs can be very annoying.

* adding an "finite" intent into f2py. This is currently my preferred solution.
as f2py often has to copy the data to make it available for FORTRAN,
checking finiteness could be done while copying with virtually no
loss of speed.

So, what are yall thinking?

Greetings

Martin

-- 
Max-Born-Institut
Max-Born-Straße 2a
12489 Berlin
+49 30 6392 1234


More information about the SciPy-Dev mailing list