Skip to content

Commit

Permalink
rename grammian to gramian
Browse files Browse the repository at this point in the history
  • Loading branch information
knikolaou committed Jun 10, 2024
1 parent 7ccd77a commit c16efc2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions CI/unit_tests/utils/test_matrix_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from numpy.testing import assert_array_almost_equal, assert_array_equal, assert_raises

from papyrus.utils import (
compute_grammian_diagonal_distribution,
compute_gramian_diagonal_distribution,
compute_hermitian_eigensystem,
compute_l_pq_norm,
flatten_rank_4_tensor,
Expand Down Expand Up @@ -140,9 +140,9 @@ def test_normalizing_gram_matrix(self):
assert_array_almost_equal(normalized_matrix[0], np.zeros(4))
assert_array_almost_equal(normalized_matrix[:, 0], np.zeros(4))

def test_compute_grammian_diagonal_distribution(self):
def test_compute_gramian_diagonal_distribution(self):
"""
Test the computation of the grammian diagonal distribution.
Test the computation of the gramian diagonal distribution.
The test is done in the following steps:
- Compute a gram matrix
Expand All @@ -158,7 +158,7 @@ def test_compute_grammian_diagonal_distribution(self):
array_norm_density = array_norm / array_norm.sum()

# Evaluate the magnitude density with the function that is to be tested
mag_density = compute_grammian_diagonal_distribution(matrix)
mag_density = compute_gramian_diagonal_distribution(matrix)
assert_array_almost_equal(array_norm_density, mag_density)

def test_compute_l_pq_norm(self):
Expand Down
6 changes: 3 additions & 3 deletions papyrus/measurements/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
compute_von_neumann_entropy,
)
from papyrus.utils.matrix_utils import (
compute_grammian_diagonal_distribution,
compute_gramian_diagonal_distribution,
compute_hermitian_eigensystem,
)

Expand Down Expand Up @@ -415,7 +415,7 @@ def apply(self, ntk: np.ndarray) -> np.ndarray:
"To compute the self-entropy of the NTK, the NTK matrix must"
f" be a tensor of rank 2, but got a tensor of rank {len(ntk.shape)}."
)
distribution = compute_grammian_diagonal_distribution(gram_matrix=ntk)
distribution = compute_gramian_diagonal_distribution(gram_matrix=ntk)
return compute_shannon_entropy(distribution, effective=self.effective)


Expand Down Expand Up @@ -486,7 +486,7 @@ def apply(self, ntk: np.ndarray) -> np.ndarray:
"To compute the magnitude distribution of the NTK, the NTK matrix must"
f" be a tensor of rank 2, but got a tensor of rank {len(ntk.shape)}."
)
return compute_grammian_diagonal_distribution(gram_matrix=ntk)
return compute_gramian_diagonal_distribution(gram_matrix=ntk)


class NTKEigenvalues(BaseMeasurement):
Expand Down
4 changes: 2 additions & 2 deletions papyrus/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
compute_von_neumann_entropy,
)
from papyrus.utils.matrix_utils import (
compute_grammian_diagonal_distribution,
compute_gramian_diagonal_distribution,
compute_hermitian_eigensystem,
compute_l_pq_norm,
flatten_rank_4_tensor,
Expand All @@ -38,7 +38,7 @@
__all__ = [
compute_hermitian_eigensystem.__name__,
normalize_gram_matrix.__name__,
compute_grammian_diagonal_distribution.__name__,
compute_gramian_diagonal_distribution.__name__,
compute_l_pq_norm.__name__,
flatten_rank_4_tensor.__name__,
unflatten_rank_4_tensor.__name__,
Expand Down
2 changes: 1 addition & 1 deletion papyrus/utils/matrix_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def normalize_gram_matrix(gram_matrix: np.ndarray):
return gram_matrix * normalizing_matrix


def compute_grammian_diagonal_distribution(gram_matrix: np.ndarray) -> np.ndarray:
def compute_gramian_diagonal_distribution(gram_matrix: np.ndarray) -> np.ndarray:
"""
Compute the normalized distribution of the diagonals of a gram matrix.
Expand Down

0 comments on commit c16efc2

Please sign in to comment.