Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no longer need to cast int() on outputs from math.floor and math.ceil
Browse files Browse the repository at this point in the history
jeremyleung521 committed Nov 12, 2024
1 parent 2f37b7d commit 5cd575b
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/westpa/mclib/_mclib.pyx
Original file line number Diff line number Diff line change
@@ -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)
@@ -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)
8 changes: 4 additions & 4 deletions src/westpa/oldtools/aframe/mcbs.py
Original file line number Diff line number Diff line change
@@ -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(
@@ -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):
@@ -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]
4 changes: 2 additions & 2 deletions src/westpa/oldtools/stats/mcbs.py
Original file line number Diff line number Diff line change
@@ -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]

2 changes: 1 addition & 1 deletion src/westpa/tools/binning.py
Original file line number Diff line number Diff line change
@@ -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(

0 comments on commit 5cd575b

Please sign in to comment.