scipp.compat.wrapping.wrap1d#

scipp.compat.wrapping.wrap1d(is_partial=False, accept_masks=False, keep_coords=False)#

Decorator factory for decorating functions that wrap non-scipp 1-D functions.

1-D functions are typically functions from libraries such as scipy that depend on a single ‘axis’ argument.

The decorators returned by this factory apply pre- and postprocessing as follows:

  • An ‘axis’ keyword argument will raise ValueError, recommending use of ‘dim’. The index of the provided dimension is added as axis to kwargs.

  • Providing data with variances will raise sc.VariancesError since third-party libraries typically cannot handle variances.

  • Coordinates, masks, and attributes that act as “observers”, i.e., do not depend on the dimension of the function application, are added to the output data array. Masks are deep-copied as per the usual requirement in Scipp.

Parameters:
  • is_partial (bool, default: False) – The wrapped function is partial, i.e., does not return a data array itself, but a callable that returns a data array. If true, the postprocessing step is not applied to the wrapped function. Instead, the callable returned by the decorated function is decorated with the postprocessing step.

  • accept_masks (bool, default: False) – If false, all masks must apply to the dimension that the function is applied to.

  • keep_coords (bool, default: False) – If true, preserve the input coordinates. If false, drop coordinates that do not apply to the dimension the function is applied to.

Return type:

Callable[[Callable[..., TypeVar(_Out, bound= DataArray | Callable[..., DataArray])]], Callable[..., TypeVar(_Out, bound= DataArray | Callable[..., DataArray])]]