Functions¶
- talon.utils.check_pattern_iw(indices_of_generators: scipy.sparse.coo.coo_matrix, weights: scipy.sparse.coo.coo_matrix) → None[source]¶
Check if the sparsity pattern of the indices and the weights are the same.
This function performs a complete check on the sparsity pattern of the indices_of_generators and the weights matrices. If the two matrices have a different number of non-empty entries or the non-empty entries are in different locations, it raises an error.
If the two matrices came out of talon.voxelization, this check is not necessary.
Note
This function is very expensive in terms of memory and time.
- Parameters
indices_of_generators – sp.coo_matrix of the indices.
weights – sp.coo_matrix of the weights.
- Raises
ValueError – If weights and indices_of_generators don’t have the same sparsity pattern.
- talon.utils.concatenate_giw(giws: Iterable, axis: int = 0) → tuple[source]¶
Concatenates generators, indices, and weights along an existing axis
The indices and weights are concatenated along the supplied axis and the generators along axis 1. The generators must have the same number of columns. The indices and weights must have the same shape, except in the dimension corresponding to axis.
- Parameters
giws – An iterable of (generator, indices, weights) to concatenate e.g. [(g1, i1, w1), (g2, i2, w2)].
axis – The axis along which the indices and weights will be joined. Default is 0.
- Returns
The concatenated generators, indices, and weights.
- talon.utils.directions(number_of_points: int = 180) → numpy.ndarray[source]¶
Get a list of 3D vectors representing the directions of the fibonacci covering of a hemisphere of radius 1 computed with the golden spiral method. The \(z\) coordinate of the points is always strictly positive.
- Parameters
number_of_points – number of points of the wanted covering (default=180)
- Returns
number_of_points
x 3 array with the cartesian coordinatesof a point of the covering in each row.
- Return type
ndarray
- Raises
ValueError – if
number_of_points <= 0
.
References
- talon.utils.mask_data(data: numpy.ndarray, linear_operator: talon.core.LinearOperator) → numpy.ndarray[source]¶
Mask the data using the mask that covers only the entries that are affected by the linear operator. This prevents numerical errors in the solution of the optimization problem.
- Parameters
data – np.ndarray one dimensional array that contains the data to mask.
linear_operator – LinearOperator object that contains the self.data_mask attribute to be used as a mask.
- Returns
np.ndarray with the same dimension as data where the entries corresponding to the False entries of the mask have been set to zero.