qml.numpy.wrap_arrays

class wrap_arrays(old, new)[source]

Loop through an object’s symbol table, wrapping each function with tensor_wrapper().

This is useful if you would like to wrap every function provided by an imported module.

Parameters
  • old (dict) – The symbol table to be wrapped. Note that callable classes are ignored; only functions are wrapped.

  • new (dict) – The symbol table that contains the wrapped values.

See also

tensor_wrapper()

Example

This function is used to wrap the imported autograd.numpy module, to enable all functions to support requires_grad arguments, and to output tensor objects:

>>> from autograd import numpy as _np
>>> wrap_arrays(_np.__dict__, globals())