Find if 2D array is an exact subarray of another 2D array?

Viewed 54

I'm stuck with the problem of testing whether or not a 2d array appears in the exact same order in another 2d array, e.g.:

01
23

in

000100
002300
000000
000000

would return true, but in

001000
002300
000000
000000

would return false.

I've already attempted to use scipy.signal.correlate2d but to no avail. Any help? Cheers!

)edit) Code for generating the data:

import numpy as np
a = np.array([[0,0,0,1,0,0],
             [0,0,2,3,0,0],
             [0,0,0,0,0,0],
             [0,0,0,0,0,0]])

a = np.array([[0,0,1,0,0,0],
             [0,0,2,3,0,0],
             [0,0,0,0,0,0],
             [0,0,0,0,0,0]])



b = np.array([[0,1],
             [2,3]])
1 Answers
Related