1

下面是一个 dask 数组

>>> import dask.array as da
>>> x = da.random.normal(5,2,size=(3,3),chunks=(1,1))
>>> x
dask.array<da.rand..., shape=(3, 3), dtype=float64, chunksize=(1, 1)>

我想将 dtype 更改为 float96 of x. 怎么做?

4

1 回答 1

2

通常您可以使用该.astype(...)方法更改 NumPy 或 Dask 数组的 dtype。

x = x.astype(...)

然而,不幸的是 NumPy 和 Dask.array 都不支持float96

In [1]: import numpy as np

In [2]: np.float
np.float     np.float16   np.float64   np.floating  
np.float128  np.float32   np.float_    

In [2]: np.array(1, dtype='float96')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-50670c2e1bb5> in <module>()
----> 1 np.array(1, dtype='float96')

TypeError: data type "float96" not understood
于 2016-03-29T05:55:00.080 回答