0

I have converted grid1 and grid2 into arrays and using following function which iterates through table and should return corresponding value form table when grid1 and grid2 values are matched. But somehow the final output contain only 4 integer values which isn't correct. Any suggestion what is possibly wrong here?

def grid(grid1,grid2):
    table = {(10,1):61,(10,2):75,(10,3):83,(10,4):87,
             (11,1):54,(11,2):70,(11,3):80,(11,4):85,
             (12,1):61,(12,2):75,(12,3):83,(12,4):87,
             (13,1):77,(13,2):85,(13,3):90,(13,4):92,}
    grid3 = np.zeros(grid1.shape, dtype = np.int)

    for k,v in table.iteritems():
        grid3[[grid1 == k[0]] and [grid2 == k[1]]] = v

    return grid3
4

1 回答 1

0

我认为正在发生的事情是对变量“k”和“v”的赋值没有使用“deepcopy”完成。这意味着分配只是对变量而不是它们的值。例如,当“k”的值在后续迭代中发生变化时,所有先前的“gridx”分配现在都反映了“k”的新/当前状态。

于 2013-04-23T17:43:06.953 回答