7. Structured arrays wrapping

Taking derivatives on structured numpy arrays is not supported by autograd, so structured arrays are internally wrapped with StructuredArray.

7.1. StructuredArray

class lsqfitgp.StructuredArray(array)

Autograd-friendly imitation of a numpy structured array.

It behaves like a read-only numpy structured array, with the exception that you can set a whole field/subfield.

Parameters
arraynumpy array, StructuredArray

A structured array. An array qualifies as structured if array.dtype.names is not None.

Notes

The StructuredArray is a readonly view on the input array. When you change the content of a field of the StructuredArray, however, the reference to the original array for that field is lost.

Examples

>>> a = np.empty(3, dtype=[('f', float), ('g', float)])
>>> a = StructuredArray(a)
>>> a['f'] = np.arange(3) # this is allowed
>>> a[1] = (0.3, 0.4) # this raises an error

7.2. Functions

lsqfitgp.asarray(x, **kw)

Version of np.asarray that works with StructuredArray.

lsqfitgp.broadcast(*arrays)

Version of np.broadcast that works with StructuredArray.

lsqfitgp.broadcast_arrays(*arrays, **kw)

Version of np.broadcast_arrays that works with StructuredArray.

lsqfitgp.broadcast_shapes(shapes)

Return the broadcasted shape from a list of shapes.

lsqfitgp.broadcast_to(x, shape, **kw)

Version of np.broadcast_to that works with StructuredArray.