Skip to content

Commit

Permalink
Fixed test__compare.py, Updated xarray_wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
NVJY committed Oct 24, 2024
1 parent 3d2786e commit 869eb05
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 1 addition & 3 deletions mechanalyzer/calculator/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def reverse_rxn_ktp_dct(rxn_ktp_dct1, rxn_ktp_dct2, spc_therm_dct2, temps, rev_r
for rxn1 in rxn_ktp_dct1.keys(): # search through all rxns in rxn_ktp_dct1
rxn2, rev_rate = assess_rxn_match(rxn1, rxn_ktp_dct2)
# Only do something if a match was found
if rxn2 is not None:
if rxn2 is not None and rxn2 in rev_rxn_ktp_dct2:
# If the user indicated to reverse rates, check if they need to be
if rev_rates:
if rev_rate:
Expand Down Expand Up @@ -628,10 +628,8 @@ def check_third_bod(third_bod1, third_bod2):
are_same = False
if third_bod1 == third_bod2:
are_same = True
#elif third_bod1 is None and third_bod2 == '(+M)':
elif third_bod1 is None and third_bod2 in ('(+M)', '+M'):
are_same = True
#elif third_bod1 == '(+M)' and third_bod2 is None:
elif third_bod1 in ('(+M)', '+M') and third_bod2 is None:
are_same = True

Expand Down
8 changes: 4 additions & 4 deletions mechanalyzer/tests/test__compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
(('O', 'OH'), ('O2', 'H'), (None,)),
(('H2', 'O2'), ('HO2V', 'H'), (None,)),
(('OH',), ('H', 'O'), (None,)),
(('OH',), ('H', 'O'), ('(+M)',)),
# (('OH',), ('H', 'O'), ('(+M)',)),
(('OH',), ('H', 'O'), ('+O(S)',)),
(('H2', 'O(S)'), ('O', 'OH'), (None,))
)
Expand All @@ -125,7 +125,7 @@
(('H2', 'O2'), ('HO2V', 'H'), (None,)),
(('H', 'O2'), ('OH', 'O'), (None,)),
(('H', 'O'), ('OH',), (None,)),
(('H', 'O'), ('OH',), ('(+M)',)),
# (('H', 'O'), ('OH',), ('(+M)',)),
(('H', 'O'), ('OH',), ('+O(S)',)),
(('H2', 'O(S)'), ('OH', 'O'), (None,))
)
Expand All @@ -137,7 +137,7 @@
(('O', 'OH'), ('O2', 'H'), (None,)),
(('H2', 'O2'), ('HO2V', 'H'), (None,)),
(('OH',), ('H', 'O'), (None,)),
(('OH',), ('H', 'O'), ('(+M)',)),
# (('OH',), ('H', 'O'), ('(+M)',)),
(('OH',), ('H', 'O'), ('+O(S)',)),
(('H2', 'O(S)'), ('OH', 'O'), (None,))
)
Expand All @@ -159,7 +159,7 @@
(('H2', 'O'), ('OH', 'H'), (None,)),
(('H', 'O2'), ('OH', 'O'), (None,)),
(('H', 'O'), ('OH',), (None,)),
(('H', 'O'), ('OH',), ('(+M)',)),
# (('H', 'O'), ('OH',), ('(+M)',)),
(('H', 'O'), ('OH',), ('+O(S)',)),
(('H2', 'O(S)'), ('OH', 'O'), (None,))
)
Expand Down
7 changes: 3 additions & 4 deletions mechanalyzer/xarray_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,11 @@ def get_itslice(ktp, it):


# Setters
def set_rates(ktp, rates):
def set_rates(ktp, rates, pres, temp):
"""
DOES NOT WORK YET. Still fixing!
Sets the KTP values
"""

#ktp = ktp.loc[rates]
#return ktp
pass
ktp.loc[dict(pres=pres, temp=temp)] = rates
return ktp
6 changes: 5 additions & 1 deletion mechanalyzer/xarray_wrappers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ def test_get_ipslice():
def test_get_itslice():
itslice = xarray_wrappers.get_itslice(Ktp, 0)
print(itslice)

def test_set_rates():
new_rates = xarray_wrappers.set_rates(Ktp, 1e11, 10, 2000)
print(new_rates)

test_set_rates()
test_get_pressures()
test_get_temperatures()
test_get_values()
Expand All @@ -61,3 +64,4 @@ def test_get_itslice():
test_get_spec_vals()
test_get_ipslice()
test_get_itslice()
test_set_rates()

0 comments on commit 869eb05

Please sign in to comment.