Skip to content

Commit 1590699

Browse files
committed
Simplify some array slicing for leave-one-out selection.
For the leave-one-out selection of reactions from rs, replace rs[list(set(range(len(rs))) - {i})] with np.delete(rs, i) (which returns a copy)
1 parent 42718a8 commit 1590699

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

rmgpy/data/kinetics/family.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4628,7 +4628,7 @@ def _make_rule(rr):
46284628
kin.comment = f"Blowers-Masel fit was bad ({reason}) so instead averaged from {n} reactions."
46294629
dlnks = np.array([
46304630
np.log(
4631-
average_kinetics([r.kinetics for r in rs[list(set(range(len(rs))) - {i})]]).get_rate_coefficient(T=Tref) / rxn.get_rate_coefficient(T=Tref)
4631+
average_kinetics([r.kinetics for r in np.delete(rs, i)]).get_rate_coefficient(T=Tref) / rxn.get_rate_coefficient(T=Tref)
46324632
) for i, rxn in enumerate(rs)
46334633
]) # 1) fit to set of reactions without the current reaction (k) 2) compute log(kfit/kactual) at Tref
46344634
varis = (np.array([rank_accuracy_map[rxn.rank].value_si for rxn in rs]) / (2.0 * constants.R * Tref)) ** 2
@@ -4646,15 +4646,15 @@ def _make_rule(rr):
46464646
if isinstance(rs[0].kinetics, Arrhenius):
46474647
dlnks = np.array([
46484648
np.log(
4649-
arr().fit_to_reactions(rs[list(set(range(len(rs))) - {i})], recipe=recipe)
4649+
arr().fit_to_reactions(np.delete(rs, i), recipe=recipe)
46504650
.to_arrhenius(rxn.get_enthalpy_of_reaction(Tref))
46514651
.get_rate_coefficient(T=Tref) / rxn.get_rate_coefficient(T=Tref)
46524652
) for i, rxn in enumerate(rs)
46534653
]) # 1) fit to set of reactions without the current reaction (k) 2) compute log(kfit/kactual) at Tref
46544654
else:
46554655
dlnks = np.array([
46564656
np.log(
4657-
arr().fit_to_reactions(rs[list(set(range(len(rs))) - {i})], recipe=recipe)
4657+
arr().fit_to_reactions(np.delete(rs, i), recipe=recipe)
46584658
.to_arrhenius_charge_transfer(rxn.get_enthalpy_of_reaction(Tref))
46594659
.get_rate_coefficient(T=Tref) / rxn.get_rate_coefficient(T=Tref)
46604660
) for i, rxn in enumerate(rs)

0 commit comments

Comments
 (0)