From: Colin J. W. <cj...@sy...> - 2004-06-07 15:51:32
|
Todd, What are the objections to returning a scalar? To me, this seems to be simpler than some kluge, such as float(array) or int(array). To use these, one has first to determine what array._type is. Colin W. Todd Miller wrote: >On Mon, 2004-06-07 at 06:50, Nadav Horesh wrote: > > >>b has a scalar properties: >> >> >> >>>>>b+3 >>>>> >>>>> >>5 >> >> >> >>>>>b.rank >>>>> >>>>> >>0 >> >>The odd issue is that rank>0 arrays keeps their type in similar operations: >> >> >> >>>>>a = array((2,), type=Int16) >>>>>a >>>>> >>>>> >>array([2], type=Int16) >> >> >> >>>>>a + 3 >>>>> >>>>> >>array([5], type=Int16) >> >>I would expect that rank 0 arrays would behave like scalars with a given numarray type (Int8, UInt64, ...). >> >> Nadav. >> >> > >Originally, I think your expected behavior was the behavior. The >official policy now, always subject to debate, is that rank-0 arrays >should be a mostly hidden implementation detail. The fact that a scalar >is returned here is a matter of consistency and no accident. (This is >not to say that I'm confident that we're completely consistent... I'm >just trying to explain the direction we're heading.) > >Todd > > > |