glass.arraytools — Array tools utilities¶
This module contains utilities for working with arrays which are used by GLASS.
This module should be imported manually if used outside of GLASS:
import glass.arraytools
General¶
- glass.arraytools.broadcast_first(*arrays)[source]¶
Broadcast arrays, treating the first axis as common.
- glass.arraytools.broadcast_leading_axes(*args, xp=None)[source]¶
Broadcast all but the last N axes.
- Parameters:
- Returns:
The shape of the broadcast dimensions, and all input arrays with leading axes matching that shape.
- Return type:
Examples
Broadcast all dimensions of
a, all except the last dimension ofb, and all except the last two dimensions ofc.>>> import numpy as np >>> a = 0 >>> b = np.zeros((4, 10)) >>> c = np.zeros((3, 1, 5, 6)) >>> dims, a, b, c = broadcast_leading_axes((a, 0), (b, 1), (c, 2)) >>> dims (3, 4) >>> a.shape (3, 4) >>> b.shape (3, 4, 10) >>> c.shape (3, 4, 5, 6)
- glass.arraytools.ndinterp(x, xq, fq, axis=-1, left=None, right=None, period=None)[source]¶
Interpolate multi-dimensional array over axis.
- Parameters:
xq (
Any) – The x-coordinates of the data points.fq (
Any) – The function values corresponding to the x-coordinates in xq.axis (
int) – The axis to interpolate over.right (
Optional[float]) – The value to return for x > xq[-1].period (
Optional[float]) – The period of the function, used for interpolating periodic data.
- Returns:
The interpolated array.
- Return type: