[SciPy-user] what does 'd' mean in array([0.0, 1.0, 2.0, 3.0], 'd')

dmitrey openopt@ukr....
Thu Aug 30 11:24:46 CDT 2007


Unfortunately noone of the links give answer to my questions:
1. What should I type in command line to obtain Python print output
array([0.5, 1.5, 2.5, 3.5], 'd')
if I just type
print array([0.5, 1.5, 2.5, 3.5], double)
I get
 >>> print array([0.5, 1.5, 2.5, 3.5], double)
[ 0.5  1.5  2.5  3.5]
 >>> print x
array([0.5, 1.5, 2.5, 3.5], 'd')

2. Why the x (that "print x" yields array([0.5, 1.5, 2.5, 3.5], 'd')) 
has some attributes as ordinary array (dir(x) = ['__copy__', 
'__deepcopy__', 'astype', 'byteswapped', 'copy', 'iscontiguous', 
'itemsize', 'resize', 'savespace', 'spacesaver', 'tolist', 'toscalar', 
'tostring', 'typecode']), x.shape works((4,)),but x.size yields error?
dir(ordinary array) yields much more fields:
 >>> dir(a)
['T', '__abs__', '__add__', '__and__', '__array__', 
'__array_finalize__', '__array_interface__', '__array_priority__', 
'__array_struct__', '__array_wrap__', '__class__', '__contains__', 
'__copy__', '__deepcopy__', '__delattr__', '__delitem__', 
'__delslice__', '__div__', '__divmod__', '__doc__', '__eq__', 
'__float__', '__floordiv__', '__ge__', '__getattribute__', 
'__getitem__', '__getslice__', '__gt__', '__hash__', '__hex__', 
'__iadd__', '__iand__', '__idiv__', '__ifloordiv__', '__ilshift__', 
'__imod__', '__imul__', '__index__', '__init__', '__int__', 
'__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', 
'__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__long__', 
'__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', 
'__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', 
'__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', 
'__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', 
'__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', 
'__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__setitem__', 
'__setslice__', '__setstate__', '__str__', '__sub__', '__truediv__', 
'__xor__', 'all', 'any', 'argmax', 'argmin', 'argsort', 'astype', 
'base', 'byteswap', 'choose', 'clip', 'compress', 'conj', 'conjugate', 
'copy', 'ctypes', 'cumprod', 'cumsum', 'data', 'diagonal', 'dtype', 
'dump', 'dumps', 'fill', 'flags', 'flat', 'flatten', 'getfield', 'imag', 
'item', 'itemset', 'itemsize', 'max', 'mean', 'min', 'nbytes', 'ndim', 
'newbyteorder', 'nonzero', 'prod', 'ptp', 'put', 'ravel', 'real', 
'repeat', 'reshape', 'resize', 'round', 'searchsorted', 'setfield', 
'setflags', 'shape', 'size', 'sort', 'squeeze', 'std', 'strides', 'sum', 
'swapaxes', 'take', 'tofile', 'tolist', 'tostring', 'trace', 
'transpose', 'var', 'view']

It seems it's important - I got this x from fortran code, that uses 
numpy (ALGENCAN).
 >>> type(x)
<type 'array'>
 >>> x.shape
(4,)

D.



Steve Schmerler wrote:
> dmitrey wrote:
>   
>> hi all,
>> during debug I obtain
>>  >>> x
>> array([0.5, 1.5, 2.5, 3.5], 'd')
>> What does this 'd' mean?
>>     
>
> http://www.scipy.org/Tentative_NumPy_Tutorial#head-6a1bc005bd80e1b19f812e1e64e0d25d50f99fe2
> http://www.scipy.org/Numpy_Example_List#typeDict
> http://www.hjcb.nl/python/Arrays.html#.dtype
>
>   



More information about the SciPy-user mailing list