Skip to content

Commit

Permalink
Update sparse.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-migas committed Nov 1, 2023
1 parent d8330fa commit b028295
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/koyo/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def estimate_dense_size(array) -> str:
"""Calculate approximate size of the array if it was dense."""
from koyo.utilities import format_size

total_val = float(np.product(array.shape))
total_val = float(np.prod(array.shape))
n_bytes = total_val * array.dtype.itemsize
return format_size(n_bytes)

Expand All @@ -181,7 +181,7 @@ def calculate_array_sparsity(array):
else:
non_zero = np.count_nonzero(array)
fmt = "dense"
total_val = np.product(array.shape)
total_val = np.prod(array.shape)
sparsity = (total_val - non_zero) / total_val
density = non_zero / total_val
return f"Sparsity: {sparsity * 100:.4f}% | Density {density * 100:.4f}% | NNZ: {non_zero} | FMT: {fmt}"

0 comments on commit b028295

Please sign in to comment.