title: How can I check if one two-dimensional NumPy array contains a specific pattern of values inside it?
body: <p>I have a large <code>NumPy.array</code> <code>field_array</code> and a smaller array <code>match_array</code>, both consisting of <code>int</code> values. Using the following example, how can I check if any match_array-shaped segment of <code>field_array</code> contains values that exactly correspond to the ones in <code>match_array</code>?</p>
  
  <pre><code>import numpy
  raw_field = ( 24,  25,  26,  27,  28,  29,  30,  31,  23, \
                33,  34,  35,  36,  37,  38,  39,  40,  32, \
               -39, -38, -37, -36, -35, -34, -33, -32, -40, \
               -30, -29, -28, -27, -26, -25, -24, -23, -31, \
               -21, -20, -19, -18, -17, -16, -15, -14, -22, \
               -12, -11, -10,  -9,  -8,  -7,  -6,  -5, -13, \
                -3,  -2,  -1,   0,   1,   2,   3,   4,  -4, \
                 6,   7,   8,   4,   5,   6,   7,  13,   5, \
                15,  16,  17,   8,   9,  10,  11,  22,  14)
  field_array = numpy.array(raw_field, int).reshape(9,9)
  match_array = numpy.arange(12).reshape(3,4)
  </code></pre>
  
  <p>These examples ought to return <code>True</code> since the pattern described by <code>match_array</code> aligns over <code>[6:9,3:7]</code>.</p>