Skip to content

Commit f109677

Browse files
committed
Merge branch 'nov20' of github.com:bjodah/chempy into nov20
2 parents 68bf7b0 + 5acc04b commit f109677

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

chempy/kinetics/rates.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ def heaviside(x, z):
198198
elif hasattr(backend, 'clip'): # e.g. numpy
199199
def heaviside(x, z):
200200
assert z == 0
201-
lx = backend.log(backend.maximum(x, tiny))
202-
xclp = be.clip(lx, lo, hi)
201+
lx = backend.log(backend.maximum(backend.array(x), tiny))
202+
xclp = backend.clip(lx, lo, hi)
203+
x = (xclp - lo)/(hi - lo)
203204
y = (3 - 2*x)*x*x
204205
return y
205206
else:

chempy/kinetics/tests/test__rates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def test_Log10TPolyMassAction__units():
8686
p = MassAction(Constant(kunit)*10**ShiftedTPoly([273.15*u.K, .7, .02/u.K, .003/u.K**2, .0004/u.K**3]))
8787
r = Reaction({'A': 2, 'B': 1}, {'C': 1}, p, {'B': 1})
8888
res = p({'A': 11*u.molar, 'B': 13*u.molar, 'temperature': 298.15*u.K}, reaction=r)
89-
ref = 10**(.7 + .02*25 + 0.003 * 25**2 + 0.0004 * 25**3)
90-
assert abs(res - ref*13*11**2*Mps) < 1e-15
89+
ref = 10**(.7 + .02*25 + 0.003 * 25**2 + 0.0004 * 25**3)*13*11**2*Mps
90+
assert abs((res - ref)/ref) < 1e-15
9191

9292

9393
def test_TPolyInLog10MassAction():

chempy/tests/test_units.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_to_unitless():
207207
sy.exp(Ea_over_RT_uncert)
208208

209209
T_K_sym = np.array(sy.Symbol('T_K', real=True), dtype=object) * u.K
210-
to_unitless(T_K_sym/(298*u.K))
210+
assert to_unitless(T_K_sym/(298*u.K)).tolist() == [sy.Symbol('T_K', real=True)]
211211
rescale(simplified(Ea/dc.molar_gas_constant)/T_K_sym, 1)
212212
Ea_over_R_uncert = UncertainQuantity(Ea, unit_of(Ea), 0.1*Ea)/dc.molar_gas_constant
213213
to_unitless(Ea_over_R_uncert/(298*u.K))
@@ -223,7 +223,7 @@ def test_UncertainQuantity():
223223
a = UncertainQuantity([1, 2], u.m, [.1, .2])
224224
assert a[1] == [2.]*u.m
225225
assert (-a)[0] == [-1.]*u.m
226-
assert (-a).uncertainty[0] == [0.1]*u.m
226+
assert allclose((-a).uncertainty[0], [0.1]*u.m)
227227
assert (-a)[0] == (a*-1)[0]
228228
assert (-a).uncertainty[0] == (a*-1).uncertainty[0]
229229
assert allclose(a, [1, 2]*u.m)

0 commit comments

Comments
 (0)