title: Removing line breaks from numpy array
body: <p>I have a function to calculate the average vector for each name which is made of many words, this function is returning <code>numpy.ndarray</code> with shape of <code>(100,)</code>. The resulting vector is as the following:</p>
  
  <pre><code>[ 0.00127441  0.0002633   0.00039622  0.00055501  0.00070984 -0.00089766
   -0.00073814 -0.00224919  0.00233035 -0.00037628  0.00125402 -0.00052623
    0.00114087 -0.00070441 -0.00419099  0.00031204 -0.0002703  -0.00290918
    ...(13 lines)
  0.00260704 -0.00000406 -0.00160876  0.00134342]
  </code></pre>
  
  <p>As upon receiving the numpy array, I am removing line breaks as follows:</p>
  
  <pre><code>temp = ["%.8f" % number for number in name_avg_vector]
  temp=re.sub('\s+', ' ', temp)
  name_avg_vector= np.array(list(temp))
  </code></pre>
  
  <p>but I am getting the following error:</p>
  
  <pre><code>---&gt; 79     temp=re.sub('\s+', ' ', name_avg_vector)
  TypeError: cannot use a string pattern on a bytes-like object
  </code></pre>
  
  <p>I also tried changing the printoptions, but I continue having the break line in the file storing the numpy array values:</p>
  
  <pre><code>import sys
  np.set_printoptions(threshold=sys.maxsize)
  np.set_printoptions(threshold=np.inf)
  </code></pre>
  
  <p>After, I tried with array_repr to remove the break line:</p>
  
  <pre><code>name_avg_vector = np.array_repr(name_avg_vector).replace('\n', '')
  </code></pre>
  
  <p>but it saves as:</p>
  
  <pre><code>['array([-0.00849786,  0.00113221, -0.00643946,  0.00437448, -0.00740928,        0.00381133,  0.00178376, -0.00065115, -0.00050142,       -0.0001178 ,  0.00029183,  0.00015484, -0.00001569,  0.0006973 ,        0.00051486,  0.00006652, -0.00099618, -0.00049231,  0.0003479 ,        0.00135821,  0.00078396,  0.00038927,  0.00040825, -0.00093267,        0.00025755, -0.00012063, -0.00074733,  0.00120466,  0.00041425,       -0.00062592,  0.00098112,  0.00101578, -0.00048335,  0.00079251,       -0.00112981, 
  ...
  -0.00050014,  0.00133685, -0.00020537, -0.00082505])']  
  </code></pre>
  
  <p>As stated by Anoyz in <a href="https://stackoverflow.com/questions/1987694/how-to-print-the-full-numpy-array-without-truncation">here</a>, converting to list gets rid of break lines such as <code>name_avg_vector.tolist()</code>.</p>
  
  <p>Thanks</p>