forked from Auto-Mech/autochem
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lint: Formats/adds type annotations to kTP code
- Loading branch information
Showing
5 changed files
with
135 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
""" autoreact | ||
"""autoreact. | ||
I this should be renamed `autorate` and house the functions in ratefit and | ||
mechanalyzer.calculator.rates, along with the parametrization functions. | ||
""" | ||
from autoreact import params | ||
|
||
__all__ = [ | ||
'params', | ||
"params", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,99 @@ | ||
"""Tests xarray_wrappers.py's functions""" | ||
"""Test xarray_wrappers.py's functions.""" | ||
|
||
import numpy | ||
|
||
from autoreact.ktp_xarray import xarray_wrappers | ||
|
||
Temps = [1000, 1500, 2000, 2500] | ||
Press = [1, 10, numpy.inf] | ||
Rates = [[1e1, 1e2, 1e3, 1e4], [1e5, 1e6, 1e7, 1e8], [1e9, 1e10, 1e11, 1e12]] | ||
|
||
Ktp = xarray_wrappers.from_data(Temps, Press, Rates) | ||
Ktp_dct = {1.0: (([1000., 1500., 2000., 2500.]), | ||
([ 10., 100., 1000., 10000.])), | ||
10: (([1000., 1500., 2000., 2500.]), | ||
([1.e+05, 1.e+06, 1.e+07, 1.e+08])), | ||
numpy.inf: (([1000., 1500., 2000., 2500.]), | ||
([1.e+09, 1.e+10, 1.e+11, 1.e+12]))} | ||
Ktp_dct = { | ||
1.0: (([1000.0, 1500.0, 2000.0, 2500.0]), ([10.0, 100.0, 1000.0, 10000.0])), | ||
10: (([1000.0, 1500.0, 2000.0, 2500.0]), ([1.0e05, 1.0e06, 1.0e07, 1.0e08])), | ||
numpy.inf: (([1000.0, 1500.0, 2000.0, 2500.0]), ([1.0e09, 1.0e10, 1.0e11, 1.0e12])), | ||
} | ||
print(Ktp) | ||
|
||
|
||
def test_get_temperatures(): | ||
"""Tests the get_temperatures function""" | ||
"""Test the get_temperatures function.""" | ||
temp = xarray_wrappers.get_temperatures(Ktp) | ||
print(temp) | ||
|
||
|
||
def test_get_pressures(): | ||
"""Tests the get_pressures function""" | ||
"""Test the get_pressures function.""" | ||
pres = xarray_wrappers.get_pressures(Ktp) | ||
print(pres) | ||
print(f"pres = {pres}") | ||
print(type(pres)) | ||
|
||
|
||
def test_get_values(): | ||
"""Tests the get_values function""" | ||
"""Test the get_values function.""" | ||
vals = xarray_wrappers.get_values(Ktp) | ||
print(vals) | ||
print(f"vals = {vals}") | ||
print(type(vals)) | ||
|
||
|
||
def test_get_pslice(): | ||
"""Tests the get_pslice function""" | ||
"""Test the get_pslice function.""" | ||
pslice = xarray_wrappers.get_pslice(Ktp, numpy.inf) | ||
print(pslice) | ||
print(f"pslice = {pslice}") | ||
print(type(pslice)) | ||
|
||
|
||
def test_get_tslice(): | ||
"""Tests the get_tslice function""" | ||
"""Test the get_tslice function.""" | ||
tslice = xarray_wrappers.get_tslice(Ktp, 1500) | ||
print(tslice) | ||
|
||
|
||
def test_get_spec_vals(): | ||
"""Tests the get_spec_values function""" | ||
"""Test the get_spec_values function.""" | ||
vals = xarray_wrappers.get_spec_vals(Ktp, 1500, 1) | ||
print(vals) | ||
|
||
|
||
def test_get_ipslice(): | ||
"""Tests the get_ipslice function""" | ||
"""Test the get_ipslice function.""" | ||
ipslice = xarray_wrappers.get_ipslice(Ktp, 0) | ||
print(ipslice) | ||
|
||
|
||
def test_get_itslice(): | ||
"""Tests the get_itslice function""" | ||
"""Test the get_itslice function.""" | ||
itslice = xarray_wrappers.get_itslice(Ktp, 0) | ||
print(itslice) | ||
|
||
|
||
def test_set_rates(): | ||
"""Tests the set_rates function""" | ||
"""Test the set_rates function.""" | ||
new_rates = xarray_wrappers.set_rates(Ktp, numpy.nan, 10, 2000) | ||
print(new_rates) | ||
|
||
|
||
def test_dict_from_xarray(): | ||
"""Tests the ktp_to_xarray function""" | ||
"""Test the ktp_to_xarray function.""" | ||
ktp_dct = xarray_wrappers.dict_from_xarray(Ktp) | ||
print(ktp_dct) | ||
|
||
#def test_xarray_from_dict(): | ||
# """Tests the set_ktp_dct function""" | ||
|
||
# def test_xarray_from_dict(): | ||
# """Test the set_ktp_dct function.""" | ||
# xarray = xarray_wrappers.xarray_from_dict(Ktp_dct) | ||
# print(xarray) | ||
|
||
|
||
test_get_pressures() | ||
test_get_temperatures() | ||
test_get_values() | ||
# test_get_pressures() | ||
# test_get_temperatures() | ||
# test_get_values() | ||
test_get_pslice() | ||
test_get_tslice() | ||
test_get_spec_vals() | ||
test_get_ipslice() | ||
test_get_itslice() | ||
test_set_rates() | ||
test_dict_from_xarray() | ||
#test_xarray_from_dict() | ||
# test_get_tslice() | ||
# test_get_spec_vals() | ||
# test_get_ipslice() | ||
# test_get_itslice() | ||
# test_set_rates() | ||
# test_dict_from_xarray() | ||
# test_xarray_from_dict() |
Oops, something went wrong.