Computation between blocks of 2 arrays

Good day friends, I have a question about map_blocks() I’m trying something simple, I want to take the dot product between columns (the blocks of 2 arrays) as in the attached screenshot.

If this works as expected it should return a single float for the dot product of each block. So, output should be a single 1x5 array.

I’m clearly missing something because this raises the exception ValueError: shapes (100,1) and (100,1) not aligned: 1 (dim 1) != 100 (dim 0) Any pointers as to what I’m not understanding???

Hi @dmelgarm, thanks for the question! I think just a very small change will get you what you’re looking for, according to the docs, since these are 2-D arrays it will do matrix multiplication, so one array needs to be transposed. Rewriting your block_dot_product function returns an array of floats:

def block_dot_product(a, b):
    out =, b)
    return out