[Matrix-SIG] Conversion of scalars.

Travis Oliphant Oliphant.Travis@mayo.edu
Wed, 23 Jun 1999 13:07:20 -0500 (CDT)


>
> If I understood your idea correctly, you would *never* get double
> precision arrays from any operation. If that's what you want, just
> compile your private version of NumPy in such a way that PyArray_DOUBLE
> corresponds to a C float!

No that's not correct.  You would get doubles whenever you have doubles as
arguments to the operation.  All it changes is how Python scalars and
sequences are handled by default.  Even if the proposed attribute is set
you can still make sure they are returned as double precision by
requesting it either in Python with array([3,4],Float), or in C with any
of the Array construction function for which you specify a required type
(which is generally always done when it is known that the routine
needs double precision).

> 
> As a library developer, I don't like at all that the accuracy of my
> calculations depends on some user settings! I have plenty of routines
> that would not work correctly in single precision.

Help me understand a bit better, I don't see what libraries this would
break.  If a double array is ever introduced into the operation then
everything immediately becomes double precision.  The suggestion does not
break that behavior it just changes the default handling of Python scalars
(for which there are no single precision versions).  If the user does not
want single precision he/she wouldn't have to use it.  The default would
be as it is now.

> I wouldn't. Not because of the effort in changing the code, but
> because most of my NumPy is published and has a non-neglectable user
> base. I already spend too much time answering questions about
> installation problems, so I don't need the additional trouble of
> explaining which version of my code works with which version of NumPy.
> Backwards compatibility has always been a strong point of Python!

I think this can be done in a backward compatible way, anyway, so changing
code should not be necessary.

Travis