westpa 2022.12__cp313-cp313-macosx_11_0_arm64.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.

Potentially problematic release.


This version of westpa might be problematic. Click here for more details.

Files changed (149) hide show
  1. westpa/__init__.py +14 -0
  2. westpa/_version.py +21 -0
  3. westpa/analysis/__init__.py +5 -0
  4. westpa/analysis/core.py +746 -0
  5. westpa/analysis/statistics.py +27 -0
  6. westpa/analysis/trajectories.py +360 -0
  7. westpa/cli/__init__.py +0 -0
  8. westpa/cli/core/__init__.py +0 -0
  9. westpa/cli/core/w_fork.py +152 -0
  10. westpa/cli/core/w_init.py +230 -0
  11. westpa/cli/core/w_run.py +77 -0
  12. westpa/cli/core/w_states.py +212 -0
  13. westpa/cli/core/w_succ.py +99 -0
  14. westpa/cli/core/w_truncate.py +68 -0
  15. westpa/cli/tools/__init__.py +0 -0
  16. westpa/cli/tools/ploterr.py +506 -0
  17. westpa/cli/tools/plothist.py +706 -0
  18. westpa/cli/tools/w_assign.py +596 -0
  19. westpa/cli/tools/w_bins.py +166 -0
  20. westpa/cli/tools/w_crawl.py +119 -0
  21. westpa/cli/tools/w_direct.py +547 -0
  22. westpa/cli/tools/w_dumpsegs.py +94 -0
  23. westpa/cli/tools/w_eddist.py +506 -0
  24. westpa/cli/tools/w_fluxanl.py +376 -0
  25. westpa/cli/tools/w_ipa.py +833 -0
  26. westpa/cli/tools/w_kinavg.py +127 -0
  27. westpa/cli/tools/w_kinetics.py +96 -0
  28. westpa/cli/tools/w_multi_west.py +414 -0
  29. westpa/cli/tools/w_ntop.py +213 -0
  30. westpa/cli/tools/w_pdist.py +515 -0
  31. westpa/cli/tools/w_postanalysis_matrix.py +82 -0
  32. westpa/cli/tools/w_postanalysis_reweight.py +53 -0
  33. westpa/cli/tools/w_red.py +491 -0
  34. westpa/cli/tools/w_reweight.py +780 -0
  35. westpa/cli/tools/w_select.py +226 -0
  36. westpa/cli/tools/w_stateprobs.py +111 -0
  37. westpa/cli/tools/w_trace.py +599 -0
  38. westpa/core/__init__.py +0 -0
  39. westpa/core/_rc.py +673 -0
  40. westpa/core/binning/__init__.py +55 -0
  41. westpa/core/binning/_assign.cpython-313-darwin.so +0 -0
  42. westpa/core/binning/assign.py +455 -0
  43. westpa/core/binning/binless.py +96 -0
  44. westpa/core/binning/binless_driver.py +54 -0
  45. westpa/core/binning/binless_manager.py +190 -0
  46. westpa/core/binning/bins.py +47 -0
  47. westpa/core/binning/mab.py +506 -0
  48. westpa/core/binning/mab_driver.py +54 -0
  49. westpa/core/binning/mab_manager.py +198 -0
  50. westpa/core/data_manager.py +1694 -0
  51. westpa/core/extloader.py +74 -0
  52. westpa/core/h5io.py +995 -0
  53. westpa/core/kinetics/__init__.py +24 -0
  54. westpa/core/kinetics/_kinetics.cpython-313-darwin.so +0 -0
  55. westpa/core/kinetics/events.py +147 -0
  56. westpa/core/kinetics/matrates.py +156 -0
  57. westpa/core/kinetics/rate_averaging.py +266 -0
  58. westpa/core/progress.py +218 -0
  59. westpa/core/propagators/__init__.py +54 -0
  60. westpa/core/propagators/executable.py +719 -0
  61. westpa/core/reweight/__init__.py +14 -0
  62. westpa/core/reweight/_reweight.cpython-313-darwin.so +0 -0
  63. westpa/core/reweight/matrix.py +126 -0
  64. westpa/core/segment.py +119 -0
  65. westpa/core/sim_manager.py +835 -0
  66. westpa/core/states.py +359 -0
  67. westpa/core/systems.py +93 -0
  68. westpa/core/textio.py +74 -0
  69. westpa/core/trajectory.py +330 -0
  70. westpa/core/we_driver.py +910 -0
  71. westpa/core/wm_ops.py +43 -0
  72. westpa/core/yamlcfg.py +391 -0
  73. westpa/fasthist/__init__.py +34 -0
  74. westpa/fasthist/_fasthist.cpython-313-darwin.so +0 -0
  75. westpa/mclib/__init__.py +271 -0
  76. westpa/mclib/__main__.py +28 -0
  77. westpa/mclib/_mclib.cpython-313-darwin.so +0 -0
  78. westpa/oldtools/__init__.py +4 -0
  79. westpa/oldtools/aframe/__init__.py +35 -0
  80. westpa/oldtools/aframe/atool.py +75 -0
  81. westpa/oldtools/aframe/base_mixin.py +26 -0
  82. westpa/oldtools/aframe/binning.py +178 -0
  83. westpa/oldtools/aframe/data_reader.py +560 -0
  84. westpa/oldtools/aframe/iter_range.py +200 -0
  85. westpa/oldtools/aframe/kinetics.py +117 -0
  86. westpa/oldtools/aframe/mcbs.py +153 -0
  87. westpa/oldtools/aframe/output.py +39 -0
  88. westpa/oldtools/aframe/plotting.py +90 -0
  89. westpa/oldtools/aframe/trajwalker.py +126 -0
  90. westpa/oldtools/aframe/transitions.py +469 -0
  91. westpa/oldtools/cmds/__init__.py +0 -0
  92. westpa/oldtools/cmds/w_ttimes.py +361 -0
  93. westpa/oldtools/files.py +34 -0
  94. westpa/oldtools/miscfn.py +23 -0
  95. westpa/oldtools/stats/__init__.py +4 -0
  96. westpa/oldtools/stats/accumulator.py +35 -0
  97. westpa/oldtools/stats/edfs.py +129 -0
  98. westpa/oldtools/stats/mcbs.py +96 -0
  99. westpa/tools/__init__.py +33 -0
  100. westpa/tools/binning.py +472 -0
  101. westpa/tools/core.py +340 -0
  102. westpa/tools/data_reader.py +159 -0
  103. westpa/tools/dtypes.py +31 -0
  104. westpa/tools/iter_range.py +198 -0
  105. westpa/tools/kinetics_tool.py +340 -0
  106. westpa/tools/plot.py +283 -0
  107. westpa/tools/progress.py +17 -0
  108. westpa/tools/selected_segs.py +154 -0
  109. westpa/tools/wipi.py +751 -0
  110. westpa/trajtree/__init__.py +4 -0
  111. westpa/trajtree/_trajtree.cpython-313-darwin.so +0 -0
  112. westpa/trajtree/trajtree.py +117 -0
  113. westpa/westext/__init__.py +0 -0
  114. westpa/westext/adaptvoronoi/__init__.py +3 -0
  115. westpa/westext/adaptvoronoi/adaptVor_driver.py +214 -0
  116. westpa/westext/hamsm_restarting/__init__.py +3 -0
  117. westpa/westext/hamsm_restarting/example_overrides.py +35 -0
  118. westpa/westext/hamsm_restarting/restart_driver.py +1165 -0
  119. westpa/westext/stringmethod/__init__.py +11 -0
  120. westpa/westext/stringmethod/fourier_fitting.py +69 -0
  121. westpa/westext/stringmethod/string_driver.py +253 -0
  122. westpa/westext/stringmethod/string_method.py +306 -0
  123. westpa/westext/weed/BinCluster.py +180 -0
  124. westpa/westext/weed/ProbAdjustEquil.py +100 -0
  125. westpa/westext/weed/UncertMath.py +247 -0
  126. westpa/westext/weed/__init__.py +10 -0
  127. westpa/westext/weed/weed_driver.py +192 -0
  128. westpa/westext/wess/ProbAdjust.py +101 -0
  129. westpa/westext/wess/__init__.py +6 -0
  130. westpa/westext/wess/wess_driver.py +217 -0
  131. westpa/work_managers/__init__.py +57 -0
  132. westpa/work_managers/core.py +396 -0
  133. westpa/work_managers/environment.py +134 -0
  134. westpa/work_managers/mpi.py +318 -0
  135. westpa/work_managers/processes.py +187 -0
  136. westpa/work_managers/serial.py +28 -0
  137. westpa/work_managers/threads.py +79 -0
  138. westpa/work_managers/zeromq/__init__.py +20 -0
  139. westpa/work_managers/zeromq/core.py +641 -0
  140. westpa/work_managers/zeromq/node.py +131 -0
  141. westpa/work_managers/zeromq/work_manager.py +526 -0
  142. westpa/work_managers/zeromq/worker.py +320 -0
  143. westpa-2022.12.dist-info/AUTHORS +22 -0
  144. westpa-2022.12.dist-info/LICENSE +21 -0
  145. westpa-2022.12.dist-info/METADATA +193 -0
  146. westpa-2022.12.dist-info/RECORD +149 -0
  147. westpa-2022.12.dist-info/WHEEL +6 -0
  148. westpa-2022.12.dist-info/entry_points.txt +29 -0
  149. westpa-2022.12.dist-info/top_level.txt +1 -0
@@ -0,0 +1,218 @@
1
+ import collections
2
+ import threading
3
+ import time
4
+
5
+ import blessings # @UnresolvedImport
6
+
7
+ import numpy as np
8
+ from scipy.stats import linregress
9
+
10
+
11
+ def nop():
12
+ pass
13
+
14
+
15
+ class ProgressIndicator:
16
+ def __init__(self, stream=None, interval=1):
17
+ self.terminal = blessings.Terminal(stream=stream)
18
+ self.interval = interval # how often the status is updated
19
+
20
+ self._operation = None # string describing operation
21
+ self._extent = None # how far we have to go, total
22
+ self._progress = 0 # how far we've gone
23
+
24
+ self._endloop = False
25
+ self._startup_event = threading.Event()
26
+ self._event = threading.Event()
27
+
28
+ self._last_update = None
29
+ self._last_operation = None
30
+ self._operation_start = None
31
+ self._progress_history = collections.deque(maxlen=100)
32
+
33
+ try:
34
+ self.flush_output = self.terminal.stream.flush
35
+ except AttributeError:
36
+ self.flush_output = nop
37
+
38
+ self.fancy = self.terminal.is_a_tty
39
+
40
+ def _completion_est(self):
41
+ if self._extent is None:
42
+ return 'unknown'
43
+
44
+ history = np.array(self._progress_history)
45
+ if not len(history):
46
+ return 'unknown'
47
+ history[:, 1] -= self._extent
48
+ (_slope, intercept, _r, _p, _stderr) = linregress(history[:, 1], history[:, 0])
49
+ if not np.isfinite(intercept):
50
+ return 'unknown'
51
+ else:
52
+ total_seconds_remaining = intercept - time.time()
53
+
54
+ if total_seconds_remaining < 60:
55
+ return 'less than 1 minute'
56
+
57
+ # 1 minute or more remains
58
+ minutes = total_seconds_remaining / 60
59
+ if minutes < 60:
60
+ minutes = int(round(minutes))
61
+ return 'about {:d} {}'.format(minutes, 'minutes' if minutes > 1 else 'minute')
62
+
63
+ # 1 hour or more remains
64
+ hours, minutes = divmod(minutes, 60)
65
+ days, hours = divmod(hours, 24)
66
+ days = int(days)
67
+ hours = int(round(hours))
68
+ minutes = int(round(minutes))
69
+ if days > 0:
70
+ return 'about {:d} {}, {:d} {}'.format(days, 'days' if days > 1 else 'day', hours, 'hours' if hours > 1 else 'hour')
71
+ else:
72
+ return 'about {:d} {}, {:d} {}'.format(
73
+ hours, 'hours' if hours > 1 else 'hour', minutes, 'minutes' if minutes > 1 else 'minute'
74
+ )
75
+
76
+ def draw_fancy(self):
77
+ operation_text = 'Operation: '
78
+ progress_text = 'Progress: '
79
+ remaining_text = 'Time remaining: '
80
+
81
+ term = self.terminal
82
+ stream = self.terminal.stream
83
+
84
+ stream.write('{t.clear_eol}{t.bold}{}{t.normal}{}\n'.format(operation_text, self._operation or '', t=term))
85
+
86
+ if self._extent:
87
+ width = term.width
88
+ pct_done = self.progress / self._extent
89
+ pct_part = '{:<4.0%} '.format(pct_done)
90
+
91
+ barwidth = width - len(progress_text) - 2 - len(pct_part)
92
+ neqs = int(round(pct_done * barwidth))
93
+ eqs = '=' * neqs
94
+ spaces = ' ' * (barwidth - neqs)
95
+
96
+ stream.write(
97
+ '{t.clear_eol}{t.bold}{progress_text}{t.normal}{pct_part}{t.bold}[{t.normal}{eqs}{spaces}{t.bold}]{t.normal}\n'.format(
98
+ t=term, progress_text=progress_text, pct_part=pct_part, eqs=eqs, spaces=spaces
99
+ )
100
+ )
101
+
102
+ completion_est = self._completion_est()
103
+ stream.write('{t.clear_eol}{t.bold}{}{t.normal}{}\n'.format(remaining_text, completion_est, t=term))
104
+ stream.write('{t.move_up}'.format(t=term) * 2)
105
+ stream.write('{t.move_up}'.format(t=term))
106
+
107
+ self._last_update = time.time()
108
+
109
+ def draw_simple(self):
110
+ if self._operation != self._last_operation:
111
+ self.terminal.stream.write((self._operation or '(unknown)') + '...\n')
112
+ self._last_operation = self._operation
113
+ self._last_update = time.time()
114
+
115
+ def draw(self):
116
+ if not self._operation:
117
+ return
118
+ if self.fancy:
119
+ self.draw_fancy()
120
+ else:
121
+ self.draw_simple()
122
+
123
+ def clear(self):
124
+ if self.fancy:
125
+ if self._extent:
126
+ nlines = 3
127
+ else:
128
+ nlines = 1
129
+
130
+ for _i in range(nlines):
131
+ self.terminal.stream.write('{t.clear_eol}{t.move_down}'.format(t=self.terminal))
132
+ for _i in range(nlines):
133
+ self.terminal.stream.write('{t.move_up}'.format(t=self.terminal))
134
+
135
+ @property
136
+ def operation(self):
137
+ return self._operation
138
+
139
+ @operation.setter
140
+ def operation(self, op):
141
+ if self._operation is not None:
142
+ self.clear()
143
+ self._operation = op
144
+ self._operation_start = time.time()
145
+ self._progress_history.clear()
146
+ self._event.set()
147
+
148
+ @property
149
+ def extent(self):
150
+ return self._extent
151
+
152
+ @extent.setter
153
+ def extent(self, ext):
154
+ self._extent = ext
155
+ self._progress_history.clear()
156
+ self._event.set()
157
+
158
+ @property
159
+ def progress(self):
160
+ return self._progress
161
+
162
+ @progress.setter
163
+ def progress(self, p):
164
+ self._progress = p
165
+ self._progress_history.append((time.time(), p))
166
+
167
+ def new_operation(self, operation, extent=None, progress=0):
168
+ self.operation = operation
169
+ self.progress = progress
170
+ self._extent = extent
171
+ self._event.set()
172
+
173
+ def _reporter_loop(self):
174
+ self._startup_event.set()
175
+ while not self._endloop:
176
+ self._event.wait(self.interval)
177
+ self._event.clear()
178
+ if self._last_operation != self._operation or time.time() - self._last_update >= self.interval:
179
+ self.draw()
180
+ self.flush_output()
181
+
182
+ def start(self):
183
+ if self.fancy:
184
+ self.terminal.stream.write(self.terminal.hide_cursor)
185
+ self._endloop = False
186
+ t = threading.Thread(target=self._reporter_loop)
187
+ t.daemon = True
188
+ t.start()
189
+ self._startup_event.wait()
190
+ self.flush_output()
191
+
192
+ def stop(self):
193
+ self._endloop = True
194
+ self._event.set()
195
+
196
+ self.clear()
197
+ if self.fancy:
198
+ self.terminal.stream.write(self.terminal.normal_cursor)
199
+ self.flush_output()
200
+
201
+ def __enter__(self):
202
+ self.start()
203
+ return self
204
+
205
+ def __exit__(self, exc_type, exc_val, exc_tb):
206
+ self.stop()
207
+ return False
208
+
209
+
210
+ if __name__ == '__main__':
211
+ with ProgressIndicator() as pi:
212
+ pi.operation = 'Test 1'
213
+ pi.extent = 10
214
+ for i in range(10):
215
+ pi.progress = i + 1
216
+ time.sleep(2)
217
+
218
+ time.sleep(0.2)
@@ -0,0 +1,54 @@
1
+ import westpa
2
+ import itertools
3
+
4
+
5
+ def blocked_iter(blocksize, iterable, fillvalue=None):
6
+ # From the Python "itertools recipes" (grouper)
7
+ args = [iter(iterable)] * blocksize
8
+ return itertools.zip_longest(fillvalue=fillvalue, *args)
9
+
10
+
11
+ class WESTPropagator:
12
+ def __init__(self, rc=None):
13
+ # For maximum flexibility, the basis states and initial states valid
14
+ # at the point in the simulation when the propgator is used must be
15
+ # available in several routines, and it is inconvenient to pass them
16
+ # to every routine that needs them. A currently-reasonable-seeming solution
17
+ # is to store at least the basis states and initial states necessary for
18
+ # the current operation (propagation, etc). The set_basis_initial_states() function
19
+ # accomplishes this. They are stored as dictionaries of state_id -> state,
20
+ # so they can be looked up by ID without needing to store them all (and
21
+ # thus potentially send them all over the wire when only one of them is needed, e.g.)
22
+ self.basis_states = {}
23
+ self.initial_states = {}
24
+
25
+ self.rc = rc or westpa.rc
26
+
27
+ def prepare_iteration(self, n_iter, segments):
28
+ """Perform any necessary per-iteration preparation. This is run by the work manager."""
29
+ pass
30
+
31
+ def finalize_iteration(self, n_iter, segments):
32
+ """Perform any necessary post-iteration cleanup. This is run by the work manager."""
33
+ pass
34
+
35
+ # Specific functions required by the WEST framework
36
+ def get_pcoord(self, state):
37
+ '''Get the progress coordinate of the given basis or initial state.'''
38
+ raise NotImplementedError
39
+
40
+ def gen_istate(self, basis_state, initial_state):
41
+ '''Generate a new initial state from the given basis state.'''
42
+ raise NotImplementedError
43
+
44
+ def propagate(self, segments):
45
+ """Propagate one or more segments, including any necessary per-iteration setup and teardown for this propagator."""
46
+ raise NotImplementedError
47
+
48
+ def clear_basis_initial_states(self):
49
+ self.basis_states = {}
50
+ self.initial_states = {}
51
+
52
+ def update_basis_initial_states(self, basis_states, initial_states):
53
+ self.basis_states.update({state.state_id: state for state in basis_states})
54
+ self.initial_states.update({state.state_id: state for state in initial_states})