Skip to content

Commit

Permalink
refactor threaded worker function
Browse files Browse the repository at this point in the history
  • Loading branch information
Areustle committed Jan 3, 2022
1 parent ff62e07 commit 76bbdf0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cubepy/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def tiled_rule(center, halfwidth, vol, evtidx):
lens = np.roll(np.cumsum(np.array(list(map(lambda x: x.shape[1], c_sp))), 0), 1)
lens[0] = 0

def tile_rule_worker(iter, c, h, v, e):
def rule_worker(iter, c, h, v, e):
end = iter + c.shape[1]
val, err, sub = rule(_f(e), c, h, v)
value[:, iter:end] = val
Expand All @@ -267,7 +267,7 @@ def tile_rule_worker(iter, c, h, v, e):
else:
max_workers = parallel
with ThreadPoolExecutor(max_workers=max_workers) as exec:
exec.map(tile_rule_worker, lens, c_sp, h_sp, v_sp, e_sp)
exec.map(rule_worker, lens, c_sp, h_sp, v_sp, e_sp)

return value, error, split_dim

Expand Down
4 changes: 2 additions & 2 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ def us_std_atm_density(z, earth_radius=6371):
z = np.asarray(z)

h = z * earth_radius / (z + earth_radius)
i = np.searchsorted(H_b, h, side="right") - 1
i = np.searchsorted(H_b, h, side="right") - 1 # <--!!

deltah = h - H_b[i]

temperature = T_b[i] + Lm_b[i] * deltah

mask = Lm_b[i] == 0
pressure = np.full(z.shape, P_b[i])
pressure[mask] *= np.exp(-gmr * deltah[mask] / T_b[i][mask])
pressure[mask] *= np.exp(-gmr * deltah[mask] / T_b[i][mask]) # <--!!
pressure[~mask] *= (T_b[i][~mask] / temperature[~mask]) ** (
gmr / Lm_b[i][~mask]
)
Expand Down

0 comments on commit 76bbdf0

Please sign in to comment.