[Numpy-discussion] help! type 'float64scalar' is not type 'float'

Sebastian Haase haase at msg.ucsf.edu
Thu Aug 3 11:32:30 CDT 2006


On Wednesday 02 August 2006 22:43, Travis Oliphant wrote:
> Sebastian Haase wrote:
> > Thanks,
> > I just found
> > numpy.isscalar() and numpy.issctype()   ?
> > These sound like they would do what I need - what is the difference
> > between the two ?
>
> Oh, yeah.
>
> numpy.issctype works with type objects
> numpy.isscalar works with instances
>
> Neither of them distinguish between scalars and "numbers."
>
> If you get errors with isscalar it would be nice to know what they are.

I'm still trying to reproduce the exception, but here is a first comparison 
that - honestly - does not make much sense to me:
(type vs. instance seems to get mostly the same results  and why is there a 
difference with a string ('12') )

>>> N.isscalar(12) 
True
>>> N.issctype(12)
True

>>> N.isscalar('12')
True
>>> N.issctype('12')
False

>>> N.isscalar(N.array([1]))
False
>>> N.issctype(N.array([1]))
True

>>> N.isscalar(N.array([1]).dtype)
False
>>> N.issctype(N.array([1]).dtype)
False

  # apparently new 'scalars' have a dtype attribute !
>>> N.isscalar(N.array([1])[0].dtype)
False
>>> N.issctype(N.array([1])[0].dtype)
False

>>> N.isscalar(N.array([1])[0])
True
>>> N.issctype(N.array([1])[0])
True 

-Sebastian




More information about the Numpy-discussion mailing list