Skip to content

Commit

Permalink
ENH: Add possiblity to provide tolerance for compatibility checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwboth committed Dec 2, 2023
1 parent 25bfee0 commit a426696
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/darsia/measure/emd.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ def _preprocess(self, img: darsia.Image) -> darsia.Image:
return preprocessed_img

def _compatibility_check(
self,
img_1: darsia.Image,
img_2: darsia.Image,
self, img_1: darsia.Image, img_2: darsia.Image, tol=1e-6
) -> bool:
"""
Compatibility check.
Expand Down Expand Up @@ -130,7 +128,7 @@ def _compatibility_check(
# Compatible distributions - comparing sums is sufficient since it is implicitly
# assumed that the coordinate systems are equivalent. Check each time step
# separately.
assert np.allclose(self._sum(img_1), self._sum(img_2))
assert np.allclose(self._sum(img_1), self._sum(img_2), atol=tol)

def _sum(self, img: darsia.Image) -> Union[float, np.ndarray]:
"""Sum over spatial entries.
Expand Down

0 comments on commit a426696

Please sign in to comment.