pyotc 0.2.2__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyotc/__init__.py CHANGED
@@ -2,4 +2,15 @@
2
2
 
3
3
  __author__ = """Jay Hineman"""
4
4
  __email__ = "jay.hineman@gmail.com"
5
- __version__ = "0.1.0"
5
+ __version__ = "0.3.0"
6
+
7
+ # Public API re-exports
8
+ from .otc import entropic_otc, exact_otc
9
+
10
+ __all__ = [
11
+ "exact_otc",
12
+ "entropic_otc",
13
+ "__author__",
14
+ "__email__",
15
+ "__version__",
16
+ ]
pyotc/otc.py CHANGED
@@ -1,5 +1,53 @@
1
1
  """Main entry point for otc funcitonality"""
2
2
 
3
+ from .otc_backend.policy_iteration.dense.exact import exact_otc as _exact_otc_dense
4
+ from .otc_backend.policy_iteration.sparse.exact import exact_otc as _exact_otc_sparse
5
+ from .otc_backend.policy_iteration.dense.entropic import entropic_otc as _entropic_otc
3
6
 
4
- def exact_OTC():
5
- raise NotImplementedError
7
+
8
+ def exact_otc(
9
+ P1,
10
+ P2,
11
+ c,
12
+ *,
13
+ stat_dist="best",
14
+ backend="dense",
15
+ max_iter=None,
16
+ ):
17
+ if backend == "dense":
18
+ return _exact_otc_dense(P1, P2, c, stat_dist=stat_dist)
19
+ elif backend == "sparse":
20
+ if max_iter is None:
21
+ return _exact_otc_sparse(P1, P2, c, stat_dist=stat_dist)
22
+ return _exact_otc_sparse(P1, P2, c, stat_dist=stat_dist, max_iter=max_iter)
23
+ else:
24
+ raise ValueError("Unknown backend: {backend}. Choose from {'dense', 'sparse'}.")
25
+
26
+
27
+ def entropic_otc(
28
+ Px,
29
+ Py,
30
+ c,
31
+ *,
32
+ L=100,
33
+ T=100,
34
+ xi=0.1,
35
+ method="logsinkhorn",
36
+ sink_iter=100,
37
+ reg_num=None,
38
+ get_sd=False,
39
+ silent=True,
40
+ ):
41
+ return _entropic_otc(
42
+ Px,
43
+ Py,
44
+ c,
45
+ L=L,
46
+ T=T,
47
+ xi=xi,
48
+ method=method,
49
+ sink_iter=sink_iter,
50
+ reg_num=reg_num,
51
+ get_sd=get_sd,
52
+ silent=silent,
53
+ )
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyotc
3
+ Version: 0.3.0
4
+ Summary: Perform optimal transition coupling (OTC) in python.
5
+ Author: Jay Hineman, Yuning Pan, Bongsoo Yi
6
+ License: MIT license
7
+ License-File: AUTHORS.rst
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.10
10
+ Requires-Dist: matplotlib>=3.10.0
11
+ Requires-Dist: networkx>=3.4.2
12
+ Requires-Dist: numpy>=2.2.1
13
+ Requires-Dist: pot>=0.9.5
14
+ Description-Content-Type: text/markdown
15
+
16
+ # pyotc
17
+ [![codecov](https://codecov.io/github/pyotc/pyotc/graph/badge.svg?token=52QPNW0AP7)](https://codecov.io/github/pyotc/pyotc)
18
+
19
+ A python implementations of optimal transport coupling algorithms.
20
+
21
+ ## Documentation
22
+ Find sphinx documentation [here](https://pyotc.github.io/pyotc/).
23
+
24
+ ## Installation
25
+
26
+ We expect `pyotc` to be pip-installable across all platforms.
27
+
28
+
29
+ ### 1. Install from pypi (Recommended)
30
+
31
+ ```bash
32
+ pip install pyotc
33
+ ```
34
+ - Note: `pyotc` requires Python 3.10 or above.
35
+
36
+ ### 2. Install from github
37
+
38
+ ```bash
39
+ pip install https://github.com/pyotc/pyotc.git
40
+ ```
41
+
42
+ ### 3. Install for Development
43
+ We test in venvs provided by [uv](https://docs.astral.sh/uv/) via [nox](https://nox.thea.codes/en/stable/usage.html#changing-the-sessions-default-backend). It's helpful, but not strictly necessary to do the same.
44
+
45
+ ```bash
46
+ git clone https://github.com/pyotc/pyotc.git
47
+ cd pyotc
48
+ pip install -e .
49
+ ```
50
+
51
+ ### `uv` workflow
52
+ Install the [uv tool](https://docs.astral.sh/uv/getting-started/installation/). Then
53
+
54
+ ```bash
55
+ git clone https://github.com/pyotc/pyotc.git
56
+ cd pyotc
57
+ uv sync
58
+ uv pip install -e .
59
+ ```
60
+
61
+ To verify your installation, run
62
+ ```bash
63
+ uv run pytest
64
+ ```
65
+
66
+ ## Run Tests
67
+ With a `uv` setup one can simply
68
+ ```bash
69
+ uv run pytest
70
+ ```
71
+ Otherwise, in `pip` installed context with deps met, `pytest` should behave as expected.
72
+
73
+ ## Contributing
74
+ Guidelines for contribution to `pyotc` are provided in [CONTRIBUTING.md](./CONTRIBUTING.md).
75
+
76
+ ## Changelog
77
+ A summary of changes and guide to versioning are recoreded in [CHANGELOG.md](./CHANGELOG.md).
78
+
79
+ ## Citing this Repository
80
+ If you wish to cite our work, please use the following BibTeX code:
81
+ ```bibtex
82
+ @article{yi2025alignment,
83
+ title={Alignment and comparison of directed networks via transition couplings of random walks},
84
+ author={Yi, Bongsoo and O'Connor, Kevin and McGoff, Kevin and Nobel, Andrew B},
85
+ journal={Journal of the Royal Statistical Society Series B: Statistical Methodology},
86
+ pages={qkae085},
87
+ year={2024},
88
+ doi = {10.1093/jrsssb/qkae085}
89
+ }
90
+ ```
@@ -1,5 +1,5 @@
1
- pyotc/__init__.py,sha256=Od-nJxr4TP_mgmXMxpwaItNDISKzR0V6X8QakVNTmr8,125
2
- pyotc/otc.py,sha256=_we15B7Gw-IgxVlXnXbWS_8d0LGwHbaZiSrHwBSGbM0,94
1
+ pyotc/__init__.py,sha256=xeEd5NMPTp_zvS0KFWDUJJxDQWy89IhMybeSfeExAl8,297
2
+ pyotc/otc.py,sha256=ViNIL9bqdYUQj_5HDkVyfVVVIyNfbvNql8_wpxhmc_M,1233
3
3
  pyotc/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pyotc/examples/edge_awareness.py,sha256=k4pAs_UkDC2ZzgvkQZD9aY-gemjd8I9UAzWA1x8Z_3E,2513
5
5
  pyotc/examples/lollipops.py,sha256=fmvPkdSL9T5ZjQU8SpFnIox5DDuiVVwikjt7w3ukxLc,1589
@@ -27,8 +27,8 @@ pyotc/otc_backend/policy_iteration/sparse/__init__.py,sha256=47DEQpj8HBSa-_TImW-
27
27
  pyotc/otc_backend/policy_iteration/sparse/exact.py,sha256=2VskHrp1nDGPV2yEsD5MBagrZHkUDCdChMZ28WOb0uk,4400
28
28
  pyotc/otc_backend/policy_iteration/sparse/exact_tce.py,sha256=oSymhuok3logzt0wYSYJeMkTls0zzC0kRiQw2nHXk7c,3626
29
29
  pyotc/otc_backend/policy_iteration/sparse/exact_tci.py,sha256=mW90o-2ZVd9fjgKFDlJhR223G5JYxBSzsHBr7NdK6eg,3446
30
- pyotc-0.2.2.dist-info/METADATA,sha256=yTtg2-uCXeJCSpSeh-NUWJ_i2NnxLzLjFuLcO46mexY,1122
31
- pyotc-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
32
- pyotc-0.2.2.dist-info/licenses/AUTHORS.rst,sha256=FtGxBvQjLU6Vdej_-zcsdWxTwnInCsjqejFRmaeC7TU,136
33
- pyotc-0.2.2.dist-info/licenses/LICENSE,sha256=DfWCeVpuOnLG1KJZfBO24ry8u90eeQi7mTdjoo5pt8M,1070
34
- pyotc-0.2.2.dist-info/RECORD,,
30
+ pyotc-0.3.0.dist-info/METADATA,sha256=tmOqDSpLPDu6nJ2AoxNmCtyKeq3tFvDjyBOHaQVHwjY,2419
31
+ pyotc-0.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
32
+ pyotc-0.3.0.dist-info/licenses/AUTHORS.rst,sha256=FtGxBvQjLU6Vdej_-zcsdWxTwnInCsjqejFRmaeC7TU,136
33
+ pyotc-0.3.0.dist-info/licenses/LICENSE,sha256=DfWCeVpuOnLG1KJZfBO24ry8u90eeQi7mTdjoo5pt8M,1070
34
+ pyotc-0.3.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,38 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pyotc
3
- Version: 0.2.2
4
- Summary: Perform optimal transition coupling (OTC) in python.
5
- Author: Jay Hineman, Yuning Pan, Bongsoo Yi
6
- License: MIT license
7
- License-File: AUTHORS.rst
8
- License-File: LICENSE
9
- Requires-Python: >=3.10
10
- Requires-Dist: matplotlib>=3.10.0
11
- Requires-Dist: networkx>=3.4.2
12
- Requires-Dist: numpy>=2.2.1
13
- Requires-Dist: pot>=0.9.5
14
- Description-Content-Type: text/markdown
15
-
16
- # pyotc
17
- [![codecov](https://codecov.io/github/pyotc/pyotc/graph/badge.svg?token=52QPNW0AP7)](https://codecov.io/github/pyotc/pyotc)
18
-
19
- A python implementations of optimal transport coupling algorithms.
20
-
21
- ## Documentation
22
- Find sphinx documentation [here](https://pyotc.github.io/pyotc/).
23
-
24
- ## Install
25
- See [install instructions](INSTALL.md)
26
-
27
- ## Run Tests
28
- With a `uv` setup one can simply
29
- ```bash
30
- uv run pytest
31
- ```
32
- Otherwise, in `pip` installed context with deps met, `pytest` should behave as expected.
33
-
34
- ## Contributing
35
- Guidelines for contribution to `pyotc` are provided in [CONTRIBUTING.md](./CONTRIBUTING.md).
36
-
37
- ## Changelog
38
- A summary of changes and guide to versioning are recoreded in [CHANGELOG.md](./CHANGELOG.md).