Skip to content

Commit 5837a8c

Browse files
committed
Simplify a bit
1 parent 3b4c2f2 commit 5837a8c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

vrplib/parse/parse_distances.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ def from_lower_row(data: np.ndarray) -> np.ndarray:
112112

113113
# The flattened data represents the lower triangle of a symmetric matrix.
114114
# Derive the matrix size (https://en.wikipedia.org/wiki/Triangular_number).
115-
# n * (n - 1) / 2 = m => n = (1 + sqrt(1 + 8m)) / 2
116-
m = flattened.size
117-
n = (1 + int((1 + 8 * m) ** 0.5)) // 2
115+
# m = n * (n - 1) / 2 => n = (1 + sqrt(1 + 8m)) / 2
116+
n = (1 + int((1 + 8 * flattened.size) ** 0.5)) // 2
118117

119118
distances = np.zeros((n, n))
120119
distances[np.tril_indices(n, k=-1)] = flattened

0 commit comments

Comments
 (0)