title: How to get copy of structured array selection
body: <p>I have a structured array with mixed types:</p>
  
  <pre><code>dt = np.dtype([('x', np.float64), ('y', np.float64), ('n', np.uint32)])
  arr = np.empty(10, dtype=dt)
  </code></pre>
  
  <p>As of numpy 1.16 or so, if I view <code>x</code> and <code>y</code>, I get a view:</p>
  
  <pre><code>&gt;&gt;&gt; sub = arr[['x', 'y']]
  &gt;&gt;&gt; sub
  array([(6.23042070e-307, 4.67296746e-307),
         (1.15710088e-306, 1.60221615e-306),
         (1.95821574e-306, 6.23062102e-307),
         (1.78019082e-306, 1.37959740e-306),
         (1.37959129e-306, 1.33511562e-306),
         (1.33511018e-306, 1.33511969e-306),
         (1.11261027e-306, 1.11261502e-306),
         (8.45593934e-307, 9.34600963e-307),
         (6.23038336e-307, 1.29061142e-306),
         (2.22522596e-306, 2.22522596e-306)],
        dtype={'names':['x','y'], 'formats':['&lt;f8','&lt;f8'], 'offsets':[0,8], 'itemsize':20})
  </code></pre>
  
  <p>This is a problem because I would like to be able to convert the subset <code>sub</code> into a <code>(10, 2)</code> view of the <code>x</code> and <code>y</code> fields.</p>
  
  <p>I can not just use <code>sub.view(dtype=np.float64)</code>. That raises the error</p>
  
  <pre><code>ValueError: When changing to a smaller dtype, its size must be a divisor of the size of original dtype
  </code></pre>
  
  <p>I can use <code>np.lib.stride_tricks.as_strided</code>, but that is hacky and problematic because it only works when I want two fields (or alternatively any number of evenly-spaced fields):</p>
  
  <pre><code>&gt;&gt;&gt; shape = sub.shape + (2,)
  &gt;&gt;&gt; strides = (sub.dtype.itemsize,
             np.diff([x[1] for x in sub.dtype.fields.values()]).item())
  &gt;&gt;&gt; np.lib.stride_tricks.as_strided(sub, shape=shape, strides=strides)['x']
  array([[6.23042070e-307, 4.67296746e-307],
         [1.15710088e-306, 1.60221615e-306],
         [1.95821574e-306, 6.23062102e-307],
         [1.78019082e-306, 1.37959740e-306],
         [1.37959129e-306, 1.33511562e-306],
         [1.33511018e-306, 1.33511969e-306],
         [1.11261027e-306, 1.11261502e-306],
         [8.45593934e-307, 9.34600963e-307],
         [6.23038336e-307, 1.29061142e-306],
         [2.22522596e-306, 2.22522596e-306]])
  </code></pre>
  
  <p>If <code>sub</code> were a copy, then I could simply view it as a <code>(10, 2)</code> array of floats. How can I view the selected fields as such an array, either by copying the selection or any other means?</p>