westpa 2022.13__cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.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.
Files changed (162) 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 +749 -0
  5. westpa/analysis/statistics.py +27 -0
  6. westpa/analysis/trajectories.py +369 -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 +597 -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 +557 -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 +832 -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_timings.py +113 -0
  38. westpa/cli/tools/w_trace.py +599 -0
  39. westpa/core/__init__.py +0 -0
  40. westpa/core/_rc.py +673 -0
  41. westpa/core/binning/__init__.py +55 -0
  42. westpa/core/binning/_assign.c +36018 -0
  43. westpa/core/binning/_assign.cpython-312-aarch64-linux-gnu.so +0 -0
  44. westpa/core/binning/_assign.pyx +370 -0
  45. westpa/core/binning/assign.py +454 -0
  46. westpa/core/binning/binless.py +96 -0
  47. westpa/core/binning/binless_driver.py +54 -0
  48. westpa/core/binning/binless_manager.py +189 -0
  49. westpa/core/binning/bins.py +47 -0
  50. westpa/core/binning/mab.py +506 -0
  51. westpa/core/binning/mab_driver.py +54 -0
  52. westpa/core/binning/mab_manager.py +197 -0
  53. westpa/core/data_manager.py +1761 -0
  54. westpa/core/extloader.py +74 -0
  55. westpa/core/h5io.py +1079 -0
  56. westpa/core/kinetics/__init__.py +24 -0
  57. westpa/core/kinetics/_kinetics.c +45174 -0
  58. westpa/core/kinetics/_kinetics.cpython-312-aarch64-linux-gnu.so +0 -0
  59. westpa/core/kinetics/_kinetics.pyx +815 -0
  60. westpa/core/kinetics/events.py +147 -0
  61. westpa/core/kinetics/matrates.py +156 -0
  62. westpa/core/kinetics/rate_averaging.py +266 -0
  63. westpa/core/progress.py +218 -0
  64. westpa/core/propagators/__init__.py +54 -0
  65. westpa/core/propagators/executable.py +592 -0
  66. westpa/core/propagators/loaders.py +196 -0
  67. westpa/core/reweight/__init__.py +14 -0
  68. westpa/core/reweight/_reweight.c +36899 -0
  69. westpa/core/reweight/_reweight.cpython-312-aarch64-linux-gnu.so +0 -0
  70. westpa/core/reweight/_reweight.pyx +439 -0
  71. westpa/core/reweight/matrix.py +126 -0
  72. westpa/core/segment.py +119 -0
  73. westpa/core/sim_manager.py +839 -0
  74. westpa/core/states.py +359 -0
  75. westpa/core/systems.py +93 -0
  76. westpa/core/textio.py +74 -0
  77. westpa/core/trajectory.py +603 -0
  78. westpa/core/we_driver.py +910 -0
  79. westpa/core/wm_ops.py +43 -0
  80. westpa/core/yamlcfg.py +298 -0
  81. westpa/fasthist/__init__.py +34 -0
  82. westpa/fasthist/_fasthist.c +38755 -0
  83. westpa/fasthist/_fasthist.cpython-312-aarch64-linux-gnu.so +0 -0
  84. westpa/fasthist/_fasthist.pyx +222 -0
  85. westpa/mclib/__init__.py +271 -0
  86. westpa/mclib/__main__.py +28 -0
  87. westpa/mclib/_mclib.c +34610 -0
  88. westpa/mclib/_mclib.cpython-312-aarch64-linux-gnu.so +0 -0
  89. westpa/mclib/_mclib.pyx +226 -0
  90. westpa/oldtools/__init__.py +4 -0
  91. westpa/oldtools/aframe/__init__.py +35 -0
  92. westpa/oldtools/aframe/atool.py +75 -0
  93. westpa/oldtools/aframe/base_mixin.py +26 -0
  94. westpa/oldtools/aframe/binning.py +178 -0
  95. westpa/oldtools/aframe/data_reader.py +560 -0
  96. westpa/oldtools/aframe/iter_range.py +200 -0
  97. westpa/oldtools/aframe/kinetics.py +117 -0
  98. westpa/oldtools/aframe/mcbs.py +153 -0
  99. westpa/oldtools/aframe/output.py +39 -0
  100. westpa/oldtools/aframe/plotting.py +88 -0
  101. westpa/oldtools/aframe/trajwalker.py +126 -0
  102. westpa/oldtools/aframe/transitions.py +469 -0
  103. westpa/oldtools/cmds/__init__.py +0 -0
  104. westpa/oldtools/cmds/w_ttimes.py +361 -0
  105. westpa/oldtools/files.py +34 -0
  106. westpa/oldtools/miscfn.py +23 -0
  107. westpa/oldtools/stats/__init__.py +4 -0
  108. westpa/oldtools/stats/accumulator.py +35 -0
  109. westpa/oldtools/stats/edfs.py +129 -0
  110. westpa/oldtools/stats/mcbs.py +96 -0
  111. westpa/tools/__init__.py +33 -0
  112. westpa/tools/binning.py +472 -0
  113. westpa/tools/core.py +340 -0
  114. westpa/tools/data_reader.py +159 -0
  115. westpa/tools/dtypes.py +31 -0
  116. westpa/tools/iter_range.py +198 -0
  117. westpa/tools/kinetics_tool.py +343 -0
  118. westpa/tools/plot.py +283 -0
  119. westpa/tools/progress.py +17 -0
  120. westpa/tools/selected_segs.py +154 -0
  121. westpa/tools/wipi.py +751 -0
  122. westpa/trajtree/__init__.py +4 -0
  123. westpa/trajtree/_trajtree.c +17829 -0
  124. westpa/trajtree/_trajtree.cpython-312-aarch64-linux-gnu.so +0 -0
  125. westpa/trajtree/_trajtree.pyx +130 -0
  126. westpa/trajtree/trajtree.py +117 -0
  127. westpa/westext/__init__.py +0 -0
  128. westpa/westext/adaptvoronoi/__init__.py +3 -0
  129. westpa/westext/adaptvoronoi/adaptVor_driver.py +214 -0
  130. westpa/westext/hamsm_restarting/__init__.py +3 -0
  131. westpa/westext/hamsm_restarting/example_overrides.py +35 -0
  132. westpa/westext/hamsm_restarting/restart_driver.py +1165 -0
  133. westpa/westext/stringmethod/__init__.py +11 -0
  134. westpa/westext/stringmethod/fourier_fitting.py +69 -0
  135. westpa/westext/stringmethod/string_driver.py +253 -0
  136. westpa/westext/stringmethod/string_method.py +306 -0
  137. westpa/westext/weed/BinCluster.py +180 -0
  138. westpa/westext/weed/ProbAdjustEquil.py +100 -0
  139. westpa/westext/weed/UncertMath.py +247 -0
  140. westpa/westext/weed/__init__.py +10 -0
  141. westpa/westext/weed/weed_driver.py +192 -0
  142. westpa/westext/wess/ProbAdjust.py +101 -0
  143. westpa/westext/wess/__init__.py +6 -0
  144. westpa/westext/wess/wess_driver.py +217 -0
  145. westpa/work_managers/__init__.py +57 -0
  146. westpa/work_managers/core.py +396 -0
  147. westpa/work_managers/environment.py +134 -0
  148. westpa/work_managers/mpi.py +318 -0
  149. westpa/work_managers/processes.py +201 -0
  150. westpa/work_managers/serial.py +28 -0
  151. westpa/work_managers/threads.py +79 -0
  152. westpa/work_managers/zeromq/__init__.py +20 -0
  153. westpa/work_managers/zeromq/core.py +635 -0
  154. westpa/work_managers/zeromq/node.py +131 -0
  155. westpa/work_managers/zeromq/work_manager.py +526 -0
  156. westpa/work_managers/zeromq/worker.py +320 -0
  157. westpa-2022.13.dist-info/METADATA +179 -0
  158. westpa-2022.13.dist-info/RECORD +162 -0
  159. westpa-2022.13.dist-info/WHEEL +7 -0
  160. westpa-2022.13.dist-info/entry_points.txt +30 -0
  161. westpa-2022.13.dist-info/licenses/LICENSE +21 -0
  162. westpa-2022.13.dist-info/top_level.txt +1 -0
westpa/core/wm_ops.py ADDED
@@ -0,0 +1,43 @@
1
+ import westpa
2
+
3
+ import logging
4
+
5
+ log = logging.getLogger(__name__)
6
+
7
+
8
+ def get_pcoord(state):
9
+ log.debug('getting progress coordinate for {!r}'.format(state))
10
+ propagator = westpa.rc.get_propagator()
11
+ propagator.get_pcoord(state)
12
+ return state
13
+
14
+
15
+ def gen_istate(basis_state, initial_state):
16
+ log.debug('generating initial state from {!r} (into {!r})'.format(basis_state, initial_state))
17
+ propagator = westpa.rc.get_propagator()
18
+ propagator.update_basis_initial_states([basis_state], [initial_state])
19
+ propagator.gen_istate(basis_state, initial_state)
20
+ return basis_state, initial_state
21
+
22
+
23
+ def prep_iter(n_iter, segments):
24
+ log.debug('propagator.prepare_iteration(...)')
25
+ propagator = westpa.rc.get_propagator()
26
+ propagator.clear_basis_initial_states()
27
+ propagator.prepare_iteration(n_iter, segments)
28
+
29
+
30
+ def post_iter(n_iter, segments):
31
+ log.debug('propagator.finalize_iteration(...)')
32
+ propagator = westpa.rc.get_propagator()
33
+ propagator.finalize_iteration(n_iter, segments)
34
+
35
+
36
+ def propagate(basis_states, initial_states, segments):
37
+ propagator = westpa.rc.get_propagator()
38
+ propagator.update_basis_initial_states(basis_states, initial_states)
39
+ outgoing_ids = [segment.seg_id for segment in segments]
40
+ incoming_segments = {segment.seg_id: segment for segment in propagator.propagate(segments)}
41
+ if log.isEnabledFor(logging.DEBUG):
42
+ log.debug('propagated {:d} segments'.format(len(incoming_segments)))
43
+ return [incoming_segments[seg_id] for seg_id in outgoing_ids]
westpa/core/yamlcfg.py ADDED
@@ -0,0 +1,298 @@
1
+ '''
2
+ YAML-based configuration files for WESTPA
3
+ '''
4
+
5
+ import os
6
+ import warnings
7
+ import yaml
8
+
9
+ try:
10
+ from yaml import CLoader as YLoader
11
+ except ImportError:
12
+ # fall back on Python implementation
13
+ from yaml import Loader as YLoader
14
+
15
+ from . import extloader
16
+
17
+ NotProvided = object()
18
+
19
+
20
+ class ConfigValueWarning(UserWarning):
21
+ pass
22
+
23
+
24
+ def warn_dubious_config_entry(entry, value, expected_type=None, category=ConfigValueWarning, stacklevel=1):
25
+ if expected_type:
26
+ warnings.warn(
27
+ 'dubious configuration entry {}: {} (expected type {})'.format(entry, value, expected_type), category, stacklevel + 1
28
+ )
29
+ else:
30
+ warnings.warn('dubious configuration entry {}: {}'.format(entry, value), category, stacklevel + 1)
31
+
32
+
33
+ def check_bool(value, action='warn'):
34
+ '''Check that the given ``value`` is boolean in type. If not, either
35
+ raise a warning (if ``action=='warn'``) or an exception (``action=='raise'``).
36
+ '''
37
+ if action not in ('warn', 'raise'):
38
+ raise ValueError('invalid action {!r}'.format(action))
39
+
40
+ if not isinstance(value, bool):
41
+ if action == 'warn':
42
+ warnings.warn(
43
+ 'dubious boolean value {!r}, will be treated as {!r}'.format(value, bool(value)),
44
+ category=ConfigValueWarning,
45
+ stacklevel=2,
46
+ )
47
+ elif action == 'raise':
48
+ raise ValueError('dubious boolean value {!r}, would be treated as {!r}'.format(value, bool(value)))
49
+ else:
50
+ return value
51
+
52
+
53
+ class ConfigItemMissing(KeyError):
54
+ def __init__(self, key, message=None):
55
+ self.key = key
56
+ if message is None:
57
+ message = 'configuration item missing: {!r}'.format(key)
58
+ super().__init__(message)
59
+
60
+
61
+ class ConfigItemTypeError(TypeError):
62
+ def __init__(self, key, expected_type, message=None):
63
+ self.key = key
64
+ self.expected_type = expected_type
65
+ if message is None:
66
+ message = 'configuration item {!r} must have type {!r}'.format(key, expected_type)
67
+ super().__init__(message)
68
+
69
+
70
+ class ConfigValueError(ValueError):
71
+ def __init__(self, key, value, message=None):
72
+ self.key = key
73
+ self.value = value
74
+ if message is None:
75
+ message = 'bad value {!r} for configuration item {!r}'.format(key, value)
76
+ super().__init__(message)
77
+
78
+
79
+ class YAMLConfig:
80
+ preload_config_files = ['/etc/westpa/westrc', os.path.expanduser('~/.westrc')]
81
+
82
+ def __init__(self):
83
+ self._data = {}
84
+
85
+ for source in self.preload_config_files:
86
+ self.update_from_file(source, required=False)
87
+
88
+ def __repr__(self):
89
+ return repr(self._data)
90
+
91
+ def update_from_file(self, file, required=True):
92
+ if isinstance(file, str):
93
+ try:
94
+ file = open(file, 'rt')
95
+ except IOError:
96
+ if required:
97
+ raise
98
+ else:
99
+ return
100
+
101
+ self._data.update(yaml.load(file, Loader=YLoader))
102
+ file.close()
103
+
104
+ def _normalize_key(self, key):
105
+ if isinstance(key, str):
106
+ key = (key,)
107
+ else:
108
+ try:
109
+ key = tuple(key)
110
+ except TypeError:
111
+ key = (key,)
112
+ return key
113
+
114
+ def _resolve_object_chain(self, key, last=None):
115
+ if last is None:
116
+ last = len(key)
117
+ objects = [self._data[key[0]]]
118
+ for subkey in key[1:last]:
119
+ objects.append(objects[-1][subkey])
120
+ return objects
121
+
122
+ def __getitem__(self, key):
123
+ key = self._normalize_key(key)
124
+ return self._resolve_object_chain(key)[-1]
125
+
126
+ def __setitem__(self, key, value):
127
+ key = self._normalize_key(key)
128
+
129
+ try:
130
+ objchain = self._resolve_object_chain(key, -1)
131
+ except KeyError:
132
+ # creation of a new (possibly nested) entry
133
+ val = self._data
134
+ for keypart in key[:-1]:
135
+ try:
136
+ val = val[keypart]
137
+ except KeyError:
138
+ val[keypart] = {}
139
+ val = val[keypart]
140
+ try:
141
+ val = val[key[-1]]
142
+ except KeyError:
143
+ val[key[-1]] = value
144
+ else:
145
+ objchain[-1][key[-1]] = value
146
+
147
+ def __delitem__(self, key):
148
+ key = self._normalize_key(key)
149
+ objchain = self._resolve_object_chain(key, -1)
150
+ del objchain[-1][key[-1]]
151
+
152
+ def __contains__(self, key):
153
+ try:
154
+ self[key]
155
+ except (KeyError, TypeError):
156
+ return False
157
+ else:
158
+ return True
159
+
160
+ def require(self, key, type_=None):
161
+ '''Ensure that a configuration item with the given ``key`` is present. If
162
+ the optional ``type_`` is given, additionally require that the item has that
163
+ type.'''
164
+
165
+ try:
166
+ item = self[key]
167
+ except KeyError:
168
+ raise ConfigItemMissing(key)
169
+
170
+ if type_ is not None:
171
+ if not isinstance(item, type_):
172
+ raise ConfigItemTypeError(item, type_)
173
+ return item
174
+
175
+ def require_type_if_present(self, key, type_):
176
+ '''Ensure that the configuration item with the given ``key`` has the
177
+ given type.'''
178
+
179
+ try:
180
+ item = self[key]
181
+ except KeyError:
182
+ return
183
+ else:
184
+ if not isinstance(item, type_):
185
+ raise ConfigItemTypeError(item, type_)
186
+
187
+ def coerce_type_if_present(self, key, type_):
188
+ try:
189
+ item = self[key]
190
+ except KeyError:
191
+ return
192
+ else:
193
+ if type_ is bool and not isinstance(item, bool):
194
+ warn_dubious_config_entry(key, item, bool)
195
+ self[key] = type_(item)
196
+
197
+ def get(self, key, default=None):
198
+ try:
199
+ return self[key]
200
+ except KeyError:
201
+ return default
202
+
203
+ def get_typed(self, key, type_, default=NotProvided):
204
+ try:
205
+ item = self[key]
206
+ except KeyError as ke:
207
+ if default is not NotProvided:
208
+ item = default
209
+ else:
210
+ raise ke
211
+
212
+ # Warn about possibly bad boolean
213
+ if type_ is bool and not isinstance(item, bool):
214
+ warn_dubious_config_entry(key, item, bool)
215
+
216
+ return type_(item)
217
+
218
+ def get_path(self, key, default=NotProvided, expandvars=True, expanduser=True, realpath=True, abspath=True):
219
+ try:
220
+ path = self[key]
221
+ except KeyError as ke:
222
+ if default is not NotProvided:
223
+ path = default
224
+ else:
225
+ raise ke
226
+
227
+ if expandvars:
228
+ path = os.path.expandvars(path)
229
+ if expanduser:
230
+ path = os.path.expanduser(path)
231
+ if realpath:
232
+ path = os.path.realpath(path)
233
+ if abspath:
234
+ path = os.path.abspath(path)
235
+
236
+ return path
237
+
238
+ def get_pathlist(self, key, default=NotProvided, sep=os.pathsep, expandvars=True, expanduser=True, realpath=True, abspath=True):
239
+ try:
240
+ paths = self[key]
241
+ except KeyError as ke:
242
+ if default is not NotProvided:
243
+ paths = default
244
+ else:
245
+ raise ke
246
+
247
+ try:
248
+ items = paths.split(sep)
249
+ except AttributeError:
250
+ # Default must have been something we can't process, like a list or None
251
+ # Just pass it through, since enforcing a restriction on what kind of
252
+ # default is passed is probably more counterproductive than any poor programming
253
+ # practice it encourages.
254
+ return paths
255
+
256
+ if expandvars:
257
+ items = list(map(os.path.expandvars, items))
258
+ if expanduser:
259
+ items = list(map(os.path.expanduser, items))
260
+ if realpath:
261
+ items = list(map(os.path.realpath, items))
262
+ if abspath:
263
+ items = list(map(os.path.abspath, items))
264
+
265
+ return items
266
+
267
+ def get_python_object(self, key, default=NotProvided, path=None):
268
+ try:
269
+ qualname = self[key]
270
+ except KeyError as ke:
271
+ if default is not NotProvided:
272
+ return default
273
+ else:
274
+ raise ke
275
+
276
+ return extloader.get_object(qualname, path)
277
+
278
+ def get_choice(self, key, choices, default=NotProvided, value_transform=None):
279
+ try:
280
+ value = self[key]
281
+ except KeyError:
282
+ if default is not NotProvided:
283
+ value = default
284
+ else:
285
+ raise
286
+
287
+ choices = set(choices)
288
+ if value_transform:
289
+ value = value_transform(value)
290
+ if value not in choices:
291
+ raise ConfigValueError(
292
+ key,
293
+ value,
294
+ message='bad value {!r} for configuration item {!r} (valid choices: {!r})'.format(
295
+ value, key, tuple(sorted(choices))
296
+ ),
297
+ )
298
+ return value
@@ -0,0 +1,34 @@
1
+ from ._fasthist import histnd # noqa
2
+
3
+ import numpy as np
4
+
5
+
6
+ def normhistnd(hist, binbounds):
7
+ '''Normalize the N-dimensional histogram ``hist`` with corresponding
8
+ bin boundaries ``binbounds``. Modifies ``hist`` in place and returns
9
+ the normalization factor used.'''
10
+
11
+ ndim = hist.ndim
12
+
13
+ if ndim != len(binbounds):
14
+ raise ValueError(
15
+ 'shape of histogram [{!r}] does not match bin boundary sets (there are {})'.format(hist.shape, len(binbounds))
16
+ )
17
+
18
+ diffs = [np.diff(bb) for bb in binbounds]
19
+
20
+ if ndim == 1:
21
+ assert diffs[0].shape == hist.shape
22
+ normfac = (hist * diffs[0]).sum()
23
+ else:
24
+ outers = np.multiply.outer(diffs[0], diffs[1])
25
+ for delta in diffs[2:]:
26
+ outers = np.multiply.outer(outers, delta)
27
+ assert outers.shape == hist.shape, 'hist shape {} != outers shape {}'.format(hist.shape, outers.shape)
28
+ # Divide by bin volumes
29
+ hist /= outers
30
+ normfac = hist.sum()
31
+ # normfac = (hist * outers).sum()
32
+
33
+ hist /= normfac
34
+ return normfac