Skip to content

Commit

Permalink
soft tolerance in spherical_mds
Browse files Browse the repository at this point in the history
  • Loading branch information
wrongu committed May 17, 2023
1 parent ea4aba9 commit 9b784f2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/repsim/stats/spherical_mds.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def pairwise_arc_lengths(X, center):


def _is_arc_length_matrix(X):
tolerance = 1e-4
tolerance, soft_tolerance = 1e-4, 1e-3
if X.ndim != 2:
return False
if X.shape[0] != X.shape[1]:
Expand All @@ -220,5 +220,8 @@ def _is_arc_length_matrix(X):
# Note that arccos(0.999) = .045, which is still 'far from zero'. So instead of asserting that the diagonal is zero,
# we'll assert that it's as close to zero as can be expected based on 'tolerance' error in the dot() part.
if not torch.all(X.diag().abs() < np.arccos(1.0 - tolerance)):
return False
if torch.all(X.diag().abs() < np.arccos(1.0 - soft_tolerance)):
warnings.warn("Diagonal of arc-length matrix is not zero, but is close to zero.")
else:
return False
return True

0 comments on commit 9b784f2

Please sign in to comment.