[Numpy-discussion] help! type 'float64scalar' is not type 'float'
Mathew Yeates
myeates at jpl.nasa.gov
Thu Aug 3 19:30:33 EDT 2006
Here is a similar problem I wish could be fixed. In scipy.io.mio is
savemat with the line
if type(var) != ArrayType
which, I believe should be changed to
if not isinstance(var,ArrayType):
so I can use savemat with memory mapped arrays.
Mathew
Travis Oliphant wrote:
> Sebastian Haase wrote:
>
>> 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') )
>>
>
> These routines are a little buggy. I've cleaned them up in SVN to
> reflect what they should do. When the dtype object came into
> existence a lot of what the scalar types where being used for was no
> longer needed. Some of these functions weren't updated to deal with
> the dtype objects correctly either.
>
> This is what you get now:
> >>> import numpy as N
> >>> N.isscalar(12)
>
> True
>
> >>> N.issctype(12)
>
> False
>
> >>> N.isscalar('12')
>
> True
>
> >>> N.issctype('12')
>
> False
>
> >>> N.isscalar(N.array([1]))
>
> False
>
> >>> N.issctype(N.array([1]))
>
> False
>
> >>> N.isscalar(N.array([1]).dtype)
>
> False
>
> >>> N.issctype(N.array([1]).dtype)
>
> True
>
> >>> N.isscalar(N.array([1])[0].dtype)
>
> False
>
> >>> N.issctype(N.array([1])[0].dtype)
>
> True
>
> >>> N.isscalar(N.array([1])[0])
>
> True
>
> >>> N.issctype(N.array([1])[0])
>
> False
>
>
> -Travis
>
>
>>>>> 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
>>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
More information about the NumPy-Discussion
mailing list