Move check of pattern of indices and weights from init to utils
When loading a linear operator, a check on the sparsity pattern of indices
and weights
is performed. This consumes a lot of ram for some reason to be investigated (probably the sorted
).
This check is unnecessary in most cases, as the indices
and weights
coming out of talon functions are already granted to
have the same sparsity pattern.
if not (
len(weights.data) == len(indices_of_generators.data) and
np.array_equal(
sorted(zip(weights.row, weights.col)),
sorted(zip(indices_of_generators.row,
indices_of_generators.col)))):
raise ValueError(
'"indices_of_generators" and "weights" must have the same'
' sparsity pattern')
This should be moved to an auxiliary function in talon.utils
.