Skip to content

Commit af83931

Browse files
committed
Improve constants naming
1 parent 791fbe2 commit af83931

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

cfpq_decomposer/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
HASH_PRIME_MODULUS = 2147483647
44
MIN_LSH_BUCKET_SIZE = 3
55
SMALL_BUCKET_ID = -1
6-
HASH_COUNT = 3
6+
HASH_FUNCTIONS_COUNT = 3
77
MIN_REDUCTION_RATIO = 0.05
88
MAX_SIZE_RATIO = 0.3

cfpq_decomposer/high_performance_decomposer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from graphblas.core.vector import Vector
1010

1111
from cfpq_decomposer.abstract_decomposer import AbstractDecomposer
12-
from cfpq_decomposer.constants import HASH_PRIME_MODULUS, HASH_COUNT, MIN_LSH_BUCKET_SIZE, SMALL_BUCKET_ID
12+
from cfpq_decomposer.constants import HASH_PRIME_MODULUS, HASH_FUNCTIONS_COUNT, MIN_LSH_BUCKET_SIZE, SMALL_BUCKET_ID
1313
from cfpq_matrix.matrix_utils import drop_zeros_inplace
1414

1515

@@ -70,7 +70,7 @@ def _compute_row_hashes(matrix: Matrix) -> npt.NDArray[Any]:
7070
hash_weights = np.random.default_rng().integers(
7171
low=1,
7272
high=np.iinfo(np.int64).max,
73-
size=HASH_COUNT,
73+
size=HASH_FUNCTIONS_COUNT,
7474
dtype=np.int64
7575
)
7676
row_hashes = row_signatures_matrix.to_dense(fill_value=0) @ hash_weights
@@ -79,13 +79,13 @@ def _compute_row_hashes(matrix: Matrix) -> npt.NDArray[Any]:
7979
@staticmethod
8080
def _compute_row_signatures_matrix(matrix: Matrix) -> Matrix:
8181
num_rows, num_cols = matrix.shape
82-
hash_coefficients = np.random.randint(1, HASH_PRIME_MODULUS, size=HASH_COUNT, dtype=np.int64)
83-
hash_offsets = np.random.randint(0, HASH_PRIME_MODULUS, size=HASH_COUNT, dtype=np.int64)
82+
hash_coefficients = np.random.randint(1, HASH_PRIME_MODULUS, size=HASH_FUNCTIONS_COUNT, dtype=np.int64)
83+
hash_offsets = np.random.randint(0, HASH_PRIME_MODULUS, size=HASH_FUNCTIONS_COUNT, dtype=np.int64)
8484
column_indices = np.arange(num_cols, dtype=np.int64)
8585
hash_matrix = Matrix.from_dense(
8686
(column_indices[:, None] * hash_coefficients[None, :] + hash_offsets[None, :]) % HASH_PRIME_MODULUS
8787
)
88-
row_signatures_matrix = Matrix(INT64, num_rows, HASH_COUNT)
88+
row_signatures_matrix = Matrix(INT64, num_rows, HASH_FUNCTIONS_COUNT)
8989
row_signatures_matrix << semiring.min_second(matrix @ hash_matrix)
9090
return row_signatures_matrix
9191

0 commit comments

Comments
 (0)