[Matrix-SIG] Numeric Nits
Konrad Hinsen
hinsen@cnrs-orleans.fr
Wed, 23 Jun 1999 20:40:45 +0200
> I'll concede that virtually all the operations should go ahead and return
> scalars. However, the original poster referred to '-array([5])' returning a
> scalar. I haven't been able to think of any situations where people are
> going to be using negative on a rank-0 array without expecting the result to
> also be a rank-0 array. The chance of the rank-0 array's produced this way
> getting loose and hurting people seems slim.
Fine, but wouldn't you also want addition, multiplication, etc. of
rank-0 arrays to return rank-0 arrays for consistency? And how should
the NumPy code decide if it was called with an explicit rank-0 array
or with a result of a previous operation that just happens to be a
rank-0 array and that the user wants converted to a scalar?
> Actually, I've disallowed this in JPython because it is,as you say, a
> kludge. There are however two ways of getting at the value in a rank-0
> array.
>
> a[()]
> a[...]
>
> I prefer the first (not just because it's shorter...).
I agree, but this is still far from obvious (try to write an
explanation for the NumPy tutorial!)
> This isn't a very good solution in many ways, but it's the best one I've
> seen so far. Using floats is enough of a pain that it would probably kill
> you in interactive mode, so I think the lack of support for floats is a
> legitimate complaint. I would love to see a better solution than this one
> though.
I'd prefer the
"special-float-type-which-is-higher-in-the-cast-hierarchy-than-double"
solution. At least the "weird" property is attached to arrays, and not
to a global variable.
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------