-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Sparse Geodesic Cost Support (#677)
* set ottjax version first and the tests * recreate solution files with new ottjax version so it doesn't fail * update tests with new version, specify inner_iterations * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add comments on issues * first draft of geodesic sparse need to add more tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * set to new ottjax commit * revert old commit that fixes the lr case * set new version of ottjax instead of commit * fix and modify the geodesic cost tests * typo fix * fix doc and add tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * still densify for other costs * fix docs * add the final tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dominik Klein <[email protected]>
- Loading branch information
1 parent
4ba5f83
commit 1b951fe
Showing
8 changed files
with
117 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
|
||
import jax.experimental.sparse as jesp | ||
import numpy as np | ||
import scipy.sparse as sp | ||
from ott.geometry.geometry import Geometry | ||
|
||
from moscot.backends.ott._utils import _instantiate_geodesic_cost | ||
|
||
|
||
class TestBackendUtils: | ||
|
||
@staticmethod | ||
def test_instantiate_geodesic_cost(): | ||
m, n = 10, 10 | ||
problem_shape = 10, 10 | ||
g = sp.rand(m, n, 0.1, dtype=np.float64) | ||
g = jesp.BCOO.from_scipy_sparse(g) | ||
geom = _instantiate_geodesic_cost(g, problem_shape, 1.0, False) | ||
assert isinstance(geom, Geometry) | ||
with pytest.raises(ValueError, match="Expected `x` to have"): | ||
_instantiate_geodesic_cost(g, problem_shape, 1.0, True) | ||
geom = _instantiate_geodesic_cost(g, (5, 5), 1.0, True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters