eryn 1.2.5__py3-none-any.whl → 1.2.6__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.
eryn/utils/updates.py CHANGED
@@ -1,6 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  from abc import ABC
4
+ import dataclasses
4
5
 
5
6
  import numpy as np
6
7
 
@@ -20,6 +21,111 @@ class Update(ABC, object):
20
21
  """
21
22
  raise NotImplementedError
22
23
 
24
+ class CompositeUpdate(Update):
25
+ """A composite update that chains multiple Update objects together."""
26
+
27
+ def __init__(self, updates: list):
28
+ """
29
+ Args:
30
+ updates (list): List of Update objects to chain together.
31
+ """
32
+ self._updates = updates
33
+
34
+ def __call__(self, iter, last_sample, sampler):
35
+ """Call all chained updates in sequence."""
36
+ for update in self._updates:
37
+ update(iter, last_sample, sampler)
38
+
39
+ def __add__(self, other):
40
+ """Concatenate with another Update or CompositeUpdate."""
41
+ if isinstance(other, CompositeUpdate):
42
+ return CompositeUpdate(self._updates + other._updates)
43
+ elif isinstance(other, Update):
44
+ return CompositeUpdate(self._updates + [other])
45
+ else:
46
+ raise NotImplementedError
47
+
48
+ def __radd__(self, other):
49
+ """Support other + self."""
50
+ if isinstance(other, CompositeUpdate):
51
+ return CompositeUpdate(other._updates + self._updates)
52
+ elif isinstance(other, Update):
53
+ return CompositeUpdate([other] + self._updates)
54
+ else:
55
+ raise NotImplementedError
56
+
57
+ def __repr__(self):
58
+ return f"CompositeUpdate({self._updates})"
59
+
60
+
61
+ @dataclasses.dataclass
62
+ class UpdateStep(Update):
63
+ """
64
+ Base class for chainable update steps.
65
+
66
+ Attributes:
67
+ nsteps (int): Base number of steps between updates.
68
+ increment (int): Factor by which to increase the interval.
69
+ increment_every (int): Number of iterations after which to increase the interval.
70
+ stop (int): Optional iteration to stop updates.
71
+ """
72
+ nsteps: int = 100
73
+ increment: int = 1
74
+ increment_every: int = 500
75
+ stop: int = None
76
+
77
+ def __add__(self, other):
78
+ """Concatenate with another Update or CompositeUpdate."""
79
+ if isinstance(other, CompositeUpdate):
80
+ return CompositeUpdate([self] + other._updates)
81
+ elif isinstance(other, Update):
82
+ return CompositeUpdate([self, other])
83
+ else:
84
+ return NotImplemented
85
+
86
+ def __radd__(self, other):
87
+ """Support other + self."""
88
+ if isinstance(other, CompositeUpdate):
89
+ return CompositeUpdate(other._updates + [self])
90
+ elif isinstance(other, Update):
91
+ return CompositeUpdate([other, self])
92
+ else:
93
+ return NotImplemented
94
+
95
+ def check_step(self, iteration):
96
+ """Check if the update should be applied at this iteration.
97
+
98
+ The diagnostic frequency decreases over time. The interval between
99
+ diagnostics is multiplied by `increment` every `increment_every` steps.
100
+
101
+ Example with nsteps=100, increment=2, increment_every=500:
102
+ - iterations 0-499: check every 100 steps (but not at 0)
103
+ - iterations 500-999: check every 200 steps
104
+ - iterations 1000-1499: check every 400 steps
105
+ - etc.
106
+ """
107
+ if iteration == 0:
108
+ return False
109
+
110
+ exponent = iteration // self.increment_every
111
+ interval = self.nsteps * (self.increment ** exponent)
112
+
113
+ if self.stop is not None and iteration >= self.stop:
114
+ return False
115
+
116
+ return (iteration % interval == 0)
117
+
118
+ def update(self, iteration, last_sample, sampler):
119
+ """Override this method in subclasses to define the update behavior."""
120
+ raise NotImplementedError("Subclasses must implement update() method.")
121
+
122
+ def __call__(self, iteration, last_sample, sampler):
123
+ """Call the update if the step condition is met."""
124
+ if self.check_step(iteration):
125
+ print(f'Calling {self.__class__.__name__} at iteration {iteration}')
126
+ self.update(iteration, last_sample, sampler)
127
+
128
+
23
129
 
24
130
  class AdjustStretchProposalScale(Update):
25
131
  def __init__(
eryn/utils/utility.py CHANGED
@@ -218,7 +218,7 @@ def stepping_stone_log_evidence(betas, logls, block_len=50, repeats=100):
218
218
 
219
219
  Based on
220
220
  a. https://arxiv.org/abs/1810.04488 and
221
- b. https://pubmed.ncbi.nlm.nih.gov/21187451/.
221
+ b. doi: 10.1093/sysbio/syq085
222
222
 
223
223
  Args:
224
224
  betas (np.ndarray[ntemps]): The inverse temperatures to use for the quadrature.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eryn
3
- Version: 1.2.5
3
+ Version: 1.2.6
4
4
  Summary: Eryn: an omni-MCMC sampling package.
5
5
  Author: Michael Katz
6
6
  Author-email: Michael Katz <mikekatz04@gmail.com>
@@ -9,7 +9,6 @@ Classifier: Natural Language :: English
9
9
  Classifier: Programming Language :: C++
10
10
  Classifier: Programming Language :: Cython
11
11
  Classifier: Programming Language :: Python :: 3 :: Only
12
- Classifier: Programming Language :: Python :: 3.9
13
12
  Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
@@ -19,6 +18,9 @@ Requires-Dist: h5py
19
18
  Requires-Dist: jsonschema
20
19
  Requires-Dist: matplotlib
21
20
  Requires-Dist: numpy
21
+ Requires-Dist: pandas
22
+ Requires-Dist: corner
23
+ Requires-Dist: seaborn
22
24
  Requires-Dist: nvidia-ml-py
23
25
  Requires-Dist: platformdirs
24
26
  Requires-Dist: pydantic
@@ -41,7 +43,8 @@ Requires-Dist: corner ; extra == 'doc'
41
43
  Requires-Dist: matplotlib ; extra == 'testing'
42
44
  Requires-Dist: corner ; extra == 'testing'
43
45
  Requires-Dist: chainconsumer ; extra == 'testing'
44
- Requires-Python: >=3.9
46
+ Requires-Dist: scienceplots ; extra == 'testing'
47
+ Requires-Python: >=3.10
45
48
  Provides-Extra: doc
46
49
  Provides-Extra: testing
47
50
  Description-Content-Type: text/markdown
@@ -90,7 +93,7 @@ python -m unittest discover
90
93
 
91
94
  ## Contributing
92
95
 
93
- Please read [CONTRIBUTING.md](CONTRIBUTING) for details on our code of conduct, and the process for submitting pull requests to us.
96
+ Please read [CONTRIBUTING](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. See [CONTRIBUTORS](CONTRIBUTORS.md) for those that have authored code for and contributed to Eryn.
94
97
 
95
98
  ## Versioning
96
99
 
@@ -146,17 +149,6 @@ archivePrefix = {arXiv},
146
149
 
147
150
  Depending on which proposals are used, you may be required to cite more sources. Please make sure you do this properly.
148
151
 
149
- ## Authors
150
-
151
- * **Michael Katz**
152
- * Nikos Karnesis
153
- * Natalia Korsakova
154
- * Jonathan Gair
155
-
156
- ### Contibutors
157
-
158
- * Maybe you!
159
-
160
152
  ## License
161
153
 
162
154
  This project is licensed under the GNU License - see the [LICENSE.md](LICENSE) file for details.
@@ -3,7 +3,7 @@ eryn/__init__.py,sha256=eMxCEUQyqtaUM8zTr6kDCxeuFWpxZsfY41TefWUNHXI,821
3
3
  eryn/backends/__init__.py,sha256=yRQszA4WSofDDsSpTsA1V9eNw-pLVO_qalP5wpKjyZQ,380
4
4
  eryn/backends/backend.py,sha256=Udw_29TelVxAZsMNfsMiuIOUSlEUIRKTqXhfpNwnIng,47327
5
5
  eryn/backends/hdfbackend.py,sha256=dYJZtgTyNmW7zGpN6bVP8iY16hViDq2Gj2h970_w-pw,30062
6
- eryn/ensemble.py,sha256=OmwaLQHjIxe9LFkNM_tTUeXmwbTI0R-bm2S5yApyncI,72325
6
+ eryn/ensemble.py,sha256=-swmSbfrfxrQzP4yRUuG-GtQKvcaHPIgZMmyt595r0Q,72342
7
7
  eryn/git_version.py.in,sha256=dZ5WklaoF4dDsCVqhgw5jwr3kJCc8zjRX_LR90byZOw,139
8
8
  eryn/model.py,sha256=5TeWTI6V-Xcuy5C2LI6AmtZZU-EkRSSuA7VojXNALk8,284
9
9
  eryn/moves/__init__.py,sha256=9pWsSZSKLt05Ihd46vPASHwotTOHOPk_zEsCm8jWiw8,1081
@@ -26,12 +26,13 @@ eryn/moves/tempering.py,sha256=e2doT8jVWSuaPpVUKIkWQjRe20T0i98w70wi-dz7buo,23977
26
26
  eryn/pbar.py,sha256=uDDn8dMVHLD6EqZyk6vGhkOQwxgFm21Us9dz-nZE4oI,1330
27
27
  eryn/prior.py,sha256=3JhtkcD3TqZCpu54T_CO_M0_4wfabA9CLf_V_OVKoFA,16034
28
28
  eryn/state.py,sha256=x4HZNrGhxnR6Ia2JrVskJGDS1Uk3AgQHgxJ4384Hpzs,31456
29
- eryn/utils/__init__.py,sha256=HzlQs1wg3J1xdrZjIMO34QHd0ZT58SQFCKEdclj7vpM,250
29
+ eryn/utils/__init__.py,sha256=2jn40OhyhBETx0O6PExDQ104UigIe3xx76KBVZaYZSQ,248
30
30
  eryn/utils/periodic.py,sha256=w0C7YT6v7iVkvhP2OAg0UZ3aMZRUUCyLXrxAwT1pOeY,4745
31
+ eryn/utils/plot.py,sha256=RAzhocHyk7xyxPVnisnZ4ri8OObFL16KJG7XxkSITEM,56841
31
32
  eryn/utils/stopping.py,sha256=fX1np10U3B-fpI3dGqEPZfqeYt8dc0x3PQGwrvYbbFU,5095
32
33
  eryn/utils/transform.py,sha256=PqtGG__DAtIuRJm2SR9_ZuRyPvlUmh-eplgbpmZZghQ,9467
33
- eryn/utils/updates.py,sha256=U3T9UxPLabJzJuuB9s2OuX3vMD_2P7486SkgaFEkbLw,2137
34
- eryn/utils/utility.py,sha256=mgmfoL0BFFb3hho7OAQSJLO7T_erx6f6t38V-5yKSA4,11296
35
- eryn-1.2.5.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
36
- eryn-1.2.5.dist-info/METADATA,sha256=rex8RemF1bUpmVV86ZezubBZXxCZhyjneOmKd7qdbqA,6240
37
- eryn-1.2.5.dist-info/RECORD,,
34
+ eryn/utils/updates.py,sha256=W9oWUkUXzofTX21MDx8K89GMR_x-SYJERGphvGUcGF8,6003
35
+ eryn/utils/utility.py,sha256=9i3xe0SllA31jWvO_D39dGN_mi8r_va8Pe-dOWhasaM,11280
36
+ eryn-1.2.6.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
37
+ eryn-1.2.6.dist-info/METADATA,sha256=qN0g_VqhB1a9_uYFKzzSorCQBfLnecSB9MyfCU-N3gY,6290
38
+ eryn-1.2.6.dist-info/RECORD,,
File without changes