pygsti.extras.interpygate.core.InterpolatedQuantityFactory#
- class InterpolatedQuantityFactory(fn_to_interpolate, qty_shape=(), parameter_ranges=None, parameter_points=None, num_params_to_evaluate_as_group=0, interpolator_and_args=None)#
Bases:
objectCreates an InterpolatedQuantityFactory object.
These objects are used to create
InterpolatedQuantityobjects, which hold interpolated quantities, using multiple processors.- Parameters:
fn_to_interpolate (function) – The function to interpolate, which usually takes considerable resources to evaluate. If num_params_to_evaluate_as_group == 0 then the expected function definition is: def fn_to_interpolate(point, comm). The point argument is an array that specifies values of all the parameters, and comm is an MPI communicator. If num_params_to_evaluate_as_group > 0 then the function’s definition must be def fn_to_interpolate(point, grouped_axial_pts, comm). The point argument then omits values for the final num_params_to_evaluate_as_group parameters, which are instead specified by arrays of values within the list grouped_axial_pts.
qty_shape (tuple) – The shape of the quantity that is being interpolated. This is the shape of the array returned by fn_to_interpolate if num_params_to_evaluate_as_group == 0. In general, the shape of the array returned by fn_to_interpolate is qty_shape preceded by the number of values in each of the num_params_to_evaluate_as_group groups. An empty tuple means a floating point value.
parameter_ranges (list, optional) – A list of elements that each specify the values a parameter ranges over. If the elements are tuples, they should be of the form (min_value, max_value, num_points) to specify a set of equally spaced num_points points. If the elements are numpy.ndarray objects, then they specify the values directly, e.g. array([0, 0.1, 0.4, 1.0, 5.0]). If parameter_ranges is specified, parameter_points must be left as None.
parameter_points (list or numpy.ndarray, optional) – A list or array of parameter-space points, which can be used instead of parameter_ranges to specify a non-rectangular grid of points. Each element is an array of real values specifying a single point in parameter space (the length of each element must be the same, and sets the number of parameters). If parameter_points is used, then num_params_to_evaluate_as_group must be 0.
num_params_to_evaluate_as_group (int, optional) – The number of parameter ranges, counted back from the last one, that should be passed to fn_to_interpolate as an entire range of values, i.e. via the grouped_axial_pts argument.
interpolator_and_args (tuple or string, optional) – Optionally a 2-tuple of an interpolation class and argument dictionary. If None, the default of (csaps.NdGridCubicSmoothingSpline, {‘shape’, self.qty__shape}) is used. If csaps is not available, then (scipy.interpolate.LinearNDInterpolator, {‘rescale’: True}) is used instead. A linear interpolator can be specified explicitly by linear and the default spline interpolator may be explicitly specified by spline.
Methods
__init__(fn_to_interpolate[, qty_shape, ...])Creates an InterpolatedQuantityFactory object.
build([comm, mpi_workers_per_process, verbosity])compute_data([comm, ...])