title: Numeric computation of certain symbols in numpy array of sympy expressions
body: <h1>Problem</h1>
  <p>I am working with an arbitrary MxN numpy matrix where each element is a sympy expression, potentially with differing symbols. For the purposes of visualization, let's work with the following matrix <code>test</code></p>
  <pre><code>import sympy as sp
  import numpy as np
  
  a,b,c=sp.symbols('a b c');
  test=np.array([[a**2,a+b],[a*c+b,b/c]]);
  </code></pre>
  <p>When run, <code>test</code> will look like:</p>
  <pre><code>In [25]: test
  Out[25]: 
  array([[a**2, a + b],
         [a*c + b, b/c]], dtype=object)
  </code></pre>
  <p>I would like to be able to replace one variable in this array with a number and return a new array that has the same dimensions as <code>test</code> but has replaced the specified variable with it's new value. For example, if I wanted to replace <code>b</code> with 2, the new array should look like:</p>
  <pre><code>array([[a**2, a + 2],
         [a*c + 2, 2/c]], dtype=object)
  </code></pre>
  <h1>Attempt at a Solution</h1>
  <p>I first tried to use the sympy function <code>subs</code> but I received the following error:</p>
  <pre><code>test.subs({b:2})
  Traceback (most recent call last):
  
    File &quot;&lt;ipython-input-29-a9a04d63af37&gt;&quot;, line 1, in &lt;module&gt;
      test.subs({b:2})
  
  AttributeError: 'numpy.ndarray' object has no attribute 'subs'
  </code></pre>
  <p>I looked at using lambdify but I believe that it returns a numeric lambda expression which isn't what I want. I need a new symbolic expression, just one that doesn't depend on <code>b</code> anymore. I found some literature in the Wolfram Mathematica documentation under pattern matching that seems to be what I need <a href="http://www.wolfram.com/language/fast-introduction-for-programmers/en/patterns/" rel="nofollow noreferrer">http://www.wolfram.com/language/fast-introduction-for-programmers/en/patterns/</a> but I can't figure out how to implement this in Python, or if it's even possible to do so. Any help would be greatly appreciated.</p>