From 50b29a3b5f459e0a9b071dc8efc108a655d267bc Mon Sep 17 00:00:00 2001 From: Peter Kraus Date: Tue, 16 Aug 2022 20:50:03 +0800 Subject: [PATCH] Bug fixes. (#52) * Fix rates - first row is NaN * Don't propagate uncertainties through cumsum. * black * Filter points where I == 0 in fe. --- src/dgpost/transform/electrochemistry.py | 18 ++++++++++++++-- src/dgpost/transform/rates.py | 7 +++--- .../ref.electrochemistry_charge.ts0.pkl | Bin 17801 -> 17723 bytes .../ref.electrochemistry_current.ts0.pkl | Bin 18836 -> 18634 bytes tests/test_electrochemistry_fe.py | 20 +++++++++++++++++- tests/test_rates_batchtomolar.py | 10 ++++++--- .../ref.batchtomolar.plain.df.pkl | Bin 1543 -> 1509 bytes .../ref.batchtomolar.units.df.pkl | Bin 1616 -> 1582 bytes 8 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/dgpost/transform/electrochemistry.py b/src/dgpost/transform/electrochemistry.py index f85d632..15ad91d 100644 --- a/src/dgpost/transform/electrochemistry.py +++ b/src/dgpost/transform/electrochemistry.py @@ -16,7 +16,15 @@ from yadg.dgutils import ureg import numpy as np import pandas as pd -from dgpost.utils.helpers import load_data, name_to_chem, electrons_from_smiles +from typing import Iterable +from uncertainties import UFloat +from uncertainties import unumpy as unp +from dgpost.utils.helpers import ( + load_data, + separate_data, + name_to_chem, + electrons_from_smiles, +) @load_data( @@ -177,6 +185,8 @@ def fe( """ etot = abs(I) / (ureg("elementary_charge") * ureg("avogadro_constant")) + if isinstance(etot.m, Iterable): + etot.m[etot.m == 0] = np.NaN pretag = "fe" if output is None else output ret = {} for k, v in rate.items(): @@ -243,7 +253,11 @@ def charge( dQ = I * dt - Q = np.cumsum(dQ).to_base_units() + if any([isinstance(i.m, UFloat) for i in dQ]): + dQn, dQs, dQu = separate_data(dQ) + Q = ureg.Quantity(unp.uarray(np.cumsum(dQn), dQs), dQu).to_base_units() + else: + Q = np.cumsum(dQ).to_base_units() ret = {output: Q} return ret diff --git a/src/dgpost/transform/rates.py b/src/dgpost/transform/rates.py index 24b6ea0..6d30577 100644 --- a/src/dgpost/transform/rates.py +++ b/src/dgpost/transform/rates.py @@ -13,7 +13,6 @@ """ import pint - from yadg.dgutils import ureg import pandas as pd import numpy as np @@ -172,16 +171,16 @@ def batch_to_molar( c0 = ureg.Quantity(0, "mol/m³") for k, v in c.items(): c[k] = np.insert(v, 0, c0) - elif isinstance(V.magnitude, Iterable) and len(V) == nts: + elif isinstance(V.m, Iterable) and len(V) == nts: V = V[1:] dt = np.diff(time) - dc = {k: np.diff(c_k) for k, c_k in c.items()} + dc = {k: np.diff(v) for k, v in c.items()} ret = {} for k, dc_k in dc.items(): r = (dc_k / dt) * V if len(r) < nts: - r0 = ureg.Quantity(0, "mol/s") + r0 = ureg.Quantity(np.nan, "mol/s") r = np.insert(r, 0, r0) ret[f"{output}->{k}"] = r.to_base_units() return ret diff --git a/tests/test_electrochemistry_charge/ref.electrochemistry_charge.ts0.pkl b/tests/test_electrochemistry_charge/ref.electrochemistry_charge.ts0.pkl index cac019fcaa3b299d4502ebd03a1fd93c431054df..6dc4d61d36862d12688fcf5964b9bfc3450133c1 100644 GIT binary patch literal 17723 zcmb{4X=73~_ilvGbycVpo zO0`RvBW-x#^7<{=h zw0~zj3IZXBz-yPDp=ntn2nf*tLq|d&%2XiURA7{;z~`m{Vp9P*8Zh{5LGmW2D}&%s zNJj*o)(mXtWHTKClhA;c*1i%ZXq^DZ$I-5B!2jNYN~EMqvjF?5i9L*?cISdS!hBf55JW%9Wd&=`wu z3}4yy(> z-Jy|%ZhU-DzVlevC1~WJ8v)8|F6EA^pfMZW=yQJSnxY}a(3p>I_${~I5@}CCV==nn zQ@7SG|M)a$EJrsy14EC*_8Sk4wdjVw=YHYP?90&Dgl>H7y16>-sty`IqZ|H5$Bj6B zb}=+|p&Pw72a{G7DbP58ZgdZv5jsA212jsJjTUc1hzcHzzj!b%^I+WI!MMwVQO|?X z$b<2k2gBOJ^lQ4dJQy8$Fx-$0Vcfh3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`s}{4$J6ujE u-v5K1HR>4$NvevPY-*$@+1W!oRWFel)5!fSWuPTwqYv(bVy@mO9q@l7Y4mac diff --git a/tests/test_electrochemistry_current/ref.electrochemistry_current.ts0.pkl b/tests/test_electrochemistry_current/ref.electrochemistry_current.ts0.pkl index b8b53d7db9d746a6d72a6ffee8df35d0ef94da7f..fbe6785f33d6c1f487314d6cc16d1a32fd5dfd67 100644 GIT binary patch literal 18634 zcmb{4cU%)^9{}($MLOh?NS7&d;<7MY@U&>STpdPp@caT#+IhfWjMBnMa9u8C1BHgqlgkQ{Eyg zk(;%0m z0=zV@cEt=Toia$|-!Mgzx0iP`=H&jL#FP8P%DY7Ic@>A81r1)wyUP7ckzhbD3lMg# zG^9sMJQ4}uvjHF6+lM4g5+ebTEI>{BAOSI!0z)kYMp+6-ECm#n0?8~u*oEBqEw0!5 zBJG9oY{1L%K8;-)Ohp2IU;)fJ4l*nSNK1ivmI6yG1y)%KY_t^EVJWcNQs984z!6J< zKP?5$SqfaX6u41EVrI#28G5W2W)-fao%@_0ate~M7Gik!3^^+5HU`Pq0x`OK7x4S1T|+W{ff&6!ww5K`Fd!Lw zAx8IOqX(V4umH&@gcu#S2I=jr6OfD|h|#v^w2(1Dn~;nWcEg-cBE(-D7}q#3?r>l{ zE)N_Ak`%rVhnD! z_3F-5Cyla-!Tr`}9LD#uxfQKH{cu`$;Z$tZ;w zr$e9kTBrVsWZZxm2^Ys-n2UC=eGg`|y|F{FqX4NK-`wNByZEw$k5wJb!iAQ_!)an3Xy)kAR5CA&;AZ-%~7Os zctDJlRPl<1Rbfbm7rS9rpWJ~1qbmnS00%}02Zn&%;QK$DBD)oO0BOGnAx7lkrp=FL zL?an-5QD#B>$sO^-Xj^qAqKYWP*1^k0Z7Ieh%w;rGOu$LRY-;mVu(7f3fmCf9?2L7 zF$PuaU9Krb`wm45F|OQs+0Ltv4yhayA;z_DhCi-2e-Fu+3Nfy?c(Wya=rAN>Cd9ar z6Et*Z@(3g&7h>F$%{-rS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WpbhGVbE^ToNBb9X-#{zm2Hk?W#=AtXUjZ5yXD6{1{~Q?)6TcD z&9SU(cHXGReHG>zgxOC%LFS8QZ_XGqIDS))7S(qyQP62*YY#c4C;Oea$Tai>*$@qR zjZ8Rf%i2nsb|WE0qxfA(UKgEATqiZ1N~`sJ3?{H1nO^|(c0)K;{INl6AW4GO$R}xhVwye08h-bdXyXhrOPZ?^OsYca z$P6TD&G3!0IA#cW$F%2(i*NU2otCs*t0vp6NaJY(rB=|&bOq_3di+zZhUCN{y~6#> zi9et84zEfAIo2VBf6G23hR??IB5w~i#DtSq!ufm@ZOTWJygmP>+fWjX+{as@@J(Q1 zNp;K(pjpRwt%5f7E8FyqZDB~3)~Vvj?Y}HRM>bk9CM3{0a@f2=nu)C*4tDk;QxB_r z|K0b+x`#z1ZbY*z(zhX;f$upTsRO}W8`XCcH*~afaA_d2cXF=B?-Ro@spL(*G?Pv; zd~uqsuh;4fTAhN_BAV<=Lym!|($UfMzej@gtnHk#G{rSkt)&e9es7#KrekKV%Yt!L z^L5gVX$vG-Wztp2&CB`JZYL6UKZ@IqF{x=U9f8vpig2;9| zWDgNm;v&9HSx`W*PrO zVaYL;oXnC_T5{toxzU!~SWAw!zt8^Az8MbJ}J_NY{CO": ureg.Quantity(0.02858024), }, ), + ( # ts2 - arrays, with I == 0, all Quantities, weird units + { + "I": ureg.Quantity([0, 100], "mA"), + "rate": { + "H2": ureg.Quantity([0.6811524, 0.6811524], "mmol/hour"), + "CH4": ureg.Quantity([0.1134709, 0.1134709], "mmol/hour"), + "C2H4": ureg.Quantity([0.0239087, 0.0239087], "mmol/hour"), + "CO": ureg.Quantity([0.0533184, 0.0533184], "mmol/hour"), + }, + "charges": {"C": 4, "H": 1, "O": -2}, + }, + { + "fe->H2": ureg.Quantity([np.NaN, 0.36511734]), + "fe->CH4": ureg.Quantity([np.NaN, 0.24329496]), + "fe->C2H4": ureg.Quantity([np.NaN, 0.07689462]), + "fe->CO": ureg.Quantity([np.NaN, 0.02858024]), + }, + ), ], ) def test_electrochemistry_fe_direct(inputs, output): @@ -53,7 +71,7 @@ def test_electrochemistry_fe_direct(inputs, output): print(ret) for k in inputs["rate"].keys(): n = f"{tag}->{k}" - assert np.allclose(ret[n], output[n]) + assert np.allclose(ret[n], output[n], equal_nan=True) @pytest.mark.parametrize( diff --git a/tests/test_rates_batchtomolar.py b/tests/test_rates_batchtomolar.py index 1464eac..7434f2e 100644 --- a/tests/test_rates_batchtomolar.py +++ b/tests/test_rates_batchtomolar.py @@ -36,8 +36,12 @@ "V": ureg.Quantity(1, "l"), }, { - "rate->A": ureg.Quantity([0.0, 10.0 / 60, 5.0 / 60, 5.0 / 60], "mol/s"), - "rate->B": ureg.Quantity([0.0, 5.0 / 60, 5.0 / 60, 1.0 / 60], "mol/s"), + "rate->A": ureg.Quantity( + [np.NaN, 10.0 / 60, 5.0 / 60, 5.0 / 60], "mol/s" + ), + "rate->B": ureg.Quantity( + [np.NaN, 5.0 / 60, 5.0 / 60, 1.0 / 60], "mol/s" + ), }, ), ], @@ -45,7 +49,7 @@ def test_rates_batchtomolar_direct(spec, ref): ret = rates.batch_to_molar(**spec) for k, v in ref.items(): - assert np.allclose(v, ret[k]) + assert np.allclose(v, ret[k], equal_nan=True) @pytest.mark.parametrize( diff --git a/tests/test_rates_batchtomolar/ref.batchtomolar.plain.df.pkl b/tests/test_rates_batchtomolar/ref.batchtomolar.plain.df.pkl index 610108adfb71fd6e59bc46cb261f20720f781d9c..bbe7c384f0255fdd77b47b8e0db9bc82cfa10f2d 100644 GIT binary patch delta 137 zcmZqYdCJYwz&iETMwVzMrXTf_H!^u}Fn|G&lgQ-3JS9VPvK(^-ycxZjfSj<-*eM!4jE+-!7@el1 zmP|>?h?|_qqQ@9Mc>;?HD+A+{jKaw~S#+4~d!#2TGK)<9!y?P*Ia!J|i!p9;D{BG( DhR-ex diff --git a/tests/test_rates_batchtomolar/ref.batchtomolar.units.df.pkl b/tests/test_rates_batchtomolar/ref.batchtomolar.units.df.pkl index 5b05ae068fd0923fcf798ba039f64a54cee15a69..62cf565a45250d97899cc20bf92ad87b4f8111b2 100644 GIT binary patch delta 327 zcmcb>vyO+Qfpx0#MwV!%`XBXHJqC~ZDoyQfmT08=Jax3|X;`x)cfGUSMY(m#>(X58 zzP!~-_B-Ta=bfVeb>%k~JHK`L2Fc>Cb}n7Bm`rqC?aISjlPYao?HIrSW}d5^cIFaI zZRrF%kM(_z1Hr1;c@XJMU8f4&AeZ} zDz@1Dof3RO{bHNllnl|ya?Bmf))|(QS2C|Ow9as@ouZN9n&FY*<;~DKCBvtEO3)My zZ$@t>ASb9Zc8W$1qvMnwMyDyMB~y|zq9!-9=rIOQ-o&E9%E&M!BX{y`79B?G$sDZ4 zjINVyShEdsvDROH!wRBvK#} N#ZxkpCrh)L0stXoe+vKr delta 345 zcmZ3-bAgAYfpx0uMwV!%dIkpT9)m}Hm9BQ$nM*Xar4#Ht*6*41>3Wvkrm9!0v8Rgc z4$UpwcR-`U?!p14a+UU4yZ431#g7y<+Lbr+e)+1{V)t)K@CEgYZFUS$05Q+h?na45 zy3bQbyPk$MOLEsc+g+4fr@SuB#qR4{y=1>bE_OaC`d?QneRHw%Uzcx?EbeOO+BJ*G zMAy}>BD^)J(#F+pN`_DmQ<}wOekS?J3m91^Gch+Y+h^ELZf9O;XrJL;J4GYIGs7pt z&zqrjN=88Yl%OdZ-i+Q%Ku%a^>=cb2M#m{Vj80QhOQs}c#7$0Q(PIpsJb^`pm4R_e zM&ab0EIQ2gJ<^jEnMEf5VUcC@oGitf#TYlamDR~8s)r>v_t54k8POn1(tB8Q^K