Skip to content

Commit deb70b4

Browse files
committed
Better PEP8 conformance. Can now handle limits as arguments.
1 parent bfd920a commit deb70b4

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

structure_threader/wrappers/maverick_wrapper.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,22 @@ def maverick_normalization(x_mean, x_sd, klist, draws=1e6, limit=95):
179179
This is essentially a port from the C++ code written by Bob Verity.
180180
"""
181181

182-
z = np.zeros([len(x_mean), draws])
182+
z_array = np.zeros([len(x_mean), draws])
183183

184-
for i in range(z.shape[0]):
185-
y = np.array([np.exp(rnorm(x_mean[i], x_sd[i])) for _ in range(draws)])
186-
z[i] = np.sort(y/sum(y))
184+
for i in range(z_array.shape[0]):
185+
y_array = np.array([np.exp(rnorm(x_mean[i], x_sd[i]))
186+
for _ in range(draws)])
187+
188+
z_array[i] = np.sort(y_array/sum(y_array))
189+
190+
# Define limit tails
191+
l_limit = (100 - limit) / 2
192+
u_limit = 100 - l_limit
187193

188194
norm_res = dict(
189-
(i, {"norm_mean": np.mean(z[i]),
190-
"lower_limit": np.percentile(z[i], 2.5),
191-
"upper_limit": np.percentile(z[i], 97.5)})
195+
(i, {"norm_mean": np.mean(z_array[i]),
196+
"lower_limit": np.percentile(z_array[i], l_limit),
197+
"upper_limit": np.percentile(z_array[i], u_limit)})
192198
for i, k in enumerate(klist))
193199

194200
return norm_res

0 commit comments

Comments
 (0)