Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup of WESTPA-for CI testing #20

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ ipython_config.py
dmypy.json


# idea env
.idea/

# vim
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
Expand Down
4 changes: 2 additions & 2 deletions src/westpa/core/_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from westpa.core.binning.assign import BinMapper
from westpa.core.binning import RectilinearBinMapper, RecursiveBinMapper, MABBinMapper, BinlessMapper
from .yamlcfg import YAMLConfig
from .yamlcfg import YAMLSystem
from .systems import WESTSystem
from . import extloader
from ..work_managers import SerialWorkManager

Expand Down Expand Up @@ -548,7 +548,7 @@ def system_from_yaml(self, system_dict):
the parsed settings from the config file.
"""

yamlSystem = YAMLSystem()
yamlSystem = WESTSystem()
print("System building only off of the configuration file")
# Now for the building of the system from YAML we need to use
# require for these settings since they are musts.
Expand Down
1 change: 0 additions & 1 deletion src/westpa/core/binning/_assign.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ cpdef rectilinear_assign(coord_t[:,:] coords,

# backwards iteration needs signed values, so that the final != -1 works
for idim in range(ndim-1,-1,-1):
found = 0
cval = coords[icoord,idim]
boundlen = boundlens[idim]
bvec = <coord_t*> boundvecs[idim]
Expand Down
2 changes: 1 addition & 1 deletion src/westpa/core/propagators/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def pcoord_loader(fieldname, pcoord_return_filename, destobj, single_point):
pcoord.shape = expected_shape
if pcoord.shape != expected_shape:
raise ValueError(
'progress coordinate data has incorrect shape {!r} [expected {!r}] Check pcoord.err or seg_logs for more information.'.format(
'progress coordinate data has incorrect shape {!r} [expected {!r}] Check the get_pcoord stderr or seg_logs for more information.'.format(
pcoord.shape, expected_shape
)
)
Expand Down
32 changes: 15 additions & 17 deletions src/westpa/core/reweight/_reweight.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,38 @@

from __future__ import print_function,division
import cython
import numpy
import numpy as np
import h5py
from scipy.sparse import csgraph
import warnings
from collections import Counter
cimport numpy
cimport numpy as np
cimport scipy.linalg
cimport scipy.linalg.cython_lapack as cl
import scipy.linalg
from libc.math cimport isnan

ctypedef numpy.uint16_t index_t
ctypedef numpy.float64_t weight_t
ctypedef numpy.uint8_t bool_t
ctypedef numpy.int64_t trans_t
ctypedef numpy.uint_t uint_t # 32 bits on 32-bit systems, 64 bits on 64-bit systems
ctypedef np.uint16_t index_t
ctypedef np.float64_t weight_t
ctypedef np.uint8_t bool_t
ctypedef np.int64_t trans_t
ctypedef np.uint_t uint_t # 32 bits on 32-bit systems, 64 bits on 64-bit systems
ctypedef unsigned short Ushort
ctypedef double complex Cdouble

weight_dtype = numpy.float64
index_dtype = numpy.uint16
bool_dtype = numpy.bool_
intc_dtype = numpy.intc
weight_dtype = np.float64
index_dtype = np.uint16
bool_dtype = np.bool_
intc_dtype = np.intc

@cython.boundscheck(False)
@cython.wraparound(False)
cpdef stats_process(numpy.ndarray[index_t, ndim=2] bin_assignments,
numpy.ndarray[weight_t, ndim=1] weights,
numpy.ndarray[weight_t, ndim=2] fluxes,
numpy.ndarray[weight_t, ndim=1] populations,
numpy.ndarray[trans_t, ndim=2] trans,
numpy.ndarray[index_t, ndim=2] mask,
cpdef stats_process(np.ndarray[index_t, ndim=2] bin_assignments,
np.ndarray[weight_t, ndim=1] weights,
np.ndarray[weight_t, ndim=2] fluxes,
np.ndarray[weight_t, ndim=1] populations,
np.ndarray[trans_t, ndim=2] trans,
np.ndarray[index_t, ndim=2] mask,
str interval='timepoint' ):
cdef:
Py_ssize_t i,k
Expand Down
2 changes: 1 addition & 1 deletion src/westpa/core/sim_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def initialize_simulation(self, basis_states, target_states, start_states, segs_

# Process start states
# Unlike the above, does not create an ibstate group.
# TODO: Should it? I don't think so, if needed it can be traced back through basis_auxref
# Should it? I don't think so, if needed it can be traced back through basis_auxref

# Here, we are trying to assign a state_id to the start state to be initialized, without actually
# saving it to the ibstates records in any of the h5 files. It might actually be a problem
Expand Down
5 changes: 2 additions & 3 deletions src/westpa/core/we_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ def new_iteration(self, initial_states=None, target_states=None, new_weights=Non

self.initial_binning = self.bin_mapper.construct_bins()
self.final_binning = self.bin_mapper.construct_bins()
self.next_iter_binning = None

flux_matrix = self.flux_matrix = np.zeros((nbins, nbins), dtype=np.float64)
transition_matrix = self.transition_matrix = np.zeros((nbins, nbins), np.uint)
Expand Down Expand Up @@ -530,7 +529,7 @@ def _split_by_weight(self, bin, target_count, ideal_weight):
to_split = segments[weights > self.weight_split_threshold * ideal_weight]

for segment in to_split:
m = int(math.ceil(segment.weight / ideal_weight))
m = math.ceil(segment.weight / ideal_weight)
bin.remove(segment)
new_segments_list = self._split_walker(segment, m, bin)
bin.update(new_segments_list)
Expand Down Expand Up @@ -623,7 +622,7 @@ def _split_by_threshold(self, bin, subgroup):

to_split = segments[weights > self.largest_allowed_weight]
for segment in to_split:
m = int(math.ceil(segment.weight / self.largest_allowed_weight))
m = math.ceil(segment.weight / self.largest_allowed_weight)
bin.remove(segment)
subgroup.remove(segment)
new_segments_list = self._split_walker(segment, m, bin)
Expand Down
93 changes: 0 additions & 93 deletions src/westpa/core/yamlcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

import os
import warnings

import yaml
import numpy as np

try:
from yaml import CLoader as YLoader
Expand All @@ -15,10 +13,6 @@
from yaml import Loader as YLoader

from . import extloader
from .binning import NopMapper

# Only needed for temporary class
import westpa

NotProvided = object()

Expand Down Expand Up @@ -302,90 +296,3 @@ def get_choice(self, key, choices, default=NotProvided, value_transform=None):
),
)
return value


# Temporary class here
class YAMLSystem:
'''A description of the system being simulated, including the dimensionality and
data type of the progress coordinate, the number of progress coordinate entries
expected from each segment, and binning. To construct a simulation, the user must
subclass WESTSystem and set several instance variables.

At a minimum, the user must subclass ``WESTSystem`` and override
:method:`initialize` to set the data type and dimensionality of progress
coordinate data and define a bin mapper.

:ivar pcoord_ndim: The number of dimensions in the progress coordinate.
Defaults to 1 (i.e. a one-dimensional progress
coordinate).
:ivar pcoord_dtype: The data type of the progress coordinate, which must be
callable (e.g. ``np.float32`` and ``long`` will work,
but ``'<f4'`` and ``'<i8'`` will not). Defaults to
``np.float64``.
:ivar pcoord_len: The length of the progress coordinate time series
generated by each segment, including *both* the initial
and final values. Defaults to 2 (i.e. only the initial
and final progress coordinate values for a segment are
returned from propagation).
:ivar bin_mapper: A bin mapper describing the progress coordinate space.
:ivar bin_target_counts: A vector of target counts, one per bin.
'''

def __init__(self, rc=None):
self.rc = rc or westpa.rc

# Number of dimentions in progress coordinate data
self.pcoord_ndim = 1

# Length of progress coordinate data for each segment
self.pcoord_len = 2

# Data type of progress coordinate
self.pcoord_dtype = np.float32

# Mapper
self.bin_mapper = NopMapper()
# self.bin_mapper = None
self._bin_target_counts = None

self.bin_target_counts = [1]

@property
def bin_target_counts(self):
return self._bin_target_counts

@bin_target_counts.setter
def bin_target_counts(self, target_counts):
maxcount = max(target_counts)
self._bin_target_counts = np.array(target_counts, dtype=np.min_scalar_type(maxcount))

def initialize(self):
'''Prepare this system object for use in simulation or analysis,
creating a bin space, setting replicas per bin, and so on. This
function is called whenever a WEST tool creates an instance of the
system driver.
'''
pass

def prepare_run(self):
'''Prepare this system for use in a simulation run. Called by w_run in
all worker processes.'''
pass

def finalize_run(self):
'''A hook for system-specific processing for the end of a simulation run
(as defined by such things as maximum wallclock time, rather than perhaps
more scientifically-significant definitions of "the end of a simulation run")'''
pass

def new_pcoord_array(self, pcoord_len=None):
'''Return an appropriately-sized and -typed pcoord array for a timepoint, segment,
or number of segments. If ``pcoord_len`` is not specified (or None), then
a length appropriate for a segment is returned.'''

if pcoord_len is None:
pcoord_len = self.pcoord_len
return np.zeros((pcoord_len, self.pcoord_ndim), self.pcoord_dtype)

def new_region_set(self):
raise NotImplementedError('This method has been removed.')
8 changes: 4 additions & 4 deletions src/westpa/mclib/_mclib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ cpdef mcbs_ci(dataset, estimator, alpha, dlen, n_sets=None, args=None, kwargs=No
del indices

f_synth_sorted = sort(f_synth)
lbi = int(math.floor(n_sets*alpha/2.0))
ubi = int(math.ceil(n_sets*(1-alpha/2.0)))
lbi = math.floor(n_sets*alpha/2.0)
ubi = math.ceil(n_sets*(1-alpha/2.0))
lb = f_synth_sorted[lbi]
ub = f_synth_sorted[ubi]
sterr = numpy.std(f_synth_sorted)
Expand Down Expand Up @@ -194,8 +194,8 @@ cpdef mcbs_correltime_small(dataset, alpha, n_sets):
raise ValueError('alpha ({}) > 0.5'.format(alpha))

dlen = len(dataset)
lbi = int(math.floor(n_sets*alpha/2.0))
ubi = int(math.ceil(n_sets*(1-alpha/2.0)))
lbi = math.floor(n_sets*alpha/2.0)
ubi = math.ceil(n_sets*(1-alpha/2.0))

synth_sets = numpy.empty((n_sets,)+dataset.shape, dtype=dataset.dtype)
synth_acf_elems = numpy.empty((n_sets,), numpy.float64)
Expand Down
8 changes: 4 additions & 4 deletions src/westpa/oldtools/aframe/mcbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def process_args(self, args, upcall=True):
self.mcbs_alpha = 1 - args.mcbs_confidence
self.mcbs_nsets = args.mcbs_size if args.mcbs_nsets else min(1000, calc_mcbs_nsets(self.mcbs_alpha))
self.mcbs_display_confidence = '{:.{cp}f}'.format(
100 * args.mcbs_confidence, cp=-int(math.floor(math.log10(self.mcbs_alpha))) - 2
100 * args.mcbs_confidence, cp=-math.floor(math.log10(self.mcbs_alpha)) - 2
)
westpa.rc.pstatus(
'Using bootstrap of {:d} sets to calculate {:s}% confidence interval (alpha={:g}).'.format(
Expand Down Expand Up @@ -85,7 +85,7 @@ def calc_mcbs_nsets(alpha):


def calc_ci_bound_indices(n_sets, alpha):
return (int(math.floor(n_sets * alpha / 2)), int(math.ceil(n_sets * (1 - alpha / 2))))
return (math.floor(n_sets * alpha / 2), math.ceil(n_sets * (1 - alpha / 2)))


def bootstrap_ci_ll(estimator, data, alpha, n_sets, storage, sort, eargs=(), ekwargs={}, fhat=None):
Expand All @@ -105,8 +105,8 @@ def bootstrap_ci_ll(estimator, data, alpha, n_sets, storage, sort, eargs=(), ekw
storage[iset] = estimator(data[indices], *eargs, **ekwargs)

synth_sorted = sort(storage)
lbi = int(math.floor(n_sets * alpha / 2))
ubi = int(math.ceil(n_sets * (1 - alpha / 2)))
lbi = math.floor(n_sets * alpha / 2)
ubi = math.ceil(n_sets * (1 - alpha / 2))

lb = synth_sorted[lbi]
ub = synth_sorted[ubi]
Expand Down
4 changes: 2 additions & 2 deletions src/westpa/oldtools/stats/mcbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def bootstrap_ci(estimator, data, alpha, n_sets=None, args=(), kwargs={}, sort=n
f_synth[i] = estimator(data[indices], *args, **kwargs)

f_synth_sorted = sort(f_synth)
lbi = int(math.floor(n_sets * alpha / 2))
ubi = int(math.ceil(n_sets * (1 - alpha / 2)))
lbi = math.floor(n_sets * alpha / 2)
ubi = math.ceil(n_sets * (1 - alpha / 2))
lb = f_synth_sorted[lbi]
ub = f_synth_sorted[ubi]

Expand Down
2 changes: 1 addition & 1 deletion src/westpa/tools/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def write_bin_info(mapper, assignments, weights, n_target_states, outfile=sys.st
min_seg_weight = weights.min()
max_seg_weight = weights.max()

ndec = int(math.ceil(-math.log10(1 / n_active)))
ndec = math.ceil(-math.log10(1 / n_active))

outfile.write('{:d} segments\n'.format(len(weights)))
outfile.write(
Expand Down
Loading
Loading