ray (python)是否可以通过掩码的 np.arrays 处理操作/统计信息?[ np.nansum(...)在这种情况下]。
对于非屏蔽数组,效果很好;但它会因屏蔽数组而崩溃(请参阅下面的消息错误)。
import numpy as np
import numpy.ma as ma
import ray
ray.init()
#-to nansum over axis 0 (layers)
@ray.remote
def sumo(x):
return np.nansum(x,axis=0,keepdims=True)
#-to allocate/reference the 3D-np.array into ray 'cores'
@ray.remote
def matrox(wat):
return ma.copy(wat)
#-a small reproducible example
data = np.int16((np.random.normal(size=(4,5,6))*100))
#-masking the data
data = ma.masked_less_equal(data,0)
#-this fails:
data_id = matrox.remote(data)
##-this doesn't fail as it gets rid off of the mask (but I DO need the mask)
#data_id = matrox.remote(data.data)
data_id = ray.put(data)
answer = ray.get(sumo.remote(data_id))
以下是我在运行该行时遇到的错误:
data_id =matrox.remote(数据)
数组的大小为 4x5x6=120,但在将 120 值拟合为 240=4x5x12 ValueError时会“抱怨” :无法将大小为 120 的数组重新整形为形状 (4,5,12)