From cddc09d5d8c877abee16ac14de2e38869a73bc2a Mon Sep 17 00:00:00 2001 From: "Felipe S. S. Schneider" Date: Wed, 4 Jan 2023 11:17:56 -0300 Subject: [PATCH] Review code using ruff --- .flake8 | 9 - gendocs.sh | 4 +- overreact/__init__.py | 67 ++++-- overreact/_cli.py | 46 ++-- overreact/_constants.py | 55 +++-- overreact/_datasets.py | 2 +- overreact/_misc.py | 26 ++- overreact/api.py | 80 ++++--- overreact/coords.py | 189 +++++++---------- overreact/core.py | 40 ++-- overreact/io.py | 70 +++--- overreact/rates.py | 11 +- overreact/simulate.py | 51 +++-- overreact/thermo/__init__.py | 47 +++-- overreact/thermo/_gas.py | 42 ++-- overreact/thermo/_solv.py | 10 +- overreact/tunnel.py | 19 +- poetry.lock | 375 +++++++++++++++++++-------------- pyproject.toml | 21 +- tests/test_api.py | 7 +- tests/test_coords.py | 397 +++-------------------------------- tests/test_rates.py | 22 +- tests/test_regressions.py | 32 ++- tests/test_thermo_gas.py | 3 +- tests/test_thermo_solv.py | 77 ------- tests/test_tunnel.py | 84 ++++---- 26 files changed, 733 insertions(+), 1053 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index a1c00bd5..00000000 --- a/.flake8 +++ /dev/null @@ -1,9 +0,0 @@ -[flake8] -max-line-length = 88 -max-doc-length = 88 -enable-extensions = H106,H203,H204,H205,H210,H904 -extend-ignore = E203 -max-complexity = 10 -doctests = True -docstring-convention = numpy -include-in-doctest = "*.rst" diff --git a/gendocs.sh b/gendocs.sh index 5c210f70..9a8bb94d 100644 --- a/gendocs.sh +++ b/gendocs.sh @@ -8,5 +8,5 @@ pdoc overreact \ --logo-link "/overreact" \ --math \ --search \ - --show-source -# --output-directory docs/ + --show-source \ + "$@" diff --git a/overreact/__init__.py b/overreact/__init__.py index 972eb525..d1a6455a 100644 --- a/overreact/__init__.py +++ b/overreact/__init__.py @@ -2,36 +2,57 @@ """ .. include:: ../README.md -""" +""" # noqa: D200, D400 __docformat__ = "restructuredtext" import pkg_resources as _pkg_resources -from overreact.api import get_enthalpies # noqa: F401 -from overreact.api import get_entropies # noqa: F401 -from overreact.api import get_freeenergies # noqa: F401 -from overreact.api import get_internal_energies # noqa: F401 -from overreact.api import get_k # noqa: F401 -from overreact.api import get_kappa # noqa: F401 -from overreact.core import Scheme # noqa: F401 -from overreact.core import get_transition_states # noqa: F401 -from overreact.core import is_transition_state # noqa: F401 -from overreact.core import parse_reactions # noqa: F401 -from overreact.core import unparse_reactions # noqa: F401 -from overreact.io import parse_compounds # noqa: F401 -from overreact.io import parse_model # noqa: F401 -from overreact.simulate import get_bias # noqa: F401 -from overreact.simulate import get_dydt # noqa: F401 -from overreact.simulate import get_fixed_scheme # noqa: F401 -from overreact.simulate import get_y # noqa: F401 -from overreact.thermo import change_reference_state # noqa: F401 -from overreact.thermo import get_delta # noqa: F401 -from overreact.thermo import get_reaction_entropies # noqa: F401 +from overreact.api import ( + get_enthalpies, + get_entropies, + get_freeenergies, + get_internal_energies, + get_k, + get_kappa, +) +from overreact.core import ( + Scheme, + get_transition_states, + is_transition_state, + parse_reactions, + unparse_reactions, +) +from overreact.io import parse_compounds, parse_model +from overreact.simulate import get_bias, get_dydt, get_fixed_scheme, get_y +from overreact.thermo import change_reference_state, get_delta, get_reaction_entropies + +__all__ = [ + "Scheme", + "change_reference_state", + "get_bias", + "get_delta", + "get_dydt", + "get_enthalpies", + "get_entropies", + "get_fixed_scheme", + "get_freeenergies", + "get_internal_energies", + "get_k", + "get_kappa", + "get_reaction_entropies", + "get_transition_states", + "get_y", + "is_transition_state", + "parse_compounds", + "parse_model", + "parse_reactions", + "unparse_reactions", +] __version__ = _pkg_resources.get_distribution(__name__).version __license__ = "MIT" # I'm too lazy to get it from setup.py... -__headline__ = "πŸ“ˆ Create and analyze chemical microkinetic models built from computational chemistry data." +__headline__ = "πŸ“ˆ Create and analyze chemical microkinetic models built from computational chemistry data." # noqa: E501 __url_repo__ = "https://github.com/geem-lab/overreact" __url_issues__ = f"{__url_repo__}/issues" @@ -65,7 +86,7 @@ year = {2021}, month = {Nov} } -""".replace( +""".replace( # noqa: E501 "DOI_PLACEHOLDER", __doi__ ) .replace("ZENODO_DOI_PLACEHOLDER", __zenodo_doi__) diff --git a/overreact/_cli.py b/overreact/_cli.py index cb2d9626..c20c21ba 100644 --- a/overreact/_cli.py +++ b/overreact/_cli.py @@ -54,7 +54,7 @@ class Report: qrrho : bool, optional Apply both the quasi-rigid rotor harmonic oscillator (QRRHO) approximations of M. Head-Gordon and others (enthalpy correction, see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) and S. Grimme (entropy correction, see [*Theory. Chem. Eur. J.*, **2012**, 18: 9955-9964](https://doi.org/10.1002/chem.201200497)) on top of the classical RRHO. @@ -130,10 +130,10 @@ class Report: For half-equilibria, only ratios make sense: in simulations, equilibria will be adjusted to be faster than all other reactions. ──────────────────────────────────────────────────────────────────────────────── - """ + """ # noqa: E501 def __init__( - self, + self, # noqa: ANN101 model, concentrations=None, savepath=None, @@ -148,7 +148,7 @@ def __init__( rtol=1e-3, atol=1e-6, box_style=box.SIMPLE, - ): + ) -> None: """Initialize a Report object.""" self.model = model self.concentrations = concentrations @@ -173,7 +173,7 @@ def __init__( self.atol = atol self.box_style = box_style - def __rich_console__(self, console, options): + def __rich_console__(self, console, options): # noqa: ANN101, ARG002, ANN204 """ Implement Rich Console protocol. @@ -190,7 +190,7 @@ def __rich_console__(self, console, options): yield from self._yield_kinetics() yield Markdown("---") - def _yield_scheme(self): + def _yield_scheme(self): # noqa: ANN101 """Produce a renderables describing the reaction scheme. This is meant to be used from within `__rich_console__`. @@ -232,7 +232,7 @@ def _yield_scheme(self): parsed_table.add_row(*row) yield parsed_table - def _yield_compounds(self): + def _yield_compounds(self): # noqa: ANN101 """Produce a renderables describing the compounds. This is meant to be used from within `__rich_console__`. @@ -251,7 +251,9 @@ def _yield_compounds(self): if not self.model.compounds[name]: undefined_compounds.append(name) if undefined_compounds: - raise ValueError(f"undefined compounds: {', '.join(undefined_compounds)}") + raise ValueError( + f"undefined compounds: {', '.join(undefined_compounds)}" # noqa: EM102 + ) # noqa: RUF100 logfiles_table = Table( Column("no", justify="right"), @@ -298,7 +300,7 @@ def _yield_compounds(self): yield logfiles_table yield compounds_table - def _yield_thermochemistry(self): + def _yield_thermochemistry(self): # noqa: ANN101 """Produce a renderables describing the thermochemistry of the reaction scheme. This is meant to be used from within `__rich_console__`. @@ -374,7 +376,7 @@ def _yield_thermochemistry(self): * rx.get_reaction_entropies( scheme.A, temperature=self.temperature, pressure=self.pressure ), - ), "reaction free energies do not match reaction enthalpies and reaction entropies" + ), "reaction free energies do not match reaction enthalpies and reaction entropies" # noqa: E501 delta_activation_mass = rx.get_delta(scheme.B, molecular_masses) delta_activation_energies = rx.get_delta(scheme.B, energies) @@ -396,7 +398,7 @@ def _yield_thermochemistry(self): * rx.get_reaction_entropies( scheme.B, temperature=self.temperature, pressure=self.pressure ), - ), "activation free energies do not match activation enthalpies and activation entropies" + ), "activation free energies do not match activation enthalpies and activation entropies" # noqa: E501 circ_table = Table( Column("no", justify="right"), @@ -471,7 +473,7 @@ def _yield_thermochemistry(self): yield circ_table yield dagger_table - def _yield_kinetics(self): + def _yield_kinetics(self): # noqa: ANN101, C901 """Produce a renderables describing the kinetics of the system. This is meant to be used from within `__rich_console__`. @@ -585,7 +587,7 @@ def _yield_kinetics(self): f"{self.bias} J/mol." ) yield Markdown( - "For **half-equilibria**, only ratios make sense: in simulations, **equilibria will be adjusted to be faster than all other reactions**." + "For **half-equilibria**, only ratios make sense: in simulations, **equilibria will be adjusted to be faster than all other reactions**." # noqa: E501 ) if self.concentrations is not None and self.concentrations: @@ -657,7 +659,7 @@ def _yield_kinetics(self): for i, name in enumerate(scheme.compounds): if not rx.is_transition_state(name): res = minimize_scalar( - lambda t: -r(t)[i], + lambda t: -r(t)[i], # noqa: B023 bounds=(y.t_min, (t_max + y.t_max) / 2), method="bounded", ) @@ -716,8 +718,9 @@ def _prepare_simulation(scheme, k, concentrations): try: quantity = float(quantity) except (IndexError, ValueError): - raise ValueError( - "badly formatted concentrations: " f"'{' '.join(concentrations)}'" + raise ValueError( # noqa: B904 + "badly formatted concentrations: " # noqa: EM102 + f"'{' '.join(concentrations)}'" # noqa: RUF100 ) d[name] = quantity @@ -754,7 +757,7 @@ def main(arguments=None): ) parser.add_argument( "path", - help="path to a source (`.k`) or compiled (`.jk`) model input file (if a source " + help="path to a source (`.k`) or compiled (`.jk`) model input file (if a source " # noqa: E501 "input file is given, but there is a compiled file available, the compiled " "file will be used; use --compile|-c to force recompilation of the " "source input file instead)", @@ -792,9 +795,7 @@ def main(arguments=None): "'active' species only (i.e., the ones that actually change " "concentration during the simulation) or a single compound name (e.g. " "'NH3(w)')", - # TODO(schneiderfelipe): validate inputs to avoid "ValueError: - # tuple.index(x): x not in tuple" - # choices=["active", "all", "none"], + # TODO(schneiderfelipe): validate inputs to avoid ValueError? default="none", ) parser.add_argument( @@ -831,7 +832,8 @@ def main(arguments=None): parser.add_argument( "-p", "--pressure", - help="set working pressure (in pascals) to be used in " "thermochemistry", + help="set working pressure (in pascals) to be used in " + "thermochemistry", # noqa: RUF100 type=float, default=constants.atm, ) @@ -944,4 +946,6 @@ def main(arguments=None): if __name__ == "__main__": + # TODO: catch exceptions here and print a nice error + # (we can reraise them later if we want). main() diff --git a/overreact/_constants.py b/overreact/_constants.py index d73f31b4..4686bde4 100644 --- a/overreact/_constants.py +++ b/overreact/_constants.py @@ -6,24 +6,43 @@ """ import numpy as np -from scipy.constants import N_A # noqa: F401 -from scipy.constants import R # noqa: F401 -from scipy.constants import angstrom # noqa: F401 -from scipy.constants import atm # noqa: F401 -from scipy.constants import atomic_mass # noqa: F401 -from scipy.constants import bar # noqa: F401 -from scipy.constants import c # noqa: F401 -from scipy.constants import calorie # noqa: F401 -from scipy.constants import centi # noqa: F401 -from scipy.constants import eV # noqa: F401 -from scipy.constants import giga # noqa: F401 -from scipy.constants import h # noqa: F401 -from scipy.constants import hbar # noqa: F401 -from scipy.constants import k # noqa: F401 -from scipy.constants import kilo # noqa: F401 -from scipy.constants import liter # noqa: F401 -from scipy.constants import torr # noqa: F401 -from scipy.constants import physical_constants +from scipy.constants import ( + N_A, + R, + angstrom, + atm, + atomic_mass, + bar, + c, + calorie, + centi, + eV, + giga, + h, + hbar, + k, + kilo, + liter, + physical_constants, + torr, +) + +__all__ = [ + "N_A", + "R", + "angstrom", + "atm", + "atomic_mass", + "bar", + "c", + "eV", + "giga", + "h", + "hbar", + "k", + "liter", + "torr", +] hartree, _, _ = physical_constants["Hartree energy"] bohr, _, _ = physical_constants["Bohr radius"] diff --git a/overreact/_datasets.py b/overreact/_datasets.py index 6d60a8fd..2ea4f048 100644 --- a/overreact/_datasets.py +++ b/overreact/_datasets.py @@ -28,4 +28,4 @@ if __name__ == "__main__": for name in logfiles: for compound in logfiles[name]: - print(name, compound, logfiles[name][compound].logfile) + print(name, compound, logfiles[name][compound].logfile) # noqa: T201 diff --git a/overreact/_misc.py b/overreact/_misc.py index 325506d3..6af9d7b9 100644 --- a/overreact/_misc.py +++ b/overreact/_misc.py @@ -6,7 +6,6 @@ """ from functools import lru_cache as cache -from typing import Optional, Text import numpy as np from scipy.stats import cauchy, norm @@ -425,7 +424,7 @@ def _find_package(package): def _check_package( - package: str, found_package: bool, extra_flag: Optional[str] = None + package: str, found_package: bool, extra_flag: str | None = None # noqa: FBT001 ) -> None: """Raise an issue if a package was not found. @@ -454,7 +453,7 @@ def _check_package( Traceback (most recent call last): ... ImportError: You must install `rich` to use this functionality: `pip install rich` (or `pip install "overreact[cli]"`) - """ + """ # noqa: E501 if not found_package: message = ( f"You must install `{package}` to use this functionality: " @@ -468,7 +467,11 @@ def _check_package( # TODO(schneiderfelipe): what does this function returns for identifier="gas" # or identifier="solvent"? def _get_chemical( - identifier, temperature=298.15, pressure=constants.atm, *args, **kwargs + identifier, + temperature=298.15, + pressure=constants.atm, + *args, # noqa: ANN002 + **kwargs, # noqa: ANN003 ): """Wrap `thermo.Chemical`. @@ -518,9 +521,9 @@ def broaden_spectrum( y0, distribution="gaussian", scale=1.0, - fit_points=True, - *args, - **kwargs, + fit_points=True, # noqa: FBT002 + *args, # noqa: ANN002 + **kwargs, # noqa: ANN003 ): """Broaden a point spectrum. @@ -577,8 +580,11 @@ def broaden_spectrum( s = np.sum( [ - yp * distribution.pdf(x, xp, scale=scale, *args, **kwargs) - for xp, yp in zip(x0, y0) + yp + * distribution.pdf( + x, xp, scale=scale, *args, **kwargs # noqa: RUF004, B026 + ) # noqa: RUF100 + for xp, yp in zip(x0, y0) # noqa: B905 ], axis=0, ) @@ -624,7 +630,7 @@ def totuple(a): return a -def halton(num, dim=None, jump=1, cranley_patterson=True): +def halton(num, dim=None, jump=1, cranley_patterson=True): # noqa: FBT002 """Calculate Halton low-discrepancy sequences. Those sequences are good performers for Quasi-Monte Carlo numerical diff --git a/overreact/api.py b/overreact/api.py index 73d7b1ef..adda6b40 100644 --- a/overreact/api.py +++ b/overreact/api.py @@ -5,13 +5,11 @@ If you intend to use **overreact** as a library in a project, you should probably start here. -""" +""" # noqa: D404 from __future__ import annotations -from typing import Union - __all__ = [ "get_k", "get_kappa", @@ -24,7 +22,6 @@ import logging import warnings -from typing import Optional, Text import numpy as np from scipy.misc import derivative @@ -38,7 +35,9 @@ def get_internal_energies( - compounds: dict, qrrho: bool = True, temperature: float = 298.15 + compounds: dict, + qrrho: bool = True, # noqa: FBT001, FBT002 + temperature: float = 298.15, # noqa: RUF100 ): """Obtain internal energies for compounds at a given temperature. @@ -51,7 +50,7 @@ def get_internal_energies( qrrho : bool, optional Apply the quasi-rigid rotor harmonic oscillator (QRRHO) approximation of M. Head-Gordon and others (see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical RRHO. temperature : array-like, optional Absolute temperature in Kelvin. @@ -69,7 +68,7 @@ def get_internal_energies( >>> (internal_energies - internal_energies.min()) / constants.kcal array([0. , 2.20053981]) - """ + """ # noqa: E501 compounds = rx.io._check_compounds(compounds) internal_energies = [] for name in compounds: @@ -92,7 +91,11 @@ def get_internal_energies( return np.array(internal_energies) -def get_enthalpies(compounds: dict, qrrho: bool = True, temperature: float = 298.15): +def get_enthalpies( + compounds: dict, + qrrho: bool = True, # noqa: FBT001, FBT002 + temperature: float = 298.15, # noqa: RUF100 +): # noqa: RUF100 """Obtain enthalpies for compounds at a given temperature. Parameters @@ -104,7 +107,7 @@ def get_enthalpies(compounds: dict, qrrho: bool = True, temperature: float = 298 qrrho : bool, optional Apply the quasi-rigid rotor harmonic oscillator (QRRHO) approximation of M. Head-Gordon and others (see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical RRHO. temperature : array-like, optional Absolute temperature in Kelvin. @@ -130,7 +133,7 @@ def get_enthalpies(compounds: dict, qrrho: bool = True, temperature: float = 298 >>> zero_enthalpies = get_enthalpies(model.compounds, temperature=0) >>> (enthalpies - zero_enthalpies) / constants.kcal array([2.78, 2.50]) - """ + """ # noqa: E501 compounds = rx.io._check_compounds(compounds) enthalpies = [] for name in compounds: @@ -157,7 +160,7 @@ def get_entropies( compounds: dict, environment: str | None = None, method: str = "standard", - qrrho: bool = True, + qrrho: bool = True, # noqa: FBT001, FBT002 temperature: float = 298.15, pressure: float = constants.atm, ): @@ -180,7 +183,7 @@ def get_entropies( entropies such as in [*Phys. Chem. Chem. Phys.*, **2019**, 21, 18920-18929](https://doi.org/10.1039/C9CP03226F) and - [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204–3214](https://doi.org/10.1021/acs.jctc.9b00214). + [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204-3214](https://doi.org/10.1021/acs.jctc.9b00214). Head over to the [discussions](https://github.com/geem-lab/overreact/discussions) if you're interested and would like to contribute. @@ -213,7 +216,7 @@ def get_entropies( >>> sol_entropies = get_entropies(model.compounds, environment="solvent") >>> (sol_entropies - entropies) / constants.calorie array([-6.35360874, -6.35360874]) - """ + """ # noqa: E501 compounds = rx.io._check_compounds(compounds) entropies = [] for name in compounds: @@ -271,7 +274,7 @@ def _check_qrrho(qrrho: bool | tuple[bool, bool]) -> tuple[bool, bool]: qrrho : bool or tuple-like Apply both the quasi-rigid rotor harmonic oscillator (QRRHO) approximations of M. Head-Gordon and others (enthalpy correction, see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) and S. Grimme (entropy correction, see [*Theory. Chem. Eur. J.*, **2012**, 18: 9955-9964](https://doi.org/10.1002/chem.201200497)) on top of the classical RRHO. @@ -295,15 +298,15 @@ def _check_qrrho(qrrho: bool | tuple[bool, bool]) -> tuple[bool, bool]: (True, False) >>> _check_qrrho((False, True)) (False, True) - """ - if qrrho is True: + """ # noqa: E501 + if qrrho is True: # noqa: RET505 return True, True elif qrrho is False: return False, False elif isinstance(qrrho, tuple): return qrrho else: - raise ValueError(f"unrecognized QRRHO specification: {qrrho}") + raise ValueError(f"unrecognized QRRHO specification: {qrrho}") # noqa: EM102 def get_freeenergies( @@ -311,7 +314,7 @@ def get_freeenergies( bias: float = 0.0, environment: str | None = None, method: str = "standard", - qrrho: bool | tuple[bool, bool] = True, + qrrho: bool | tuple[bool, bool] = True, # noqa: FBT002 temperature: float = 298.15, pressure: float = constants.atm, ): @@ -335,7 +338,7 @@ def get_freeenergies( entropies such as in [*Phys. Chem. Chem. Phys.*, **2019**, 21, 18920-18929](https://doi.org/10.1039/C9CP03226F) and - [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204–3214](https://doi.org/10.1021/acs.jctc.9b00214). + [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204-3214](https://doi.org/10.1021/acs.jctc.9b00214). Head over to the [discussions](https://github.com/geem-lab/overreact/discussions) if you're interested and would like to contribute. @@ -343,7 +346,7 @@ def get_freeenergies( qrrho : bool or tuple-like, optional Apply both the quasi-rigid rotor harmonic oscillator (QRRHO) approximations of M. Head-Gordon and others (enthalpy correction, see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) and S. Grimme (entropy correction, see [*Theory. Chem. Eur. J.*, **2012**, 18: 9955-9964](https://doi.org/10.1002/chem.201200497)) on top of the classical RRHO. @@ -382,7 +385,7 @@ def get_freeenergies( array([-1., -1.]) >>> get_freeenergies(model.compounds, bias=[1.0, -1.0]) - freeenergies array([ 1., -1.]) - """ + """ # noqa: E501 qrrho_enthalpy, qrrho_entropy = _check_qrrho(qrrho) enthalpies = get_enthalpies( compounds, qrrho=qrrho_enthalpy, temperature=temperature @@ -404,7 +407,7 @@ def get_k( compounds: dict | None = None, bias: float = 0.0, tunneling: str = "eckart", - qrrho: bool | tuple[bool, bool] = True, + qrrho: bool | tuple[bool, bool] = True, # noqa: FBT002 scale: str = "l mol-1 s-1", temperature: float = 298.15, pressure: float = constants.atm, @@ -431,7 +434,7 @@ def get_k( qrrho : bool or tuple-like, optional Apply both the quasi-rigid rotor harmonic oscillator (QRRHO) approximations of M. Head-Gordonand others (enthalpy correction, see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) and S. Grimme (entropy correction, see [*Theory. Chem. Eur. J.*, **2012**, 18: 9955-9964](https://doi.org/10.1002/chem.201200497)) on top of the classical RRHO. @@ -490,7 +493,7 @@ def get_k( The units of the returned reaction rate constants can be selected for non-unimolecular processes. The following is an attempt to reproduce - [*J Atmos Chem*, **1996** 23, 37–49](https://doi.org/10.1007/BF00058703) for + [*J Atmos Chem*, **1996** 23, 37-49](https://doi.org/10.1007/BF00058703) for the reaction of proton-withdrawal by a chloride radical from the methane molecule :math:`\ce{CH4 + \cdot Cl -> [H3C\cdots H\cdots Cl]^\ddagger -> H3C\cdot + HCl}`: @@ -526,7 +529,7 @@ def get_k( ... bias=np.array([0.0, 0.0, -1.4, 0.0, 0.0]) * constants.kcal, ... temperature=300.0, scale="cm3 particle-1 s-1") array([1.1e-12]) - """ + """ # noqa: E501 qrrho_enthalpy, qrrho_entropy = _check_qrrho(qrrho) scheme = rx.core._check_scheme(scheme) if compounds is not None: @@ -555,12 +558,10 @@ def get_k( if molecularity is None: molecularity = rx.thermo.get_molecularity(scheme.A) + # NOTE(schneiderfelipe): passing molecularity here to rates.eyring messes up + # rate constant units (by a factor of M-1 s-1 to atm-1 s-1), so we leave it as is. k = rates.eyring( delta_freeenergies, - # NOTE(schneiderfelipe): using molecularity here messes rate constant - # units (by a factor of M-1 s-1 to atm-1 s-1), so we leave it as is. - # - # molecularity=molecularity, temperature=temperature, pressure=pressure, volume=volume, @@ -571,7 +572,7 @@ def get_k( while i < len(scheme.is_half_equilibrium): if scheme.is_half_equilibrium[i]: pair = k[i : i + 2] - _K = pair[0] / pair[1] + _K = pair[0] / pair[1] # noqa: N806 denom = pair.min() if denom == 0.0: @@ -637,7 +638,7 @@ def get_kappa( scheme: Scheme, compounds: dict, method: str = "eckart", - qrrho: bool = True, + qrrho: bool = True, # noqa: FBT001, FBT002 temperature: float = 298.15, ): r"""Obtain tunneling transmission coefficients at a given temperature. @@ -661,7 +662,7 @@ def get_kappa( qrrho : bool, optional Apply both the quasi-rigid rotor harmonic oscillator (QRRHO) approximations of M. Head-Gordon and others (enthalpy correction, see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) and S. Grimme (entropy correction, see [*Theory. Chem. Eur. J.*, **2012**, 18: 9955-9964](https://doi.org/10.1002/chem.201200497)) on top of the classical RRHO. @@ -700,15 +701,13 @@ def get_kappa( >>> kappa * get_k(model.scheme, model.compounds, tunneling=None) array([8.e+10]) - """ + """ # noqa: E501 scheme = rx.core._check_scheme(scheme) compounds = rx.io._check_compounds(compounds) if method == "eckart": - # TODO(schneiderfelipe): We need electronic energies + ZPE here, so we + # NOTE(schneiderfelipe): We need electronic energies + ZPE here, so we # get smaller transmission coefficients. - # - # energies = [compounds[name].energy for name in scheme.compounds] energies = get_enthalpies(compounds, qrrho=qrrho, temperature=0.0) delta_forward = rx.get_delta(scheme.B, energies) # B - A delta_backward = delta_forward - rx.get_delta( @@ -743,7 +742,7 @@ def get_kappa( elif method in {"none", None}: kappa = 1.0 else: - raise ValueError(f"unavailable method: '{method}'") + raise ValueError(f"unavailable method: '{method}'") # noqa: EM102 kappas.append(kappa) @@ -763,7 +762,7 @@ def get_drc( y0, t_span=None, method="LSODA", - qrrho=True, + qrrho=True, # noqa: FBT002 scale="l mol-1 s-1", temperature=298.15, dx=1.5e3, # joules @@ -796,14 +795,9 @@ def func(t, x=0.0, i=-1): scheme, compounds=compounds, bias=bias, - # tunneling=tunneling, qrrho=qrrho, scale=scale, temperature=temperature, - # pressure=pressure, - # delta_freeenergies=delta_freeenergies, - # molecularity=molecularity, - # volume=volume, ) _, r = rx.get_y(rx.get_dydt(scheme, k), y0=y0, t_span=t_span, method=method) diff --git a/overreact/coords.py b/overreact/coords.py index f1fb5c78..81cd2e7f 100644 --- a/overreact/coords.py +++ b/overreact/coords.py @@ -3,6 +3,7 @@ """Module dedicated to classifying molecules into point groups.""" +# TODO: add types to this module from __future__ import annotations __all__ = ["find_point_group", "symmetry_number"] @@ -27,7 +28,7 @@ def get_molecular_volume( atomnos, atomcoords, - full_output=False, + full_output=False, # noqa: FBT002 environment="water", method="garza", temperature=298.15, @@ -55,7 +56,7 @@ def get_molecular_volume( entropies such as in [*Phys. Chem. Chem. Phys.*, **2019**, 21, 18920-18929](https://doi.org/10.1039/C9CP03226F) and - [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204–3214](https://doi.org/10.1021/acs.jctc.9b00214). + [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204-3214](https://doi.org/10.1021/acs.jctc.9b00214). Head over to the [discussions](https://github.com/geem-lab/overreact/discussions) if you're interested and would like to contribute. @@ -121,7 +122,7 @@ def get_molecular_volume( >>> get_molecular_volume(data.atomnos, data.atomcoords, full_output=True, ... environment="benzene") (80., 593., 0.1) - """ + """ # noqa: E501 atomnos = np.atleast_1d(atomnos) _, _, atomcoords = inertia(np.ones_like(atomnos), atomcoords) vdw_radii = constants.vdw_radius(atomnos) @@ -157,7 +158,7 @@ def get_molecular_volume( vdw_err = np.std(vdw_volumes) logger.info(f"van der Waals volume = {vdw_volume} Β± {vdw_err} Γ…Β³") if full_output: - if method == "izato": + if method == "izato": # noqa: RET505 cav_volume = np.mean(cav_volumes) cav_err = np.std(cav_volumes) logger.debug(f"Izato cavity volume = {cav_volume} Β± {cav_err} Γ…Β³") @@ -175,14 +176,14 @@ def get_molecular_volume( logger.debug(f"Garza cavity volume = {cav_volume} Γ…Β³") return (vdw_volume, cav_volume, vdw_err) else: - raise ValueError(f"unavailable method: '{method}'") + raise ValueError(f"unavailable method: '{method}'") # noqa: EM102 return vdw_volume def _garza( vdw_volume, environment="water", - full_output=False, + full_output=False, # noqa: FBT002 temperature=298.15, pressure=constants.atm, ): @@ -241,34 +242,30 @@ def _garza( # TODO(schneiderfelipe): things to do: # 1. check correctness of this function, # 2. check it is called correctly everywhere, - # 3. transfer the following commented code to get_chemical (it will become - # a complete abstraction of the solvent/molecular properties): - # - # data_S = datasets.logfiles[solvent.name] - # solvent_volume = coords.get_molecular_volume(data_S.atomnos, - # data_S.atomcoords) + # 3. create a complete abstraction of the solvent/molecular properties: + solvent_volume = solvent.Van_der_Waals_volume / ( constants.angstrom**3 * constants.N_A ) r_free = np.cbrt( solvent.Vm / (constants.angstrom**3 * constants.N_A) - solvent_volume ) - r_M = np.cbrt(vdw_volume) + r_M = np.cbrt(vdw_volume) # noqa: N806 cav_volume = (r_M + r_free) ** 3 if not full_output: return cav_volume - r_S = np.cbrt(solvent_volume) + r_S = np.cbrt(solvent_volume) # noqa: N806 ratio = r_M / r_S area_free = r_free**2 - area_S_total = r_S**2 + area_free + area_S_total = r_S**2 + area_free # noqa: N806 x = max(area_free - r_M**2, 0.0) / area_S_total if np.isclose(x, 0.0): return cav_volume, 1.0, ratio - N_x = 4.0 * np.cbrt(cav_volume) ** 2 / area_S_total + N_x = 4.0 * np.cbrt(cav_volume) ** 2 / area_S_total # noqa: N806 return cav_volume, 1.0 + N_x * x / (1.0 - x), ratio @@ -278,7 +275,7 @@ def symmetry_number(point_group): This function has a set of the most common point groups precomputed, but is able to calculate the symmetry number if it is not found in known tables. Most precomputed values are from - [*Theor Chem Account* **2007** 118, 813–826](https://doi.org/10.1007/s00214-007-0328-0). + [*Theor Chem Account* **2007** 118, 813-826](https://doi.org/10.1007/s00214-007-0328-0). Parameters ---------- @@ -319,7 +316,7 @@ def symmetry_number(point_group): 3 >>> symmetry_number("T") 12 - """ + """ # noqa: E501 point_group = point_group.strip().lower() if point_group in {"c1", "ci", "cs", "c∞v", "k", "r3"}: @@ -374,7 +371,7 @@ def symmetry_number(point_group): elif pieces["letter"] == "s": symmetry_number = int(pieces["number"]) // 2 else: - raise ValueError(f"unknown point group: '{point_group}'") + raise ValueError(f"unknown point group: '{point_group}'") # noqa: EM102 logger.info(f"symmetry number = {symmetry_number}") return symmetry_number @@ -484,7 +481,7 @@ def _find_point_group_linear(atomcoords, groups, rtol=0.0, atol=1.0e-2): See find_point_group for information on parameters and return values. """ - if _has_inversion_center(atomcoords, groups, rtol=rtol, atol=atol): + if _has_inversion_center(atomcoords, groups, rtol=rtol, atol=atol): # noqa: RET505 return "D∞h" else: return "C∞v" @@ -515,7 +512,7 @@ def _find_point_group_spheric( ) for n, _ in proper_axes: - if n == 5: + if n == 5: # noqa: RET505 return "Ih" elif n < 5: break @@ -526,19 +523,8 @@ def _find_point_group_spheric( # see too # http://web.mit.edu/5.03/www/readings/point_groups/point_groups.pdf - # the following workflow is loosely inspired by some articles: + # the employed workflow is loosely inspired by some articles: # 1. doi:10.1016/0097-8485(76)80004-6 - # elif _has_3_C4(atomcoords): - # if _has_center_of_inversion(atomcoords): - # return "oh" - # else: - # return "o" - # elif _has_3_S4_parallel_to_C2(atomcoords): - # return "td" - # elif _has_center_of_inversion(atomcoords): - # return "th" - # else: - # return "t" def _find_point_group_asymmetric( @@ -562,7 +548,7 @@ def _find_point_group_asymmetric( atomcoords, groups, axes, rotor_class, rtol=rtol, atol=atol ) - if proper_axes: + if proper_axes: # noqa: RET505 return _find_point_group_symmetric( atomcoords, groups, @@ -625,28 +611,8 @@ def _find_point_group_symmetric( atomcoords, groups, axes, rotor_class, proper_axes, rtol=rtol, atol=atol ) - # the following workflow is loosely inspired by some articles: + # the employed workflow is loosely inspired by some articles: # 1. doi:10.1016/0097-8485(76)80004-6 - # if _has_proper_ax_of_highest_order(atomcoords): - # if _has_proper_ax_larger_than_2_or_3_C2_perpendicular( - # atomcoords - # ): - # if _has_S2n_parallel_to_Cn(atomcoords): - # if _has_n_sigma_d(atomcoords): - # return "dnd" - # else: - # return "s2n" - # elif _has_nC2_perpendicular_to_Cn(atomcoords): - # if _has_sigma_h(atomcoords): - # return "dnh" - # else: - # return "dn" - # elif _has_n_sigma_v(atomcoords): - # return "cnv" - # elif _has_sigma_h(atomcoords): - # return "cnh" - # else: - # return "cn" def _find_point_group_symmetric_dihedral( @@ -673,7 +639,7 @@ def _find_point_group_symmetric_dihedral( ) if mirror_axes: - if mirror_axes[0][0] == "h": + if mirror_axes[0][0] == "h": # noqa: RET505 return f"D{proper_axes[0][0]}h" elif len([v for c, v in mirror_axes if c == "v"]) == proper_axes[0][0]: # all vertical mirror planes are dihedral for Dnd point groups @@ -705,7 +671,7 @@ def _find_point_group_symmetric_nondihedral( ) if mirror_axes: - if mirror_axes[0][0] == "h": + if mirror_axes[0][0] == "h": # noqa: RET505 return f"C{proper_axes[0][0]}h" elif len([v for c, v in mirror_axes if c == "v"]) == proper_axes[0][0]: return f"C{proper_axes[0][0]}v" @@ -727,14 +693,14 @@ def _update_proper_axes( rtol, atol, nondeg_axes=None, - normalize=False, + normalize=False, # noqa: FBT002 ): """Update axes with ax, and return it with added order (or None). Helper function for _get_proper_axes. """ if nondeg_axes is None: - nondeg_axes = list() + nondeg_axes = [] if normalize: norm = np.linalg.norm(ax) @@ -763,7 +729,7 @@ def _update_proper_axes( return axes, None -def _get_proper_axes( +def _get_proper_axes( # noqa: C901 atomcoords, groups, axes, rotor_class, rtol=0.0, atol=1.0e-2, slack=0.735 ): """Get proper symmetry axes and their orders. @@ -819,14 +785,14 @@ def _get_proper_axes( rtol, atol = slack * rtol, slack * atol if rotor_class[1] == "atomic" or len(atomcoords) == 1: - return list() + return [] axes = np.asarray(axes) atomcoords = np.asarray(atomcoords) orders = _guess_orders(groups, rotor_class) - found_axes = list() - nondeg_axes = list() + found_axes = [] + nondeg_axes = [] if rotor_class[0] == "symmetric prolate": nondeg_axes = [axes[:, 0]] found_axes, order = _update_proper_axes( @@ -957,7 +923,14 @@ def _guess_orders(groups, rotor_class): def _update_improper_axes( - n, ax, axes, atomcoords, groups, rtol, atol, normalize=False # found axes + n, + ax, + axes, + atomcoords, + groups, + rtol, + atol, + normalize=False, # found axes # noqa: FBT002 ): """Update axes with ax and return it. @@ -1036,7 +1009,7 @@ def _get_improper_axes( rtol, atol = slack * rtol, slack * atol if rotor_class[1] == "atomic" or len(atomcoords) == 1: - return list() + return [] axes = np.asarray(axes) atomcoords = np.asarray(atomcoords) @@ -1046,7 +1019,7 @@ def _get_improper_axes( atomcoords, groups, axes, rotor_class, rtol=rtol, atol=atol ) - found_axes = list() + found_axes = [] for n, ax in proper_axes: found_axes = _update_improper_axes( n, @@ -1069,14 +1042,14 @@ def _update_mirror_axes( atol, proper_axes, nondeg_axes=None, - normalize=False, + normalize=False, # noqa: FBT002 ): """Update axes with ax and return it. Helper function for _get_mirror_planes. """ if nondeg_axes is None: - nondeg_axes = list() + nondeg_axes = [] if normalize: norm = np.linalg.norm(ax) @@ -1090,7 +1063,9 @@ def _update_mirror_axes( return axes if all( - _is_symmetric(atomcoords[group], _operation("Οƒ", axis=ax), rtol=rtol, atol=atol) + _is_symmetric( + atomcoords[group], _operation("sigma", axis=ax), rtol=rtol, atol=atol + ) for group in groups[::-1] ): class_ = "" @@ -1111,7 +1086,7 @@ def _update_mirror_axes( return axes -def _get_mirror_planes( +def _get_mirror_planes( # noqa: C901 atomcoords, groups, axes, @@ -1176,7 +1151,7 @@ def _get_mirror_planes( rtol, atol = slack * rtol, slack * atol if rotor_class[1] == "atomic" or len(atomcoords) == 1: - return list() + return [] axes = np.asarray(axes) atomcoords = np.asarray(atomcoords) @@ -1189,13 +1164,13 @@ def _get_mirror_planes( def _kf(x): """Order function for returned list.""" c, v = x - if c: + if c: # noqa: RET505 return -ord(c), v else: return 0, v - found_axes = list() - nondeg_axes = list() + found_axes = [] + nondeg_axes = [] if rotor_class[0] == "symmetric prolate": nondeg_axes = [axes[:, 0]] found_axes = _update_mirror_axes( @@ -1393,15 +1368,15 @@ def _operation(name, order=2, axis=None): array([[ 0., -1., 0.], [ 1., 0., 0.], [ 0., 0., 1.]]) - >>> _operation("Οƒ", axis=[0, 0, 1]) + >>> _operation("sigma", axis=[0, 0, 1]) array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., -1.]]) - >>> _operation("Οƒ", axis=[0, 1, 0]) + >>> _operation("sigma", axis=[0, 1, 0]) array([[ 1., 0., 0.], [ 0., -1., 0.], [ 0., 0., 1.]]) - >>> _operation("Οƒ", axis=[1, 0, 0]) + >>> _operation("sigma", axis=[1, 0, 0]) array([[-1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]]) @@ -1421,25 +1396,26 @@ def _operation(name, order=2, axis=None): if axis is None: axis = np.array([0, 0, 1]) - if name == "i": + if name == "i": # noqa: RET505 return -np.eye(3) elif name == "e": return np.eye(3) - elif name in {"c", "Οƒ", "sigma", "s"}: # normalize axis + elif name in {"c", "Οƒ", "sigma", "s"}: # noqa: RUF001 + # normalize axis axis = np.asarray(axis) axis = axis / np.linalg.norm(axis) if name in {"c", "s"}: rotation = Rotation.from_rotvec(2.0 * np.pi * axis / order).as_matrix() - if name in {"Οƒ", "sigma", "s"}: + if name in {"Οƒ", "sigma", "s"}: # noqa: RUF001 reflection = np.eye(3) - 2.0 * np.outer(axis, axis) if name == "c": return rotation - elif name in {"Οƒ", "sigma"}: + elif name in {"Οƒ", "sigma"}: # noqa: RUF001 return reflection elif name == "s": return rotation @ reflection - raise ValueError(f"unknown operation: '{name}'") + raise ValueError(f"unknown operation: '{name}'") # noqa: EM102 def _classify_rotor(moments, rtol=0.0, atol=1.0e-2, slack=0.870): @@ -1603,17 +1579,17 @@ def gyradius(atommasses, atomcoords, method="iupac"): """ com = np.average(atomcoords, axis=0, weights=atommasses) atomcoords = atomcoords - com - if method == "iupac": + if method == "iupac": # noqa: RET505 return np.sqrt( np.average(np.diag(atomcoords @ atomcoords.T), weights=atommasses) ) elif method == "mean": return np.sqrt(np.mean(np.diag(atomcoords @ atomcoords.T))) else: - raise ValueError(f"unavailable method: '{method}'") + raise ValueError(f"unavailable method: '{method}'") # noqa: EM102 -def inertia(atommasses, atomcoords, align=True): +def inertia(atommasses, atomcoords, align=True): # noqa: FBT002 r"""Calculate primary moments and axes from the inertia tensor. Parameters @@ -1686,8 +1662,6 @@ def inertia(atommasses, atomcoords, align=True): if align: return inertia(atommasses, atomcoords @ axes, align=False) logger.debug(f"moments = {moments} amuΒ·Γ…Β²") - # logger.debug(f"axes = {axes} Γ…") - # logger.debug(f"atomcoords = {atomcoords} Γ…") return moments, axes, atomcoords @@ -1750,15 +1724,15 @@ def calc_hessian(atommasses, atomcoords, vibfreqs, vibdisps): -0.01313383, -0.00678954, 0.25045664, 0.29443748]]) """ dof = 3 * len(atommasses) - L_cart = np.asarray(vibdisps).reshape((len(vibfreqs), dof)).T + L_cart = np.asarray(vibdisps).reshape((len(vibfreqs), dof)).T # noqa: N806 # this function is correct until here - L_cart = np.linalg.qr(L_cart, mode="complete")[0] + L_cart = np.linalg.qr(L_cart, mode="complete")[0] # noqa: N806 atommasses_sqrt = np.sqrt([mass for mass in atommasses for _ in range(3)]) - D = eckart_transform(atommasses, atomcoords) - M = np.diag(1.0 / atommasses_sqrt) - L = np.linalg.solve(M @ D, L_cart) + D = eckart_transform(atommasses, atomcoords) # noqa: N806 + M = np.diag(1.0 / atommasses_sqrt) # noqa: N806 + L = np.linalg.solve(M @ D, L_cart) # noqa: N806 assert np.allclose(M @ D @ L, L_cart), "L_cart is not orthogonal" @@ -1912,21 +1886,24 @@ def eckart_transform(atommasses, atomcoords): y *= np.sqrt(atommasses[:, np.newaxis]) z *= np.sqrt(atommasses[:, np.newaxis]) - D_trans = np.block([x.reshape(1, dof).T, y.reshape(1, dof).T, z.reshape(1, dof).T]) - D_rot = np.array( + D_trans = np.block( # noqa: N806 + [x.reshape(1, dof).T, y.reshape(1, dof).T, z.reshape(1, dof).T] + ) # noqa: RUF100 + D_rot = np.array( # noqa: N806 [ np.cross((atomcoords @ axes)[i], axes[:, j]) / np.sqrt(atommasses[i]) for i in range(natom) for j in range(3) ] ) - D = np.block([D_trans, D_rot]) + D = np.block([D_trans, D_rot]) # noqa: N806 return np.linalg.qr(D, mode="complete")[0] -# thresh >= 0.106 -def _equivalent_atoms( - atommasses, atomcoords, method="cluster", thresh=0.106, plot=False +# NOTE(schneiderfelipe): thresh was found to be reasonable +# when greater than or equal to 0.106. +def _equivalent_atoms( # noqa: C901 + atommasses, atomcoords, method="cluster", thresh=0.106, plot=False # noqa: FBT002 ): """Generate groups of symmetry equivalent atoms. @@ -1986,14 +1963,14 @@ def _equivalent_atoms( [1, 2, 3] """ - if len(atommasses) == 1: # atom + if len(atommasses) == 1: # atom # noqa: RET505 return [[0]] elif len(atommasses) == 2: # diatomic molecule if atommasses[0] == atommasses[1]: return [[0, 1]] return [[0], [1]] - groups = list() + groups = [] def _update_groups_with_condition(condition, groups): # condition is assumed to be an array-like of bool @@ -2001,18 +1978,14 @@ def _update_groups_with_condition(condition, groups): return groups if method == "cluster": - D = squareform(pdist(atomcoords)) - # mu = np.outer(atommasses, atommasses) / np.add.outer( - # atommasses, atommasses - # ) # reduced masses - # D = mu * D # does this help? + D = squareform(pdist(atomcoords)) # noqa: N806 omega = np.mean(D, axis=0) sigma = np.std(D, axis=0) delta = np.sqrt(np.sum(D**2, axis=0)) criteria = np.block([[omega], [sigma], [delta]]).T - Z = linkage(pdist(criteria), method="single") + Z = linkage(pdist(criteria), method="single") # noqa: N806 clusters = fcluster(Z, thresh, criterion="distance") # TODO(schneiderfelipe): this was for debug and should eventually be removed. @@ -2025,7 +1998,7 @@ def _update_groups_with_condition(condition, groups): criteria[clusters == cluster, 0], criteria[clusters == cluster, 1], ) - for i, (atommass, _) in enumerate(zip(atommasses, clusters)): + for i, (atommass, _) in enumerate(zip(atommasses, clusters)): # noqa: B905 plt.annotate(atommass, (criteria[i, 0], criteria[i, 1])) plt.xlabel("omega") plt.ylabel("sigma") @@ -2041,6 +2014,6 @@ def _update_groups_with_condition(condition, groups): for mass in np.unique(atommasses): groups = _update_groups_with_condition(atommasses == mass, groups) else: - raise ValueError(f"unavailable method: '{method}'") + raise ValueError(f"unavailable method: '{method}'") # noqa: EM102 return sorted(groups, key=len) diff --git a/overreact/core.py b/overreact/core.py index f78fa5c1..d45ccaf7 100644 --- a/overreact/core.py +++ b/overreact/core.py @@ -8,7 +8,7 @@ import itertools import re -from typing import NamedTuple, Sequence, Text, Union +from typing import NamedTuple, Sequence import numpy as np @@ -32,7 +32,7 @@ class Scheme(NamedTuple): A: np.ndarray """A matrix of stoichiometric coefficients between reactants and products.""" B: np.ndarray - """A matrix of stoichiometric coefficients between reactants and transition states.""" + """A matrix of stoichiometric coefficients between reactants and transition states.""" # noqa: E501 _abbr_environment = { @@ -50,7 +50,7 @@ class Scheme(NamedTuple): } -def _check_scheme(scheme_or_text: Union[Scheme, str]) -> Scheme: +def _check_scheme(scheme_or_text: Scheme | str) -> Scheme: """Interface transparently between strings and schemes. Parameters @@ -81,7 +81,7 @@ def _check_scheme(scheme_or_text: Union[Scheme, str]) -> Scheme: return parse_reactions(scheme_or_text) -def get_transition_states(A, B, is_half_equilibrium): +def get_transition_states(A, B, is_half_equilibrium): # noqa: N803 """Return the indices of transition states for each reaction. Parameters @@ -341,7 +341,7 @@ def _get_environment(name): if environment in _abbr_environment: environment = _abbr_environment[environment] - return environment + return environment # noqa: RET504 def is_transition_state(name): @@ -399,7 +399,7 @@ def is_transition_state(name): return False -def parse_reactions(text: Union[str, Sequence[str]]) -> Scheme: +def parse_reactions(text: str | Sequence[str]) -> Scheme: # noqa: C901 """ Parse a kinetic model as a chemical reaction scheme. @@ -420,7 +420,7 @@ def parse_reactions(text: Union[str, Sequence[str]]) -> Scheme: ----- The model description should comply with the mini-language for systems of reactions. A semi-formal definition of the grammar in - [Backus–Naur form](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form) + [Backus-Naur form](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form) is given below: equation ::= equation_side arrow equation_side @@ -593,12 +593,12 @@ def parse_reactions(text: Union[str, Sequence[str]]) -> Scheme: [open an issue](https://github.com/geem-lab/overreact/issues/), we'll be happy to hear from you. """ - compounds: dict[str, int] = dict() + compounds: dict[str, int] = {} reactions: dict[ tuple[str, str, bool, str], tuple[tuple[tuple[int, str], ...], bool] - ] = dict() - A = list() # coefficients between reactants and products - B = list() # coefficients between reactants and transition states + ] = {} + A = [] # coefficients between reactants and products # noqa: N806 + B = [] # coefficients between reactants and transition states # noqa: N806 def _add_reaction(reactants, products, is_half_equilibrium, transition): """Local helper function with side-effects.""" @@ -613,13 +613,13 @@ def _add_reaction(reactants, products, is_half_equilibrium, transition): # found new reaction reactions[(reactants, products, is_half_equilibrium, transition)] = None - A_vector = np.zeros(len(compounds)) + A_vector = np.zeros(len(compounds)) # noqa: N806 for coefficient, reactant in reactants: A_vector[compounds[reactant]] = -coefficient - B_vector = A_vector + B_vector = A_vector # noqa: N806 if transition is not None: - B_vector = A_vector.copy() + B_vector = A_vector.copy() # noqa: N806 # it's assumed that # 1. there's a singe transition compound, and @@ -633,15 +633,13 @@ def _add_reaction(reactants, products, is_half_equilibrium, transition): is_half_equilibrium and (products, reactants, is_half_equilibrium, transition) in reactions ): - B_vector = np.zeros(len(compounds)) + B_vector = np.zeros(len(compounds)) # noqa: N806 A.append(A_vector) B.append(B_vector) - after_transitions: dict[tuple[tuple[int, str], ...], list[tuple[int, str]]] = dict() - before_transitions: dict[ - tuple[tuple[int, str], ...], list[tuple[int, str]] - ] = dict() + after_transitions: dict[tuple[tuple[int, str], ...], list[tuple[int, str]]] = {} + before_transitions: dict[tuple[tuple[int, str], ...], list[tuple[int, str]]] = {} for reactants, products, is_half_equilibrium in _parse_reactions(text): if (reactants, products, False, None) in reactions or ( @@ -663,7 +661,7 @@ def _add_reaction(reactants, products, is_half_equilibrium, transition): # it's assumed that if a transition shows up, # 1. it's the only compound in its side of the reaction, and # 2. its coefficient equals one - if is_transition_state(reactants[-1][-1]): + if is_transition_state(reactants[-1][-1]): # noqa: RET507 for before_reactants in before_transitions.get(reactants, []): _add_reaction( before_reactants, products, is_half_equilibrium, reactants @@ -753,7 +751,7 @@ def _parse_reactions(text): continue pieces = re.split(r"\s*(->|<=>|<-)\s*", line) - for reactants, arrow, products in zip( + for reactants, arrow, products in zip( # noqa: B905 pieces[:-2:2], pieces[1:-1:2], pieces[2::2] ): if arrow == "<-": diff --git a/overreact/io.py b/overreact/io.py index 37000332..0d9bc732 100644 --- a/overreact/io.py +++ b/overreact/io.py @@ -13,7 +13,6 @@ import warnings from collections import defaultdict from collections.abc import MutableMapping -from typing import Text import numpy as np @@ -27,7 +26,7 @@ logger = logging.getLogger(__name__) -def parse_model(path: str, force_compile: bool = False): +def parse_model(path: str, force_compile: bool = False): # noqa: FBT001, FBT002 """Parse either a source or model input file, whichever is available. A **source input file** (also known as a `.k` file) contains all the information needed @@ -93,7 +92,7 @@ def parse_model(path: str, force_compile: bool = False): >>> model_from_source = parse_model("data/ethane/B97-3c/model") >>> model_from_source == model True - """ + """ # noqa: E501 if not path.endswith((".k", ".jk")): path = f"{path}.jk" logger.warning(f"assuming `.jk` file in {path}") @@ -107,7 +106,8 @@ def parse_model(path: str, force_compile: bool = False): path_k = f"{name}.k" logger.info(f"parsing `.k` file in {path_k}") if not os.path.isfile(path_k): - raise FileNotFoundError(f"no `.k` file found in {path_k}") + # TODO: add a nice error message here and everywhere? + raise FileNotFoundError(f"no `.k` file found in {path_k}") # noqa: EM102 model = _parse_source(path_k) with open(path_jk, "w") as f: @@ -179,7 +179,7 @@ def _parse_model(file_or_path): return dotdict(model) -def _parse_source(file_path_or_str): +def _parse_source(file_path_or_str): # noqa: C901 """Parse a source input file (also known as a `.k` file). A source input file contains all the information needed to create a model input file @@ -440,7 +440,7 @@ def _check_compounds(compounds): return dict(compounds) -def parse_compounds(text, path=("",), select=None): +def parse_compounds(text, path=("",), select=None): # noqa: C901 """Parse a set of compounds. Parameters @@ -548,6 +548,7 @@ def parse_compounds(text, path=("",), select=None): value = value.strip('"') for p in path: try: + # TODO: move on to use pathlib. logger.info(f"trying to read {os.path.join(p, value)}") compounds[name].update(read_logfile(os.path.join(p, value))) except FileNotFoundError: @@ -556,7 +557,7 @@ def parse_compounds(text, path=("",), select=None): break if not success: raise FileNotFoundError( - f"could not find logfile '{value}' in path: {path}" + f"could not find logfile '{value}' in path: {path}" # noqa: E501, EM102 ) else: # one-line JSON-encoded object @@ -569,7 +570,7 @@ def parse_compounds(text, path=("",), select=None): # Apply `extra_energy_term`s for name in compounds: if "extra_energy_term" in compounds[name]: - # TODO: this assumes that 1. there's a single `extra_energy_term` and 2. `energy` is present + # TODO: this assumes that 1. there's a single `extra_energy_term` and 2. `energy` is present # noqa: E501 compounds[name]["energy"] += compounds[name]["extra_energy_term"] return dotdict(compounds) @@ -644,7 +645,7 @@ def read_logfile(path): (0.0, 0.0, 0.0)))} """ if not (parser := ccopen(path)): - raise FileNotFoundError(f"could not find logfile '{path}'") + raise FileNotFoundError(f"could not find logfile '{path}'") # noqa: EM102 origin = parser.__class__.__name__.lower() logger.info(f"reading a {origin} logfile: {path}") try: @@ -678,9 +679,15 @@ def read_logfile(path): # cclib has failed. if origin == "orca": try: + # TODO(schneiderfelipe): only run the code below if we know it is + # an ORCA logfile. The code in this final section should be very + # specific in supplying *only* things cclib is not (yet) able to + # parse. Should we add a check for this as well? data = _read_orca_logfile(path, minimal=False) except FileNotFoundError: - raise FileNotFoundError(f"could not parse logfile: '{path}'") + raise FileNotFoundError( # noqa: B904 + f"could not parse logfile: '{path}'" # noqa: EM102 + ) # noqa: RUF100 else: raise return dotdict(data) @@ -738,14 +745,14 @@ def _read_orca_hess(path): columns = [int(j) for j in line.split()] for i in range(n): entries = next(file).split()[1:] # first is same as i - for j, entry in zip(columns, entries): + for j, entry in zip(columns, entries): # noqa: B905 hessian[i, j] = float(entry) line = next(file).strip() return hessian # heavily inspired by pieces of cclib -def _read_orca_logfile(path, minimal=True): +def _read_orca_logfile(path, minimal=True): # noqa: FBT002 """Read an ORCA logfile. This function is a temporary reader, to be used until cclib supports all @@ -910,7 +917,7 @@ def _read_orca_logfile(path, minimal=True): # https://stackoverflow.com/a/23689767/4039050 -class dotdict(dict): +class dotdict(dict): # noqa: N801 """Access dictionary attributes through dot.notation. This object is meant to be immutable, so that it can be hashed. @@ -939,7 +946,7 @@ class dotdict(dict): """ - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: # noqa: ANN101, ANN002, ANN003 super().__init__(*args, **kwargs) for key, val in self.items(): @@ -950,7 +957,7 @@ def __init__(self, *args, **kwargs): __getattr__ = dict.get - def __setitem__(self, key, value): + def __setitem__(self, key, value): # noqa: ANN101, ARG002, ANN204 """ Set an item. @@ -961,18 +968,18 @@ def __setitem__(self, key, value): NotImplementedError If one attempts to change a value. """ - raise NotImplementedError("dotdict objects are immutable") + raise NotImplementedError("dotdict objects are immutable") # noqa: EM101 # https://stackoverflow.com/a/1151686/4039050 # https://stackoverflow.com/a/1151705/4039050 - def __hash__(self): + def __hash__(self): # noqa: ANN101, ANN204, D105 return hash(self._key()) # https://stackoverflow.com/a/16162138/4039050 - def _key(self): + def _key(self): # noqa: ANN101 return (frozenset(self), frozenset(self.items())) - def __eq__(self, other): + def __eq__(self, other): # noqa: ANN101, ANN204, D105 return self._key() == other._key() @@ -982,10 +989,10 @@ class _LazyDict(MutableMapping): _function = None - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: # noqa: ANN101, ANN002, ANN003 self._dict = dict(*args, **kwargs) - def __getitem__(self, key): + def __getitem__(self, key): # noqa: ANN101, ANN204 """Evaluate value.""" value = self._dict[key] if not isinstance(value, dict): @@ -993,21 +1000,21 @@ def __getitem__(self, key): value = data self._dict[key] = data - return value + return value # noqa: RET504 - def __setitem__(self, key, value): + def __setitem__(self, key, value): # noqa: ANN101, ANN204 """Store value lazily.""" self._dict[key] = value - def __delitem__(self, key): + def __delitem__(self, key): # noqa: ANN101, ANN204 """Delete value.""" return self._dict[key] - def __iter__(self): + def __iter__(self): # noqa: ANN101, ANN204 """Iterate over dictionary.""" return iter(self._dict) - def __len__(self): + def __len__(self): # noqa: ANN101, ANN204 """Evaluate size of dictionary.""" return len(self._dict) @@ -1015,12 +1022,19 @@ def __len__(self): class InterfaceFormatter(logging.Formatter): """Simple logging interface.""" - def __init__(self, fmt=None, datefmt=None, style="%", *args, **kwargs): + def __init__( + self, # noqa: ANN101 + fmt=None, + datefmt=None, + style="%", + *args, # noqa: ANN002 + **kwargs, # noqa: ANN003 + ) -> None: # noqa: RUF100 super().__init__(fmt=fmt, datefmt=datefmt, style=style) self.wrapper = textwrap.TextWrapper(*args, **kwargs) self.tab = 4 * " " - def format(self, record): + def format(self, record): # noqa: ANN101, A003 """Format log message.""" self.wrapper.initial_indent = self.tab self.wrapper.subsequent_indent = 2 * self.tab diff --git a/overreact/rates.py b/overreact/rates.py index db584762..8b14d1cc 100644 --- a/overreact/rates.py +++ b/overreact/rates.py @@ -5,8 +5,6 @@ from __future__ import annotations -from typing import Optional, Union - __all__ = ["eyring"] @@ -21,7 +19,7 @@ @np.vectorize -def liquid_viscosity(id, temperature=298.15, pressure=constants.atm): +def liquid_viscosity(id, temperature=298.15, pressure=constants.atm): # noqa: A002 """Dynamic viscosity of a solvent. This function requires the `thermo` package for obtaining property values. @@ -142,7 +140,7 @@ def collins_kimball(k_tst, k_diff): return k_tst * k_diff / (k_tst + k_diff) -def convert_rate_constant( +def convert_rate_constant( # noqa: C901 val, new_scale, old_scale="l mol-1 s-1", @@ -228,7 +226,6 @@ def convert_rate_constant( ... == convert_rate_constant(1.0, "mmHg-1 s-1", molecularity=2) True """ - # new_scale, old_scale = new_scale.lower(), old_scale.lower() for alt, ref in [("M-1", "l mol-1"), ("ml", "cm3"), ("torr-1", "mmHg-1")]: new_scale, old_scale = new_scale.replace(alt, ref), old_scale.replace(alt, ref) @@ -255,7 +252,7 @@ def convert_rate_constant( elif old_scale == "atm-1 s-1": factor = rx.thermo.molar_volume(temperature, pressure) * constants.kilo else: - raise ValueError(f"old unit not recognized: {old_scale}") + raise ValueError(f"old unit not recognized: {old_scale}") # noqa: EM102 # now we convert l mol-1 s-1 to what we need if new_scale == "cm3 mol-1 s-1": @@ -273,7 +270,7 @@ def convert_rate_constant( elif new_scale == "atm-1 s-1": factor *= 1.0 / (rx.thermo.molar_volume(temperature, pressure) * constants.kilo) else: - raise ValueError(f"new unit not recognized: {new_scale}") + raise ValueError(f"new unit not recognized: {new_scale}") # noqa: EM102 factor **= molecularity - 1 logger.info(f"conversion factor ({old_scale} to {new_scale}) = {factor}") diff --git a/overreact/simulate.py b/overreact/simulate.py index d4baed7e..d42978ba 100644 --- a/overreact/simulate.py +++ b/overreact/simulate.py @@ -7,6 +7,7 @@ """ +# TODO: type this module. from __future__ import annotations __all__ = ["get_y", "get_dydt", "get_fixed_scheme"] @@ -33,7 +34,7 @@ # of eight to equilibria, which seems reasonable. **This choice was made # using the standard ODE parameters (rtol=1e-3, atol=1e-6).** # -# TODO: this should probably be exposed to the user and use the actual simulation temperature. +# TODO: this should probably be exposed to the user and use the actual simulation temperature. # noqa: E501 EF = np.exp(1.25 * constants.kcal / (constants.R * 298.15)) @@ -45,7 +46,7 @@ from jax import jacfwd, jit from jax.config import config - config.update("jax_enable_x64", True) + config.update("jax_enable_x64", True) # noqa: FBT003 else: logger.warning( "Install JAX to have just-in-time compilation: " @@ -167,16 +168,14 @@ def get_y( # - some numberical limits, first_step = np.min( [ - 1e-14, - 1 / 27e9, + 1e-14, # Too small? + 1 / 27e9, # Too small? 1 / 1.5e10, (t_span[1] - t_span[0]) / 100.0, np.finfo(np.float16).eps, np.finfo(np.float32).eps, - np.finfo(np.float64).eps, + np.finfo(np.float64).eps, # Too small? np.nextafter(np.float16(0), np.float16(1)), - # np.nextafter(np.float33(0), np.float32(1)), # Too small. - # np.nextafter(np.float64(0), np.float64(1)), # Too small. ] ) logger.warning(f"first step = {first_step} s") @@ -205,7 +204,7 @@ def r(t): # TODO(schneiderfelipe): this is probably not the best way to # vectorize a function! try: - return np.array([dydt(_t, _y) for _t, _y in zip(t, y(t).T)]).T + return np.array([dydt(_t, _y) for _t, _y in zip(t, y(t).T)]).T # noqa: B905 except TypeError: return dydt(t, y(t)) @@ -273,11 +272,11 @@ def get_dydt(scheme, k, ef=EF): """ scheme = rx.core._check_scheme(scheme) - A = jnp.asarray(scheme.A) - M = jnp.where(A > 0, 0, -A).T + A = jnp.asarray(scheme.A) # noqa: N806 + M = jnp.where(A > 0, 0, -A).T # noqa: N806 k_adj = _adjust_k(scheme, k, ef=ef) - def _dydt(t, y): + def _dydt(t, y): # noqa: ARG001 r = k_adj * jnp.prod(jnp.power(y, M), axis=1) return jnp.dot(A, r) @@ -285,10 +284,11 @@ def _dydt(t, y): # Using JAX for JIT compilation is much faster. _dydt = jit(_dydt) + # NOTE(schneiderfelipe): the following function is defined + # such that _jac(t, y)[i, j] == d f_i / d y_j, + # with shape of (n_compounds, n_compounds). def _jac(t, y): logger.warning(f"\x1b[A@t = \x1b[94m{t:10.3f} \x1b[ms\x1b[K") - # _jac(t, y)[i, j] == d f_i / d y_j - # shape is (n_compounds, n_compounds) return jacfwd(lambda _y: _dydt(t, _y))(y) _dydt.jac = _jac @@ -370,9 +370,6 @@ def _adjust_k(scheme, k, ef=EF): # set the smallest one to be equal to one k = k / k.min() - # else: - # # only zero or more true reactions (no equilibria) - # pass return jnp.asarray(k) @@ -534,7 +531,7 @@ def get_fixed_scheme(scheme, k, fixed_y0): new_k = np.asarray(k, dtype=float).copy() new_reactions = [] for i, (reaction, is_half_equilibrium) in enumerate( - zip(scheme.reactions, scheme.is_half_equilibrium) + zip(scheme.reactions, scheme.is_half_equilibrium) # noqa: B905 ): for reactants, products, _ in rx.core._parse_reactions(reaction): new_reactants = tuple( @@ -558,20 +555,20 @@ def get_fixed_scheme(scheme, k, fixed_y0): new_reactions = tuple(r for r in rx.core._unparse_reactions(new_reactions)) new_is_half_equilibrium = scheme.is_half_equilibrium - new_A = [] - new_B = [] + new_A = [] # noqa: N806 + new_B = [] # noqa: N806 new_compounds = [] - for i, (compound, row_A, row_B) in enumerate( - zip(scheme.compounds, scheme.A, scheme.B) - ): + for compound, row_A, row_B in zip( # noqa: B905, N806 + scheme.compounds, scheme.A, scheme.B + ): # noqa: RUF100 if compound not in fixed_y0: new_compounds.append(compound) new_A.append(row_A) new_B.append(row_B) new_compounds = tuple(new_compounds) - new_A = tuple(new_A) - new_B = tuple(new_B) + new_A = tuple(new_A) # noqa: N806 + new_B = tuple(new_B) # noqa: N806 return ( rx.core.Scheme( @@ -592,7 +589,7 @@ def get_bias( data, y0, tunneling="eckart", - qrrho=True, + qrrho=True, # noqa: FBT002 temperature=298.15, pressure=constants.atm, method="LSODA", @@ -618,7 +615,7 @@ def get_bias( qrrho : bool or tuple-like, optional Apply both the quasi-rigid rotor harmonic oscillator (QRRHO) approximations of M. Head-Gordon and others (enthalpy correction, see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) and S. Grimme (entropy correction, see + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) and S. Grimme (entropy correction, see [*Theory. Chem. Eur. J.*, **2012**, 18: 9955-9964](https://doi.org/10.1002/chem.201200497)) on top of the classical RRHO. temperature : array-like, optional Absolute temperature in Kelvin. @@ -659,7 +656,7 @@ def get_bias( ... 2.632179124780495175e-5]} >>> get_bias(model.scheme, model.compounds, data, y0) / constants.kcal # doctest: +SKIP -1.36 - """ + """ # noqa: E501 max_time = np.max(data["t"]) def f(bias): diff --git a/overreact/thermo/__init__.py b/overreact/thermo/__init__.py index 34e8937e..5a5ae100 100644 --- a/overreact/thermo/__init__.py +++ b/overreact/thermo/__init__.py @@ -9,7 +9,6 @@ import logging -from typing import Optional, Union import numpy as np from scipy.misc import derivative @@ -61,7 +60,7 @@ def calc_trans_entropy( entropies such as in [*Phys. Chem. Chem. Phys.*, **2019**, 21, 18920-18929](https://doi.org/10.1039/C9CP03226F) and - [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204–3214](https://doi.org/10.1021/acs.jctc.9b00214). + [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204-3214](https://doi.org/10.1021/acs.jctc.9b00214). Head over to the [discussions](https://github.com/geem-lab/overreact/discussions) if you're interested and would like to contribute. @@ -104,7 +103,7 @@ def calc_trans_entropy( >>> calc_trans_entropy(35.45, [17], [[0, 0, 0]], environment="benzene", ... method="garza") 121.7 - """ + """ # noqa: E501 # TODO(schneiderfelipe): This is probably an ugly hack for zero temperature and # certainly wrong (https://physics.stackexchange.com/a/400431/77366). # See https://physics.stackexchange.com/a/468649/77366 and @@ -116,8 +115,10 @@ def calc_trans_entropy( if environment in {"gas", None} or method == "standard": volume = molar_volume(temperature=temperature, pressure=pressure) - elif environment == "solid": - raise ValueError(f"environment not yet implemented: {environment}") + elif environment == "solid": # noqa: RET506 + raise ValueError( + f"environment not yet implemented: {environment}" # noqa: EM102 + ) # noqa: RUF100 else: assert atomnos is not None, "atomnos must be provided" assert atomcoords is not None, "atomcoords must be provided" @@ -144,7 +145,7 @@ def calc_internal_energy( degeneracy=1, moments=None, vibfreqs=None, - qrrho=True, + qrrho=True, # noqa: FBT002 temperature=298.15, ): """Calculate internal energy. @@ -164,7 +165,7 @@ def calc_internal_energy( qrrho : bool, optional Apply the quasi-rigid rotor harmonic oscillator (QRRHO) approximation of M. Head-Gordon and others (see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical RRHO. temperature : array-like, optional Absolute temperature in Kelvin. @@ -194,7 +195,7 @@ def calc_internal_energy( ... degeneracy=degeneracy) # F 4039. - """ + """ # noqa: E501 internal_energy = ( calc_trans_energy(temperature=temperature) + calc_elec_energy(energy, degeneracy, temperature=temperature) @@ -212,7 +213,7 @@ def calc_enthalpy( degeneracy=1, moments=None, vibfreqs=None, - qrrho=True, + qrrho=True, # noqa: FBT002 temperature=298.15, ): """Calculate enthalpy. @@ -234,7 +235,7 @@ def calc_enthalpy( qrrho : bool, optional Apply the quasi-rigid rotor harmonic oscillator (QRRHO) approximation of M. Head-Gordon and others (see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical RRHO. temperature : array-like, optional Absolute temperature in Kelvin. @@ -263,7 +264,7 @@ def calc_enthalpy( ... degeneracy=degeneracy) # F 6518. - """ + """ # noqa: E501 temperature = np.asarray(temperature) enthalpy = ( @@ -294,7 +295,7 @@ def calc_entropy( vibfreqs=None, environment="gas", method="standard", - qrrho=True, + qrrho=True, # noqa: FBT002 temperature=298.15, pressure=constants.atm, ): @@ -330,7 +331,7 @@ def calc_entropy( entropies such as in [*Phys. Chem. Chem. Phys.*, **2019**, 21, 18920-18929](https://doi.org/10.1039/C9CP03226F) and - [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204–3214](https://doi.org/10.1021/acs.jctc.9b00214). + [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204-3214](https://doi.org/10.1021/acs.jctc.9b00214). Head over to the [discussions](https://github.com/geem-lab/overreact/discussions) if you're interested and would like to contribute. @@ -389,7 +390,7 @@ def calc_entropy( >>> calc_entropy(1.008, 1, [[0, 0, 0]], environment="water") # doctest: +SKIP 10.5 - """ + """ # noqa: E501 entropy = ( calc_trans_entropy( atommasses=atommasses, @@ -419,8 +420,10 @@ def calc_entropy( if environment in {"gas", None}: pass - elif environment == "solid": - raise ValueError(f"environment not yet implemented: {environment}") + elif environment == "solid": # noqa: RET506 + raise ValueError( + f"environment not yet implemented: {environment}" # noqa: EM102 + ) # noqa: RUF100 else: concentration_correction = -change_reference_state( temperature=temperature, pressure=pressure @@ -450,7 +453,7 @@ def calc_heat_capacity( degeneracy=1, moments=None, vibfreqs=None, - qrrho=True, + qrrho=True, # noqa: FBT002 temperature=298.15, dx=3e-5, order=3, @@ -472,7 +475,7 @@ def calc_heat_capacity( qrrho : bool, optional Apply the quasi-rigid rotor harmonic oscillator (QRRHO) approximation of M. Head-Gordon and others (see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical RRHO. temperature : array-like, optional Absolute temperature in Kelvin. @@ -506,7 +509,7 @@ def calc_heat_capacity( ... degeneracy=degeneracy) # F 14.43 - """ + """ # noqa: D202, E501 def func(temperature): return calc_internal_energy( @@ -560,7 +563,7 @@ def get_molecularity(transform): return np.where(res > 0, res, 1) -def get_delta(transform, property): +def get_delta(transform, property): # noqa: A002 """Calculate deltas according to reactions. Delta properties are differences in a property between the final and @@ -730,7 +733,7 @@ def equilibrium_constant( You can easily check that the above values match the values given [here](https://en.wikipedia.org/wiki/Stability_constants_of_complexes#The_chelate_effect). - """ + """ # noqa: E501 temperature = np.asarray(temperature) equilibrium_constant = np.exp( @@ -834,7 +837,7 @@ def change_reference_state( old_reference = 1.0 / volume res = sign * constants.R * np.log(new_reference / old_reference) - return res + return res # noqa: RET504 # TODO(schneiderfelipe): we need a concrete example of this for testing. diff --git a/overreact/thermo/_gas.py b/overreact/thermo/_gas.py index c4e1a938..c0f9d76a 100644 --- a/overreact/thermo/_gas.py +++ b/overreact/thermo/_gas.py @@ -193,7 +193,9 @@ def calc_elec_entropy(energy=0.0, degeneracy=1, temperature=298.15): return electronic_entropy -def calc_rot_energy(moments=None, independent=False, weights=1.0, temperature=298.15): +def calc_rot_energy( + moments=None, independent=False, weights=1.0, temperature=298.15 # noqa: FBT002 +): # noqa: RUF100 r"""Calculate the rotational energy of an ideal gas. This function uses the truncation of equation 6-48 of Statistical @@ -210,7 +212,7 @@ def calc_rot_energy(moments=None, independent=False, weights=1.0, temperature=29 Whether rotational degrees of freedom should be considered independent (this is to be mainly used in the quasi-RRHO approach of M. Head-Gordon, see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)). + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)). weights : array-like, optional temperature : array-like, optional Absolute temperature in Kelvin. @@ -239,7 +241,7 @@ def calc_rot_energy(moments=None, independent=False, weights=1.0, temperature=29 >>> calc_rot_energy() 0.0 - """ + """ # noqa: E501 temperature = np.asarray(temperature) if np.isclose(temperature, 0.0): @@ -282,7 +284,7 @@ def calc_rot_entropy( symmetry_number=1, environment="gas", method="standard", - independent=False, + independent=False, # noqa: FBT002 weights=1.0, temperature=298.15, pressure=constants.atm, @@ -320,7 +322,7 @@ def calc_rot_entropy( entropies such as in [*Phys. Chem. Chem. Phys.*, **2019**, 21, 18920-18929](https://doi.org/10.1039/C9CP03226F) and - [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204–3214](https://doi.org/10.1021/acs.jctc.9b00214). + [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204-3214](https://doi.org/10.1021/acs.jctc.9b00214). Head over to the [discussions](https://github.com/geem-lab/overreact/discussions) if you're interested and would like to contribute. @@ -381,7 +383,7 @@ def calc_rot_entropy( ... atommasses=data.atommasses, atomnos=data.atomnos, ... atomcoords=data.atomcoords) 47.1 - """ + """ # noqa: E501 temperature = np.asarray(temperature) if np.isclose(temperature, 0.0): @@ -417,13 +419,15 @@ def calc_rot_entropy( rotational_entropy = constants.R * gamma / 2.0 if environment in {"gas", None} or method == "standard": pass - elif environment == "solid": - raise ValueError(f"environment not yet implemented: {environment}") + elif environment == "solid": # noqa: RET506 + raise ValueError( + f"environment not yet implemented: {environment}" # noqa: EM102 + ) # noqa: RUF100 else: assert atomnos is not None, "atomnos must be given" assert atomcoords is not None, "atomcoords must be given" vdw_volume = coords.get_molecular_volume(atomnos, atomcoords) - cav_volume, N_cav, _ = coords._garza( + cav_volume, N_cav, _ = coords._garza( # noqa: N806 vdw_volume, environment, full_output=True, @@ -445,7 +449,7 @@ def calc_rot_entropy( return rotational_entropy -def calc_vib_energy(vibfreqs=None, qrrho=True, temperature=298.15): +def calc_vib_energy(vibfreqs=None, qrrho=True, temperature=298.15): # noqa: FBT002 r"""Calculate the vibrational energy of an ideal gas. This function uses equation 8-7 of Statistical Thermodynamics, McQuarrie, @@ -459,7 +463,7 @@ def calc_vib_energy(vibfreqs=None, qrrho=True, temperature=298.15): qrrho : bool, optional Apply the quasi-rigid rotor harmonic oscilator (QRRHO) approximation of M. Head-Gordon and others (see - [*J. Phys. Chem. C* **2015**, 119, 4, 1840–1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical + [*J. Phys. Chem. C* **2015**, 119, 4, 1840-1850](http://dx.doi.org/10.1021/jp509921r)) on top of the classical RRHO. temperature : array-like, optional Absolute temperature in Kelvin. @@ -496,7 +500,7 @@ def calc_vib_energy(vibfreqs=None, qrrho=True, temperature=298.15): >>> calc_vib_energy() 0.0 - """ + """ # noqa: E501 vibrational_temperature = _vibrational_temperature(vibfreqs) if not vibrational_temperature.size: logger.warning("assuming zero vibrational energy for atomic system") @@ -533,7 +537,7 @@ def calc_vib_energy(vibfreqs=None, qrrho=True, temperature=298.15): # TODO(schneiderfelipe): construct corrections using anharmonicity (probably # using corrections from a Morse potential). See also problem 6-24 of # Statistical Thermodynamics, McQuarrie. -def calc_vib_entropy(vibfreqs=None, qrrho=True, temperature=298.15): +def calc_vib_entropy(vibfreqs=None, qrrho=True, temperature=298.15): # noqa: FBT002 r"""Calculate the vibrational entropy of an ideal gas. This function calculates the third and fourth terms of equation 6-54 of @@ -580,7 +584,7 @@ def calc_vib_entropy(vibfreqs=None, qrrho=True, temperature=298.15): >>> calc_vib_entropy() 0.0 - """ + """ # noqa: E501 if np.isclose(temperature, 0.0): logger.warning("assuming vibrational entropy zero at zero temperature") return 0.0 @@ -648,7 +652,7 @@ def _sackur_tetrode(atommasses, volume, temperature=298.15): q_trans = volume / (constants.N_A * debroglie_wavelength**3) assert q_trans > 1.0, ( f"de Broglie wavelength {debroglie_wavelength} is too large for the gas to " - "satisfy Maxwell–Boltzmann statistics (classical regime)" + "satisfy Maxwell-Boltzmann statistics (classical regime)" ) return constants.R * (np.log(q_trans) + 2.5) @@ -799,14 +803,14 @@ def _check_vibfreqs(vibfreqs=None, cutoff=-50.0): if len(vibfreqs[vibfreqs < 0]) > 0: logger.warning( - f"imaginary frequencies found: using the absolute value of all above {-cutoff}i cm-1, ignoring the rest" + f"imaginary frequencies found: using the absolute value of all above {-cutoff}i cm-1, ignoring the rest" # noqa: E501 ) return np.abs(vibfreqs[vibfreqs > cutoff]) # B_av was chosen as 1.0e-44 / (atomic_mass * angstrom**2) -def _vibrational_moment(vibfreqs=None, B_av=602.2140762081121): +def _vibrational_moment(vibfreqs=None, B_av=602.2140762081121): # noqa: N803 """Calculate moments of inertia for a free rotors with the same frequencies. This is part of the quasi-RRHO approach of S. Grimme, see @@ -831,7 +835,7 @@ def _vibrational_moment(vibfreqs=None, B_av=602.2140762081121): array([0.52913]) >>> _vibrational_moment([5.0, 10.0]) array([10.41, 5.250]) - """ + """ # noqa: E501 # TODO(schneiderfelipe): should we receive vibrational temperatures and # avoid calling it twice when calling calc_vib_entropy? @@ -883,7 +887,7 @@ def _head_gordon_damping(vibfreqs, omega=103.61231288246945, alpha=4): array([6.e-06, 6.e-06, 4.e-04, 5.e-01]) >>> _head_gordon_damping([-55.0, -5.0, 5.0, 15.0, 100.0]) array([6.e-06, 6.e-06, 4.e-04, 5.e-01]) - """ + """ # noqa: E501 vibfreqs = _check_vibfreqs(vibfreqs) return 1.0 / (1.0 + (omega / vibfreqs) ** alpha) diff --git a/overreact/thermo/_solv.py b/overreact/thermo/_solv.py index 7debd756..d9549831 100644 --- a/overreact/thermo/_solv.py +++ b/overreact/thermo/_solv.py @@ -187,7 +187,7 @@ def molar_free_volume( entropies such as in [*Phys. Chem. Chem. Phys.*, **2019**, 21, 18920-18929](https://doi.org/10.1039/C9CP03226F) and - [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204–3214](https://doi.org/10.1021/acs.jctc.9b00214). + [*J. Chem. Theory Comput.* **2019**, 15, 5, 3204-3214](https://doi.org/10.1021/acs.jctc.9b00214). Head over to the [discussions](https://github.com/geem-lab/overreact/discussions) if you're interested and would like to contribute. @@ -250,17 +250,17 @@ def molar_free_volume( >>> molar_free_volume(data.atomnos, data.atomcoords, environment="benzene") \ ... / (constants.angstrom ** 3 * constants.N_A) 593. - """ + """ # noqa: E501 if method == "izato": vdw_volume, cav_volume, _ = coords.get_molecular_volume( atomnos, atomcoords, method="izato", full_output=True ) - r_M, r_cav = np.cbrt(vdw_volume), np.cbrt(cav_volume) + r_M, r_cav = np.cbrt(vdw_volume), np.cbrt(cav_volume) # noqa: N806 molar_free_volume = (r_cav - r_M) ** 3 * constants.angstrom**3 * constants.N_A elif method == "garza": # TODO(schneiderfelipe): test for the following solvents: water, # pentane, hexane, heptane and octane. - cav_volume, N_cav, _ = coords._garza( + cav_volume, N_cav, _ = coords._garza( # noqa: N806 coords.get_molecular_volume(atomnos, atomcoords), environment, full_output=True, @@ -269,6 +269,6 @@ def molar_free_volume( ) molar_free_volume = N_cav * cav_volume * constants.angstrom**3 * constants.N_A else: - raise ValueError(f"unrecognized method: '{method}'") + raise ValueError(f"unrecognized method: '{method}'") # noqa: EM102 logger.debug(f"molar free volume = {molar_free_volume} Γ…Β³") return molar_free_volume diff --git a/overreact/tunnel.py b/overreact/tunnel.py index 0d1914c1..8900e8f2 100644 --- a/overreact/tunnel.py +++ b/overreact/tunnel.py @@ -9,7 +9,6 @@ import logging -from typing import Optional, Union import numpy as np from scipy.integrate import fixed_quad @@ -49,7 +48,9 @@ def _check_nu(vibfreq: float) -> float: True """ if np.isclose(vibfreq, 0.0).any(): - raise ValueError(f"vibfreq should not be zero for tunneling: {vibfreq}") + raise ValueError( + f"vibfreq should not be zero for tunneling: {vibfreq}" # noqa: EM102 + ) # noqa: RUF100 return np.abs(vibfreq) * constants.c / constants.centi @@ -107,7 +108,7 @@ def eckart( """Calculate the Eckart correction to quantum tunneling. References are - [*J. Phys. Chem.* **1962**, 66, 3, 532–533](https://doi.org/10.1021/j100809a040) + [*J. Phys. Chem.* **1962**, 66, 3, 532-533](https://doi.org/10.1021/j100809a040) and [*J. Res. Natl. Inst. Stand. Technol.*, **1981**, 86, 357](https://doi.org/10.6028/jres.086.014). @@ -163,7 +164,7 @@ def eckart( >>> eckart(190.5927, -154.0231580734253) 1.03525 - """ + """ # noqa: E501 temperature = np.asarray(temperature) nu = _check_nu(vibfreq) @@ -177,7 +178,7 @@ def eckart( if delta_forward <= 0 or delta_backward <= 0: logger.warning( - "forward or backward barrier is non-positive, falling back to Wigner correction" + "forward or backward barrier is non-positive, falling back to Wigner correction" # noqa: E501 ) return wigner(vibfreq, temperature) @@ -257,20 +258,20 @@ def _eckart(u: float, alpha1: float, alpha2: float | None = None) -> float: d = 4.0 * alpha1 * alpha2 - np.pi**2 if d > 0: - D = np.cosh(np.sqrt(d)) + D = np.cosh(np.sqrt(d)) # noqa: N806 else: - D = np.cos(np.sqrt(np.abs(d))) + D = np.cos(np.sqrt(np.abs(d))) # noqa: N806 sqrt_alpha1 = np.sqrt(alpha1) sqrt_alpha2 = np.sqrt(alpha2) - F = ( + F = ( # noqa: N806 np.sqrt(2.0) * sqrt_alpha1 * sqrt_alpha2 / (np.sqrt(np.pi) * (sqrt_alpha1 + sqrt_alpha2)) ) - def f(eps, with_exp=True): + def f(eps, with_exp=True): # noqa: FBT002 """Transmission function multiplied or not by the Boltzmann weight.""" a1 = F * np.sqrt((eps + v1) / u) a2 = F * np.sqrt((eps + v2) / u) diff --git a/poetry.lock b/poetry.lock index 475e16af..9807af7d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -73,6 +73,19 @@ category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" +[[package]] +name = "astroid" +version = "2.12.13" +description = "An abstract syntax tree for Python with inference support." +category = "dev" +optional = false +python-versions = ">=3.7.2" + +[package.dependencies] +lazy-object-proxy = ">=1.4.0" +typing-extensions = {version = ">=3.10", markers = "python_version < \"3.10\""} +wrapt = {version = ">=1.11,<2", markers = "python_version < \"3.11\""} + [[package]] name = "asttokens" version = "2.2.1" @@ -122,25 +135,6 @@ category = "dev" optional = false python-versions = "*" -[[package]] -name = "bandit" -version = "1.7.4" -description = "Security oriented static analyser for python code." -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -colorama = {version = ">=0.3.9", markers = "platform_system == \"Windows\""} -GitPython = ">=1.0.1" -PyYAML = ">=5.3.1" -stevedore = ">=1.20.0" - -[package.extras] -test = ["beautifulsoup4 (>=4.8.0)", "coverage (>=4.5.4)", "fixtures (>=3.0.0)", "flake8 (>=4.0.0)", "pylint (==1.9.4)", "stestr (>=2.5.0)", "testscenarios (>=0.5.0)", "testtools (>=2.3.0)", "toml"] -toml = ["toml"] -yaml = ["PyYAML"] - [[package]] name = "beautifulsoup4" version = "4.11.1" @@ -344,6 +338,17 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +[[package]] +name = "dill" +version = "0.3.6" +description = "serialize all of python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +graph = ["objgraph (>=1.7.2)"] + [[package]] name = "entrypoints" version = "0.4" @@ -385,19 +390,6 @@ python-versions = "*" [package.extras] devel = ["colorama", "json-spec", "jsonschema", "pylint", "pytest", "pytest-benchmark", "pytest-cache", "validictory"] -[[package]] -name = "flake8" -version = "5.0.4" -description = "the modular source code checker: pep8 pyflakes and co" -category = "dev" -optional = false -python-versions = ">=3.6.1" - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.9.0,<2.10.0" -pyflakes = ">=2.5.0,<2.6.0" - [[package]] name = "fluids" version = "1.0.22" @@ -458,28 +450,6 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0, !=3.1, !=3.2, !=3.3, !=3.4, <4" -[[package]] -name = "gitdb" -version = "4.0.10" -description = "Git Object Database" -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -smmap = ">=3.0.1,<6" - -[[package]] -name = "gitpython" -version = "3.1.30" -description = "GitPython is a python library used to interact with Git repositories" -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -gitdb = ">=4.0.1,<5" - [[package]] name = "idna" version = "3.4" @@ -901,6 +871,14 @@ category = "dev" optional = false python-versions = ">=3.7" +[[package]] +name = "lazy-object-proxy" +version = "1.8.0" +description = "A fast and thorough lazy object proxy." +category = "dev" +optional = false +python-versions = ">=3.7" + [[package]] name = "markupsafe" version = "2.1.1" @@ -1218,14 +1196,6 @@ category = "dev" optional = false python-versions = ">=3.7" -[[package]] -name = "pbr" -version = "5.11.0" -description = "Python Build Reasonableness" -category = "dev" -optional = false -python-versions = ">=2.6" - [[package]] name = "pdoc" version = "12.3.0" @@ -1243,6 +1213,17 @@ pygments = ">=2.12.0" [package.extras] dev = ["autoflake", "black", "flake8", "hypothesis", "mypy", "pytest", "pytest-cov", "pytest-timeout", "pyupgrade", "reorder-python-imports", "tox", "yesqa"] +[[package]] +name = "perflint" +version = "0.7.3" +description = "Pylint extension with performance anti-patterns" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +pylint = ">=2.12.0,<3.0" + [[package]] name = "periodictable" version = "1.6.1" @@ -1378,14 +1359,6 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -[[package]] -name = "pycodestyle" -version = "2.9.1" -description = "Python style guide checker" -category = "dev" -optional = false -python-versions = ">=3.6" - [[package]] name = "pycparser" version = "2.21" @@ -1394,14 +1367,6 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -[[package]] -name = "pyflakes" -version = "2.5.0" -description = "passive checker of Python programs" -category = "dev" -optional = false -python-versions = ">=3.6" - [[package]] name = "pygments" version = "2.14.0" @@ -1413,6 +1378,29 @@ python-versions = ">=3.6" [package.extras] plugins = ["importlib-metadata"] +[[package]] +name = "pylint" +version = "2.15.9" +description = "python code static checker" +category = "dev" +optional = false +python-versions = ">=3.7.2" + +[package.dependencies] +astroid = ">=2.12.13,<=2.14.0-dev0" +colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} +dill = {version = ">=0.2", markers = "python_version < \"3.11\""} +isort = ">=4.2.5,<6" +mccabe = ">=0.6,<0.8" +platformdirs = ">=2.2.0" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +tomlkit = ">=0.10.1" +typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""} + +[package.extras] +spelling = ["pyenchant (>=3.2,<4.0)"] +testutils = ["gitpython (>3)"] + [[package]] name = "pyparsing" version = "3.0.9" @@ -1494,17 +1482,6 @@ category = "main" optional = false python-versions = "*" -[[package]] -name = "pyupgrade" -version = "3.3.1" -description = "A tool to automatically upgrade syntax for newer versions." -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -tokenize-rt = ">=3.2.0" - [[package]] name = "pywin32" version = "305" @@ -1612,6 +1589,14 @@ typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9 [package.extras] jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] +[[package]] +name = "ruff" +version = "0.0.210" +description = "An extremely fast Python linter, written in Rust." +category = "dev" +optional = false +python-versions = ">=3.7" + [[package]] name = "scipy" version = "1.10.0" @@ -1698,14 +1683,6 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -[[package]] -name = "smmap" -version = "5.0.0" -description = "A pure Python implementation of a sliding window memory map manager" -category = "dev" -optional = false -python-versions = ">=3.6" - [[package]] name = "sniffio" version = "1.3.0" @@ -1738,17 +1715,6 @@ pure-eval = "*" [package.extras] tests = ["cython", "littleutils", "pygments", "pytest", "typeguard"] -[[package]] -name = "stevedore" -version = "4.1.1" -description = "Manage dynamic plugins for Python applications" -category = "dev" -optional = false -python-versions = ">=3.8" - -[package.dependencies] -pbr = ">=2.0.0,<2.1.0 || >2.1.0" - [[package]] name = "terminado" version = "0.17.1" @@ -1799,20 +1765,20 @@ doc = ["sphinx", "sphinx_rtd_theme"] test = ["flake8", "isort", "pytest"] [[package]] -name = "tokenize-rt" -version = "5.0.0" -description = "A wrapper around the stdlib `tokenize` which roundtrips." +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" category = "dev" optional = false python-versions = ">=3.7" [[package]] -name = "tomli" -version = "2.0.1" -description = "A lil' TOML parser" +name = "tomlkit" +version = "0.11.6" +description = "Style preserving TOML library" category = "dev" optional = false -python-versions = ">=3.7" +python-versions = ">=3.6" [[package]] name = "tornado" @@ -1917,6 +1883,14 @@ category = "dev" optional = false python-versions = ">=3.7" +[[package]] +name = "wrapt" +version = "1.14.1" +description = "Module for decorators, wrappers and monkey patching." +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" + [[package]] name = "zipp" version = "3.11.0" @@ -1937,7 +1911,7 @@ solvents = ["thermo"] [metadata] lock-version = "1.1" python-versions = ">=3.8,<3.11" -content-hash = "e19977f99fa26cf9ec2532b45a0816f15e6fbfae467c31d4955ed0364f7c4f7e" +content-hash = "9723ce887e599f54c5f7b345dee6725742df5bf891ce0058e46b78d423a74205" [metadata.files] anyio = [ @@ -1983,6 +1957,10 @@ astor = [ {file = "astor-0.8.1-py2.py3-none-any.whl", hash = "sha256:070a54e890cefb5b3739d19f30f5a5ec840ffc9c50ffa7d23cc9fc1a38ebbfc5"}, {file = "astor-0.8.1.tar.gz", hash = "sha256:6a6effda93f4e1ce9f618779b2dd1d9d84f1e32812c23a29b3fff6fd7f63fa5e"}, ] +astroid = [ + {file = "astroid-2.12.13-py3-none-any.whl", hash = "sha256:10e0ad5f7b79c435179d0d0f0df69998c4eef4597534aae44910db060baeb907"}, + {file = "astroid-2.12.13.tar.gz", hash = "sha256:1493fe8bd3dfd73dc35bd53c9d5b6e49ead98497c47b2307662556a5692d29d7"}, +] asttokens = [ {file = "asttokens-2.2.1-py2.py3-none-any.whl", hash = "sha256:6b0ac9e93fb0335014d382b8fa9b3afa7df546984258005da0b9e7095b3deb1c"}, {file = "asttokens-2.2.1.tar.gz", hash = "sha256:4622110b2a6f30b77e1473affaa97e711bc2f07d3f10848420ff1898edbe94f3"}, @@ -1999,10 +1977,6 @@ backcall = [ {file = "backcall-0.2.0-py2.py3-none-any.whl", hash = "sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255"}, {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"}, ] -bandit = [ - {file = "bandit-1.7.4-py3-none-any.whl", hash = "sha256:412d3f259dab4077d0e7f0c11f50f650cc7d10db905d98f6520a95a18049658a"}, - {file = "bandit-1.7.4.tar.gz", hash = "sha256:2d63a8c573417bae338962d4b9b06fbc6080f74ecd955a092849e1e65c717bd2"}, -] beautifulsoup4 = [ {file = "beautifulsoup4-4.11.1-py3-none-any.whl", hash = "sha256:58d5c3d29f5a36ffeb94f02f0d786cd53014cf9b3b3951d42e0080d8a9498d30"}, {file = "beautifulsoup4-4.11.1.tar.gz", hash = "sha256:ad9aa55b65ef2808eb405f46cf74df7fcb7044d5cbc26487f96eb2ef2e436693"}, @@ -2269,6 +2243,10 @@ defusedxml = [ {file = "defusedxml-0.7.1-py2.py3-none-any.whl", hash = "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61"}, {file = "defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69"}, ] +dill = [ + {file = "dill-0.3.6-py3-none-any.whl", hash = "sha256:a07ffd2351b8c678dfc4a856a3005f8067aea51d6ba6c700796a4d9e280f39f0"}, + {file = "dill-0.3.6.tar.gz", hash = "sha256:e5db55f3687856d8fbdab002ed78544e1c4559a130302693d839dfe8f93f2373"}, +] entrypoints = [ {file = "entrypoints-0.4-py3-none-any.whl", hash = "sha256:f174b5ff827504fd3cd97cc3f8649f3693f51538c7e4bdf3ef002c8429d42f9f"}, {file = "entrypoints-0.4.tar.gz", hash = "sha256:b706eddaa9218a19ebcd67b56818f05bb27589b1ca9e8d797b74affad4ccacd4"}, @@ -2285,10 +2263,6 @@ fastjsonschema = [ {file = "fastjsonschema-2.16.2-py3-none-any.whl", hash = "sha256:21f918e8d9a1a4ba9c22e09574ba72267a6762d47822db9add95f6454e51cc1c"}, {file = "fastjsonschema-2.16.2.tar.gz", hash = "sha256:01e366f25d9047816fe3d288cbfc3e10541daf0af2044763f3d0ade42476da18"}, ] -flake8 = [ - {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"}, - {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"}, -] fluids = [ {file = "fluids-1.0.22-py3-none-any.whl", hash = "sha256:3fd993843518589c2c8452666b893b5fb2412b662fb8d9c88e00c3aee89eb30a"}, ] @@ -2304,14 +2278,6 @@ fqdn = [ {file = "fqdn-1.5.1-py3-none-any.whl", hash = "sha256:3a179af3761e4df6eb2e026ff9e1a3033d3587bf980a0b1b2e1e5d08d7358014"}, {file = "fqdn-1.5.1.tar.gz", hash = "sha256:105ed3677e767fb5ca086a0c1f4bb66ebc3c100be518f0e0d755d9eae164d89f"}, ] -gitdb = [ - {file = "gitdb-4.0.10-py3-none-any.whl", hash = "sha256:c286cf298426064079ed96a9e4a9d39e7f3e9bf15ba60701e95f5492f28415c7"}, - {file = "gitdb-4.0.10.tar.gz", hash = "sha256:6eb990b69df4e15bad899ea868dc46572c3f75339735663b81de79b06f17eb9a"}, -] -gitpython = [ - {file = "GitPython-3.1.30-py3-none-any.whl", hash = "sha256:cd455b0000615c60e286208ba540271af9fe531fa6a87cc590a7298785ab2882"}, - {file = "GitPython-3.1.30.tar.gz", hash = "sha256:769c2d83e13f5d938b7688479da374c4e3d49f71549aaf462b646db9602ea6f8"}, -] idna = [ {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, @@ -2492,6 +2458,27 @@ kiwisolver = [ {file = "kiwisolver-1.4.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:36dafec3d6d6088d34e2de6b85f9d8e2324eb734162fba59d2ba9ed7a2043d5b"}, {file = "kiwisolver-1.4.4.tar.gz", hash = "sha256:d41997519fcba4a1e46eb4a2fe31bc12f0ff957b2b81bac28db24744f333e955"}, ] +lazy-object-proxy = [ + {file = "lazy-object-proxy-1.8.0.tar.gz", hash = "sha256:c219a00245af0f6fa4e95901ed28044544f50152840c5b6a3e7b2568db34d156"}, + {file = "lazy_object_proxy-1.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4fd031589121ad46e293629b39604031d354043bb5cdf83da4e93c2d7f3389fe"}, + {file = "lazy_object_proxy-1.8.0-cp310-cp310-win32.whl", hash = "sha256:b70d6e7a332eb0217e7872a73926ad4fdc14f846e85ad6749ad111084e76df25"}, + {file = "lazy_object_proxy-1.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:eb329f8d8145379bf5dbe722182410fe8863d186e51bf034d2075eb8d85ee25b"}, + {file = "lazy_object_proxy-1.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4e2d9f764f1befd8bdc97673261b8bb888764dfdbd7a4d8f55e4fbcabb8c3fb7"}, + {file = "lazy_object_proxy-1.8.0-cp311-cp311-win32.whl", hash = "sha256:e20bfa6db17a39c706d24f82df8352488d2943a3b7ce7d4c22579cb89ca8896e"}, + {file = "lazy_object_proxy-1.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:14010b49a2f56ec4943b6cf925f597b534ee2fe1f0738c84b3bce0c1a11ff10d"}, + {file = "lazy_object_proxy-1.8.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:6850e4aeca6d0df35bb06e05c8b934ff7c533734eb51d0ceb2d63696f1e6030c"}, + {file = "lazy_object_proxy-1.8.0-cp37-cp37m-win32.whl", hash = "sha256:5b51d6f3bfeb289dfd4e95de2ecd464cd51982fe6f00e2be1d0bf94864d58acd"}, + {file = "lazy_object_proxy-1.8.0-cp37-cp37m-win_amd64.whl", hash = "sha256:6f593f26c470a379cf7f5bc6db6b5f1722353e7bf937b8d0d0b3fba911998858"}, + {file = "lazy_object_proxy-1.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0c1c7c0433154bb7c54185714c6929acc0ba04ee1b167314a779b9025517eada"}, + {file = "lazy_object_proxy-1.8.0-cp38-cp38-win32.whl", hash = "sha256:d176f392dbbdaacccf15919c77f526edf11a34aece58b55ab58539807b85436f"}, + {file = "lazy_object_proxy-1.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:afcaa24e48bb23b3be31e329deb3f1858f1f1df86aea3d70cb5c8578bfe5261c"}, + {file = "lazy_object_proxy-1.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:71d9ae8a82203511a6f60ca5a1b9f8ad201cac0fc75038b2dc5fa519589c9288"}, + {file = "lazy_object_proxy-1.8.0-cp39-cp39-win32.whl", hash = "sha256:8f6ce2118a90efa7f62dd38c7dbfffd42f468b180287b748626293bf12ed468f"}, + {file = "lazy_object_proxy-1.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:eac3a9a5ef13b332c059772fd40b4b1c3d45a3a2b05e33a361dee48e54a4dad0"}, + {file = "lazy_object_proxy-1.8.0-pp37-pypy37_pp73-any.whl", hash = "sha256:ae032743794fba4d171b5b67310d69176287b5bf82a21f588282406a79498891"}, + {file = "lazy_object_proxy-1.8.0-pp38-pypy38_pp73-any.whl", hash = "sha256:7e1561626c49cb394268edd00501b289053a652ed762c58e1081224c8d881cec"}, + {file = "lazy_object_proxy-1.8.0-pp39-pypy39_pp73-any.whl", hash = "sha256:ce58b2b3734c73e68f0e30e4e725264d4d6be95818ec0a0be4bb6bf9a7e79aa8"}, +] markupsafe = [ {file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812"}, {file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a"}, @@ -2732,14 +2719,14 @@ pathspec = [ {file = "pathspec-0.10.3-py3-none-any.whl", hash = "sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6"}, {file = "pathspec-0.10.3.tar.gz", hash = "sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6"}, ] -pbr = [ - {file = "pbr-5.11.0-py2.py3-none-any.whl", hash = "sha256:db2317ff07c84c4c63648c9064a79fe9d9f5c7ce85a9099d4b6258b3db83225a"}, - {file = "pbr-5.11.0.tar.gz", hash = "sha256:b97bc6695b2aff02144133c2e7399d5885223d42b7912ffaec2ca3898e673bfe"}, -] pdoc = [ {file = "pdoc-12.3.0-py3-none-any.whl", hash = "sha256:0c520a6af892863b8712abb6abaad2c928366d7dee727715177774623c30405d"}, {file = "pdoc-12.3.0.tar.gz", hash = "sha256:b245903dd8fb515b99d838bb1ad3efeb706fa0efd925a886c4624bf946afaab5"}, ] +perflint = [ + {file = "perflint-0.7.3-py2.py3-none-any.whl", hash = "sha256:e556a82495925ec956ce607b6333564a54a6ebe2146fd47753d4b32aab82c85b"}, + {file = "perflint-0.7.3.tar.gz", hash = "sha256:8569248d246c21974201b950af1330218ad058db285e2316cbb0044997d47554"}, +] periodictable = [ {file = "periodictable-1.6.1-py2.py3-none-any.whl", hash = "sha256:5b02d7171e6a8bcb7060b086c6150ac4152a36b70edcd34e5549981d84d31eed"}, {file = "periodictable-1.6.1.tar.gz", hash = "sha256:7c501c9f73d77b1fb28cb51e85b28429c2c44a99ce3d1274894564c72d712603"}, @@ -2865,22 +2852,18 @@ py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] -pycodestyle = [ - {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"}, - {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"}, -] pycparser = [ {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, ] -pyflakes = [ - {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"}, - {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, -] pygments = [ {file = "Pygments-2.14.0-py3-none-any.whl", hash = "sha256:fa7bd7bd2771287c0de303af8bfdfc731f51bd2c6a47ab69d117138893b82717"}, {file = "Pygments-2.14.0.tar.gz", hash = "sha256:b3ed06a9e8ac9a9aae5a6f5dbe78a8a58655d17b43b93c078f094ddc476ae297"}, ] +pylint = [ + {file = "pylint-2.15.9-py3-none-any.whl", hash = "sha256:349c8cd36aede4d50a0754a8c0218b43323d13d5d88f4b2952ddfe3e169681eb"}, + {file = "pylint-2.15.9.tar.gz", hash = "sha256:18783cca3cfee5b83c6c5d10b3cdb66c6594520ffae61890858fe8d932e1c6b4"}, +] pyparsing = [ {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, @@ -2934,10 +2917,6 @@ pytz = [ {file = "pytz-2022.7-py2.py3-none-any.whl", hash = "sha256:93007def75ae22f7cd991c84e02d434876818661f8df9ad5df9e950ff4e52cfd"}, {file = "pytz-2022.7.tar.gz", hash = "sha256:7ccfae7b4b2c067464a6733c6261673fdb8fd1be905460396b97a073e9fa683a"}, ] -pyupgrade = [ - {file = "pyupgrade-3.3.1-py2.py3-none-any.whl", hash = "sha256:3b93641963df022d605c78aeae4b5956a5296ea24701eafaef9c487527b77e60"}, - {file = "pyupgrade-3.3.1.tar.gz", hash = "sha256:f88bce38b0ba92c2a9a5063c8629e456e8d919b67d2d42c7ecab82ff196f9813"}, -] pywin32 = [ {file = "pywin32-305-cp310-cp310-win32.whl", hash = "sha256:421f6cd86e84bbb696d54563c48014b12a23ef95a14e0bdba526be756d89f116"}, {file = "pywin32-305-cp310-cp310-win_amd64.whl", hash = "sha256:73e819c6bed89f44ff1d690498c0a811948f73777e5f97c494c152b850fad478"}, @@ -3100,6 +3079,24 @@ rich = [ {file = "rich-13.0.0-py3-none-any.whl", hash = "sha256:12b1d77ee7edf251b741531323f0d990f5f570a4e7c054d0bfb59fb7981ad977"}, {file = "rich-13.0.0.tar.gz", hash = "sha256:3aa9eba7219b8c575c6494446a59f702552efe1aa261e7eeb95548fa586e1950"}, ] +ruff = [ + {file = "ruff-0.0.210-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:00c6af7a51f67bc58de0928fe0dc77f3f62a9297ebca4dd514c3abffda3cdfac"}, + {file = "ruff-0.0.210-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:f8243c011ced5e54b894dd8d1c1b67ff2fc022f190d20c45c7bf3e9a36d0edfe"}, + {file = "ruff-0.0.210-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2bc5eecd1101a2a7f7d783fafb02d6bdb0fd054ac9bf8029d5c6cee3cb3d00ef"}, + {file = "ruff-0.0.210-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:163b296253d4d093f04e0fa6e32d721baebeb855d8d91679fde108d60ba85b88"}, + {file = "ruff-0.0.210-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c1d578415e86282d80f2c19bd2b4945b8fdc9aae313622f3e4bde370d0b46ca7"}, + {file = "ruff-0.0.210-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:7644459a0550e68340e4988c8458ea5f8365c6c0a1437af02dd05e5606ca2d86"}, + {file = "ruff-0.0.210-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c3ebaac25dfc24becaa3046b168685ec8b3ba9dbe7dde232511ff6d6b9f18bd"}, + {file = "ruff-0.0.210-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1b5dbad011c31e3472d771c3dae628efa9dd987304b771334534351d7256db86"}, + {file = "ruff-0.0.210-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:928ff0eb7e5026d8c7b2bbf099961e78584602955153c1c544f2c4ebaad43499"}, + {file = "ruff-0.0.210-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:83c173fa584ae9252c2fa244e1509dac04cb0dd688d3c31ce7494e70864c469f"}, + {file = "ruff-0.0.210-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:13e032eaf4964e1ac5dd9b9d05a30cb330067256e8a89638ad6d41ddfea528fb"}, + {file = "ruff-0.0.210-py3-none-musllinux_1_2_i686.whl", hash = "sha256:37cc5f47655ab9d389146bed59c3c7ea6481e1db945a0eb06a582f23ea51b6b1"}, + {file = "ruff-0.0.210-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:51198b81d702ef0d4d880d454b183c7372be76f5d5e08abf9b15bd54f971bc53"}, + {file = "ruff-0.0.210-py3-none-win32.whl", hash = "sha256:e4dc8472cb73cdb1cc06814ffd964e187d2679f055eefc286fde080f5297dc9b"}, + {file = "ruff-0.0.210-py3-none-win_amd64.whl", hash = "sha256:26021f8a51d314342db40bcf5995233187d54ae205b7e8429b1601f6dde220fc"}, + {file = "ruff-0.0.210.tar.gz", hash = "sha256:7b9ba7294d79e768bbd463da5ebb87026353f08841654ec458aa033decfc86ff"}, +] scipy = [ {file = "scipy-1.10.0-cp310-cp310-macosx_10_15_x86_64.whl", hash = "sha256:b901b423c91281a974f6cd1c36f5c6c523e665b5a6d5e80fcb2334e14670eefd"}, {file = "scipy-1.10.0-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:16ba05d3d1b9f2141004f3f36888e05894a525960b07f4c2bfc0456b955a00be"}, @@ -3143,10 +3140,6 @@ six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] -smmap = [ - {file = "smmap-5.0.0-py3-none-any.whl", hash = "sha256:2aba19d6a040e78d8b09de5c57e96207b09ed71d8e55ce0959eeee6c8e190d94"}, - {file = "smmap-5.0.0.tar.gz", hash = "sha256:c840e62059cd3be204b0c9c9f74be2c09d5648eddd4580d9314c3ecde0b30936"}, -] sniffio = [ {file = "sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"}, {file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, @@ -3159,10 +3152,6 @@ stack-data = [ {file = "stack_data-0.6.2-py3-none-any.whl", hash = "sha256:cbb2a53eb64e5785878201a97ed7c7b94883f48b87bfb0bbe8b623c74679e4a8"}, {file = "stack_data-0.6.2.tar.gz", hash = "sha256:32d2dd0376772d01b6cb9fc996f3c8b57a357089dec328ed4b6553d037eaf815"}, ] -stevedore = [ - {file = "stevedore-4.1.1-py3-none-any.whl", hash = "sha256:aa6436565c069b2946fe4ebff07f5041e0c8bf18c7376dd29edf80cf7d524e4e"}, - {file = "stevedore-4.1.1.tar.gz", hash = "sha256:7f8aeb6e3f90f96832c301bff21a7eb5eefbe894c88c506483d355565d88cc1a"}, -] terminado = [ {file = "terminado-0.17.1-py3-none-any.whl", hash = "sha256:8650d44334eba354dd591129ca3124a6ba42c3d5b70df5051b6921d506fdaeae"}, {file = "terminado-0.17.1.tar.gz", hash = "sha256:6ccbbcd3a4f8a25a5ec04991f39a0b8db52dfcd487ea0e578d977e6752380333"}, @@ -3174,14 +3163,14 @@ tinycss2 = [ {file = "tinycss2-1.2.1-py3-none-any.whl", hash = "sha256:2b80a96d41e7c3914b8cda8bc7f705a4d9c49275616e886103dd839dfc847847"}, {file = "tinycss2-1.2.1.tar.gz", hash = "sha256:8cff3a8f066c2ec677c06dbc7b45619804a6938478d9d73c284b29d14ecb0627"}, ] -tokenize-rt = [ - {file = "tokenize_rt-5.0.0-py2.py3-none-any.whl", hash = "sha256:c67772c662c6b3dc65edf66808577968fb10badfc2042e3027196bed4daf9e5a"}, - {file = "tokenize_rt-5.0.0.tar.gz", hash = "sha256:3160bc0c3e8491312d0485171dea861fc160a240f5f5766b72a1165408d10740"}, -] tomli = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] +tomlkit = [ + {file = "tomlkit-0.11.6-py3-none-any.whl", hash = "sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b"}, + {file = "tomlkit-0.11.6.tar.gz", hash = "sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73"}, +] tornado = [ {file = "tornado-6.2-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:20f638fd8cc85f3cbae3c732326e96addff0a15e22d80f049e00121651e82e72"}, {file = "tornado-6.2-cp37-abi3-macosx_10_9_x86_64.whl", hash = "sha256:87dcafae3e884462f90c90ecc200defe5e580a7fbbb4365eda7c7c1eb809ebc9"}, @@ -3235,6 +3224,72 @@ widgetsnbextension = [ {file = "widgetsnbextension-4.0.5-py3-none-any.whl", hash = "sha256:eaaaf434fb9b08bd197b2a14ffe45ddb5ac3897593d43c69287091e5f3147bf7"}, {file = "widgetsnbextension-4.0.5.tar.gz", hash = "sha256:003f716d930d385be3fd9de42dd9bf008e30053f73bddde235d14fbeaeff19af"}, ] +wrapt = [ + {file = "wrapt-1.14.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:1b376b3f4896e7930f1f772ac4b064ac12598d1c38d04907e696cc4d794b43d3"}, + {file = "wrapt-1.14.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:903500616422a40a98a5a3c4ff4ed9d0066f3b4c951fa286018ecdf0750194ef"}, + {file = "wrapt-1.14.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:5a9a0d155deafd9448baff28c08e150d9b24ff010e899311ddd63c45c2445e28"}, + {file = "wrapt-1.14.1-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:ddaea91abf8b0d13443f6dac52e89051a5063c7d014710dcb4d4abb2ff811a59"}, + {file = "wrapt-1.14.1-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:36f582d0c6bc99d5f39cd3ac2a9062e57f3cf606ade29a0a0d6b323462f4dd87"}, + {file = "wrapt-1.14.1-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:7ef58fb89674095bfc57c4069e95d7a31cfdc0939e2a579882ac7d55aadfd2a1"}, + {file = "wrapt-1.14.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:e2f83e18fe2f4c9e7db597e988f72712c0c3676d337d8b101f6758107c42425b"}, + {file = "wrapt-1.14.1-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:ee2b1b1769f6707a8a445162ea16dddf74285c3964f605877a20e38545c3c462"}, + {file = "wrapt-1.14.1-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:833b58d5d0b7e5b9832869f039203389ac7cbf01765639c7309fd50ef619e0b1"}, + {file = "wrapt-1.14.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:80bb5c256f1415f747011dc3604b59bc1f91c6e7150bd7db03b19170ee06b320"}, + {file = "wrapt-1.14.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:07f7a7d0f388028b2df1d916e94bbb40624c59b48ecc6cbc232546706fac74c2"}, + {file = "wrapt-1.14.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:02b41b633c6261feff8ddd8d11c711df6842aba629fdd3da10249a53211a72c4"}, + {file = "wrapt-1.14.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2fe803deacd09a233e4762a1adcea5db5d31e6be577a43352936179d14d90069"}, + {file = "wrapt-1.14.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:257fd78c513e0fb5cdbe058c27a0624c9884e735bbd131935fd49e9fe719d310"}, + {file = "wrapt-1.14.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4fcc4649dc762cddacd193e6b55bc02edca674067f5f98166d7713b193932b7f"}, + {file = "wrapt-1.14.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:11871514607b15cfeb87c547a49bca19fde402f32e2b1c24a632506c0a756656"}, + {file = "wrapt-1.14.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8ad85f7f4e20964db4daadcab70b47ab05c7c1cf2a7c1e51087bfaa83831854c"}, + {file = "wrapt-1.14.1-cp310-cp310-win32.whl", hash = "sha256:a9a52172be0b5aae932bef82a79ec0a0ce87288c7d132946d645eba03f0ad8a8"}, + {file = "wrapt-1.14.1-cp310-cp310-win_amd64.whl", hash = "sha256:6d323e1554b3d22cfc03cd3243b5bb815a51f5249fdcbb86fda4bf62bab9e164"}, + {file = "wrapt-1.14.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:43ca3bbbe97af00f49efb06e352eae40434ca9d915906f77def219b88e85d907"}, + {file = "wrapt-1.14.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:6b1a564e6cb69922c7fe3a678b9f9a3c54e72b469875aa8018f18b4d1dd1adf3"}, + {file = "wrapt-1.14.1-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3"}, + {file = "wrapt-1.14.1-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:a85d2b46be66a71bedde836d9e41859879cc54a2a04fad1191eb50c2066f6e9d"}, + {file = "wrapt-1.14.1-cp35-cp35m-win32.whl", hash = "sha256:dbcda74c67263139358f4d188ae5faae95c30929281bc6866d00573783c422b7"}, + {file = "wrapt-1.14.1-cp35-cp35m-win_amd64.whl", hash = "sha256:b21bb4c09ffabfa0e85e3a6b623e19b80e7acd709b9f91452b8297ace2a8ab00"}, + {file = "wrapt-1.14.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:9e0fd32e0148dd5dea6af5fee42beb949098564cc23211a88d799e434255a1f4"}, + {file = "wrapt-1.14.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9736af4641846491aedb3c3f56b9bc5568d92b0692303b5a305301a95dfd38b1"}, + {file = "wrapt-1.14.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5b02d65b9ccf0ef6c34cba6cf5bf2aab1bb2f49c6090bafeecc9cd81ad4ea1c1"}, + {file = "wrapt-1.14.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21ac0156c4b089b330b7666db40feee30a5d52634cc4560e1905d6529a3897ff"}, + {file = "wrapt-1.14.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:9f3e6f9e05148ff90002b884fbc2a86bd303ae847e472f44ecc06c2cd2fcdb2d"}, + {file = "wrapt-1.14.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:6e743de5e9c3d1b7185870f480587b75b1cb604832e380d64f9504a0535912d1"}, + {file = "wrapt-1.14.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:d79d7d5dc8a32b7093e81e97dad755127ff77bcc899e845f41bf71747af0c569"}, + {file = "wrapt-1.14.1-cp36-cp36m-win32.whl", hash = "sha256:81b19725065dcb43df02b37e03278c011a09e49757287dca60c5aecdd5a0b8ed"}, + {file = "wrapt-1.14.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b014c23646a467558be7da3d6b9fa409b2c567d2110599b7cf9a0c5992b3b471"}, + {file = "wrapt-1.14.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:88bd7b6bd70a5b6803c1abf6bca012f7ed963e58c68d76ee20b9d751c74a3248"}, + {file = "wrapt-1.14.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b5901a312f4d14c59918c221323068fad0540e34324925c8475263841dbdfe68"}, + {file = "wrapt-1.14.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d77c85fedff92cf788face9bfa3ebaa364448ebb1d765302e9af11bf449ca36d"}, + {file = "wrapt-1.14.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d649d616e5c6a678b26d15ece345354f7c2286acd6db868e65fcc5ff7c24a77"}, + {file = "wrapt-1.14.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:7d2872609603cb35ca513d7404a94d6d608fc13211563571117046c9d2bcc3d7"}, + {file = "wrapt-1.14.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015"}, + {file = "wrapt-1.14.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:2b39d38039a1fdad98c87279b48bc5dce2c0ca0d73483b12cb72aa9609278e8a"}, + {file = "wrapt-1.14.1-cp37-cp37m-win32.whl", hash = "sha256:60db23fa423575eeb65ea430cee741acb7c26a1365d103f7b0f6ec412b893853"}, + {file = "wrapt-1.14.1-cp37-cp37m-win_amd64.whl", hash = "sha256:709fe01086a55cf79d20f741f39325018f4df051ef39fe921b1ebe780a66184c"}, + {file = "wrapt-1.14.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8c0ce1e99116d5ab21355d8ebe53d9460366704ea38ae4d9f6933188f327b456"}, + {file = "wrapt-1.14.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e3fb1677c720409d5f671e39bac6c9e0e422584e5f518bfd50aa4cbbea02433f"}, + {file = "wrapt-1.14.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:642c2e7a804fcf18c222e1060df25fc210b9c58db7c91416fb055897fc27e8cc"}, + {file = "wrapt-1.14.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7b7c050ae976e286906dd3f26009e117eb000fb2cf3533398c5ad9ccc86867b1"}, + {file = "wrapt-1.14.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af"}, + {file = "wrapt-1.14.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:01c205616a89d09827986bc4e859bcabd64f5a0662a7fe95e0d359424e0e071b"}, + {file = "wrapt-1.14.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:5a0f54ce2c092aaf439813735584b9537cad479575a09892b8352fea5e988dc0"}, + {file = "wrapt-1.14.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:2cf71233a0ed05ccdabe209c606fe0bac7379fdcf687f39b944420d2a09fdb57"}, + {file = "wrapt-1.14.1-cp38-cp38-win32.whl", hash = "sha256:aa31fdcc33fef9eb2552cbcbfee7773d5a6792c137b359e82879c101e98584c5"}, + {file = "wrapt-1.14.1-cp38-cp38-win_amd64.whl", hash = "sha256:d1967f46ea8f2db647c786e78d8cc7e4313dbd1b0aca360592d8027b8508e24d"}, + {file = "wrapt-1.14.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3232822c7d98d23895ccc443bbdf57c7412c5a65996c30442ebe6ed3df335383"}, + {file = "wrapt-1.14.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:988635d122aaf2bdcef9e795435662bcd65b02f4f4c1ae37fbee7401c440b3a7"}, + {file = "wrapt-1.14.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9cca3c2cdadb362116235fdbd411735de4328c61425b0aa9f872fd76d02c4e86"}, + {file = "wrapt-1.14.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d52a25136894c63de15a35bc0bdc5adb4b0e173b9c0d07a2be9d3ca64a332735"}, + {file = "wrapt-1.14.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40e7bc81c9e2b2734ea4bc1aceb8a8f0ceaac7c5299bc5d69e37c44d9081d43b"}, + {file = "wrapt-1.14.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b9b7a708dd92306328117d8c4b62e2194d00c365f18eff11a9b53c6f923b01e3"}, + {file = "wrapt-1.14.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:6a9a25751acb379b466ff6be78a315e2b439d4c94c1e99cb7266d40a537995d3"}, + {file = "wrapt-1.14.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:34aa51c45f28ba7f12accd624225e2b1e5a3a45206aa191f6f9aac931d9d56fe"}, + {file = "wrapt-1.14.1-cp39-cp39-win32.whl", hash = "sha256:dee0ce50c6a2dd9056c20db781e9c1cfd33e77d2d569f5d1d9321c641bb903d5"}, + {file = "wrapt-1.14.1-cp39-cp39-win_amd64.whl", hash = "sha256:dee60e1de1898bde3b238f18340eec6148986da0455d8ba7848d50470a7a32fb"}, + {file = "wrapt-1.14.1.tar.gz", hash = "sha256:380a85cf89e0e69b7cfbe2ea9f765f004ff419f34194018a6827ac0e3edfed4d"}, +] zipp = [ {file = "zipp-3.11.0-py3-none-any.whl", hash = "sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa"}, {file = "zipp-3.11.0.tar.gz", hash = "sha256:a7a22e05929290a67401440b39690ae6563279bced5f314609d9d03798f56766"}, diff --git a/pyproject.toml b/pyproject.toml index 8f67c0d2..e86b8328 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,30 +59,41 @@ jax = { version = "^0.4", optional = true } jaxlib = { version = "^0.4", optional = true } rich = { version = "^13", optional = true } thermo = { version = "^0.2", optional = true } +# I NEED MATPLOTLIB [tool.poetry.extras] cli = ["rich"] fast = ["jax", "jaxlib"] solvents = ["thermo"] -[tool.poetry.dev-dependencies] -bandit = "^1" +[tool.poetry.group.dev.dependencies] black = { version = "^22", allow-prereleases = true } debugpy = "^1" -flake8 = "^5" flynt = "^0.77" ipython = "^8" -isort = "^5" jupyter = "^1.0.0" matplotlib = "^3" mypy = "^0.991" pdoc = "^12" +perflint = "^0.7.1" pytest = "^7.2.0" pytest-cov = "^4" -pyupgrade = "^3.3.1" +ruff = "^0.0.210" seaborn = "^0.12" types-setuptools = "^65" [build-system] build-backend = "poetry.core.masonry.api" requires = ["poetry-core>=1.0.0"] + +[tool.ruff] +select = ["ALL"] +ignore = [ + "ANN001", # MissingTypeFunctionArgument + "ANN201", # MissingReturnTypePublicFunction + "ANN202", # MissingReturnTypePrivateFunction + "S101", # AssertUsed +] + +[tool.ruff.pydocstyle] +convention = "numpy" diff --git a/tests/test_api.py b/tests/test_api.py index 8fb92248..2048a9ba 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -10,7 +10,7 @@ from overreact import coords -def test_get_enthalpies(): +def test_get_enthalpies(): # noqa: D103 model = rx.parse_model("data/hickel1992/UM06-2X/6-311++G(d,p)/model.k") assert rx.get_delta( model.scheme.B, rx.get_enthalpies(model.compounds, qrrho=False) @@ -23,7 +23,8 @@ def test_get_entropies(): """Ensure get_entropies match some logfiles. It is worth mentioning that, currently, ORCA uses QRRHO in entropy - calculations, but not for enthalpies.""" + calculations, but not for enthalpies. + """ model = rx.parse_model("data/ethane/B97-3c/model.k") assert 298.15 * rx.get_delta( model.scheme.B, rx.get_entropies(model.compounds, environment="gas") @@ -52,7 +53,7 @@ def test_get_entropies(): ) -def test_get_freeenergies(): +def test_get_freeenergies(): # noqa: D103 model = rx.parse_model("data/hickel1992/UM06-2X/6-311++G(d,p)/model.k") sym_correction = 298.15 * rx.change_reference_state(3, 1) diff --git a/tests/test_coords.py b/tests/test_coords.py index a6f94234..cd5ee079 100644 --- a/tests/test_coords.py +++ b/tests/test_coords.py @@ -10,7 +10,7 @@ # TODO(schneiderfelipe): add one extra atom -def test_can_understand_K_symmetry(): +def test_can_understand_K_symmetry(): # noqa: N802 """Ensure values match regression logfiles for K symmetry.""" data = datasets.logfiles["tanaka1996"]["ClΒ·@UMP2/6-311G(2df,2pd)"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -38,7 +38,7 @@ def test_can_understand_K_symmetry(): assert coords.symmetry_number(point_group) == 1 -def test_can_understand_C1_symmetry(): +def test_can_understand_C1_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C1 symmetry.""" data = datasets.logfiles["symmetries"]["chlorobromofluoromethane"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -70,7 +70,7 @@ def test_can_understand_C1_symmetry(): assert coords.symmetry_number(point_group) == 1 -def test_can_understand_Cs_symmetry(): +def test_can_understand_Cs_symmetry(): # noqa: N802 """Ensure values match regression logfiles for Cs symmetry.""" data = datasets.logfiles["symmetries"]["NHF2"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -105,7 +105,6 @@ def test_can_understand_Cs_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([17.61945078, 253.37069181, 267.61052366]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 4 assert len(groups[0]) == 1 @@ -125,7 +124,6 @@ def test_can_understand_Cs_symmetry(): ) assert len(mirror_axes) == 1 assert mirror_axes[0][0] == "" - # assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Cs" @@ -162,15 +160,12 @@ def test_can_understand_Cs_symmetry(): assert coords.symmetry_number(point_group) == 1 -def test_can_understand_Ci_symmetry(): +def test_can_understand_Ci_symmetry(): # noqa: N802 """Ensure values match regression logfiles for Ci symmetry.""" data = datasets.logfiles["symmetries"]["1,2-dichloro-1,2-difluoroethane"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([130.04075032, 358.98131538, 473.66138286]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array([[1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [0.0, 0.0, -1.0]]) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 4 assert len(groups[0]) == 2 @@ -227,7 +222,7 @@ def test_can_understand_Ci_symmetry(): assert coords.symmetry_number(point_group) == 1 -def test_can_understand_Cinfv_symmetry(): +def test_can_understand_Cinfv_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C∞v symmetry.""" data = datasets.logfiles["tanaka1996"]["HCl@UMP2/6-311G(2df,2pd)"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -259,11 +254,6 @@ def test_can_understand_Cinfv_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([1.17654558e-8, 8.53818341e1, 8.53818341e1]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [[1.0, 0.0, 0.0], [0.0, -1.0, -8.61130797e-7], [0.0, 8.61130797e-7, -1.0]] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 1 @@ -287,21 +277,12 @@ def test_can_understand_Cinfv_symmetry(): assert coords.symmetry_number(point_group) == 1 -def test_can_understand_Dinfh_symmetry(): +def test_can_understand_Dinfh_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D∞h symmetry.""" data = datasets.logfiles["symmetries"]["dihydrogen"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([0.0, 2.96199592e-1, 2.96199592e-1]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [ - # [-1.0, 0.0, 0.0], - # [0.0, -9.85287297e-1, 1.70906240e-1], - # [0.0, 1.70906240e-1, 9.85287297e-1], - # ] - # ) - # ) assert atomcoords == pytest.approx( np.array([[3.83307188e-1, 0.0, 0.0], [-3.83307188e-1, 0.0, 0.0]]) ) @@ -313,7 +294,6 @@ def test_can_understand_Dinfh_symmetry(): proper_axes = coords._get_proper_axes(atomcoords, groups, axes, rotor_class) assert len(proper_axes) == 1 assert proper_axes[0][0] == 2 - # assert proper_axes[0][1] == pytest.approx([-1.0, 0.0, 0.0]) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -325,7 +305,6 @@ def test_can_understand_Dinfh_symmetry(): ) assert len(mirror_axes) == 1 assert mirror_axes[0][0] == "h" - # assert mirror_axes[0][1] == pytest.approx([-1.0, 0.0, 0.0]) assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D∞h" @@ -335,11 +314,6 @@ def test_can_understand_Dinfh_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([8.94742236e-8, 4.44644189e1, 4.44644190e1]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [[1.0, 0.0, 0.0], [0.0, -1.0, 2.45551350e-7], [0.0, -2.45551349e-7, -1.0]] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 2 assert len(groups[0]) == 1 @@ -368,13 +342,12 @@ def test_can_understand_Dinfh_symmetry(): assert coords.symmetry_number(point_group) == 2 -def test_can_understand_C2_symmetry(): +def test_can_understand_C2_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C2 symmetry.""" data = datasets.logfiles["symmetries"]["hydrogen-peroxide"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([1.74210646, 19.61466369, 20.420849]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 2 assert len(groups[0]) == 2 @@ -384,7 +357,6 @@ def test_can_understand_C2_symmetry(): proper_axes = coords._get_proper_axes(atomcoords, groups, axes, rotor_class) assert len(proper_axes) == 1 assert proper_axes[0][0] == 2 - # assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -402,7 +374,6 @@ def test_can_understand_C2_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([3.48031691, 20.67234093, 20.67777505]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 2 @@ -430,15 +401,12 @@ def test_can_understand_C2_symmetry(): assert coords.symmetry_number(point_group) == 2 -def test_can_understand_C3_symmetry(): +def test_can_understand_C3_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C3 symmetry.""" data = datasets.logfiles["symmetries"]["H3PO4"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([117.15458225, 119.69622329, 119.71729381]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array([[1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [0.0, 0.0, -1.0]]) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 4 assert len(groups[0]) == 1 @@ -511,13 +479,12 @@ def test_can_understand_C3_symmetry(): assert coords.symmetry_number(point_group) == 3 -def test_can_understand_C2h_symmetry(): +def test_can_understand_C2h_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C2h symmetry.""" data = datasets.logfiles["symmetries"]["trans-1,2-dichloroethylene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([9.8190931, 342.02181465, 351.84090775]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 2 @@ -528,7 +495,6 @@ def test_can_understand_C2h_symmetry(): proper_axes = coords._get_proper_axes(atomcoords, groups, axes, rotor_class) assert len(proper_axes) == 1 assert proper_axes[0][0] == 2 - # assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -540,7 +506,6 @@ def test_can_understand_C2h_symmetry(): ) assert len(mirror_axes) == 1 assert mirror_axes[0][0] == "h" - # assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2h" @@ -586,7 +551,7 @@ def test_can_understand_C2h_symmetry(): assert coords.symmetry_number(point_group) == 2 -def test_can_understand_C3h_symmetry(): +def test_can_understand_C3h_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C3h symmetry.""" data = datasets.logfiles["symmetries"]["boric-acid"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -622,7 +587,7 @@ def test_can_understand_C3h_symmetry(): assert coords.symmetry_number(point_group) == 3 -def test_can_understand_C2v_symmetry(): +def test_can_understand_C2v_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C2v symmetry.""" data = datasets.logfiles["symmetries"]["water"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -883,13 +848,12 @@ def test_can_understand_C2v_symmetry(): assert coords.symmetry_number(point_group) == 2 -def test_can_understand_C3v_symmetry(): +def test_can_understand_C3v_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C3v symmetry.""" data = datasets.logfiles["symmetries"]["ammonia"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([1.70511527, 1.70683927, 2.6588982]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 2 assert len(groups[0]) == 1 @@ -979,7 +943,6 @@ def test_can_understand_C3v_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([269.55650843, 269.5984722, 366.72364626]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 1 @@ -990,7 +953,6 @@ def test_can_understand_C3v_symmetry(): proper_axes = coords._get_proper_axes(atomcoords, groups, axes, rotor_class) assert len(proper_axes) == 1 assert proper_axes[0][0] == 3 - # assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -1064,7 +1026,7 @@ def test_can_understand_C3v_symmetry(): assert coords.symmetry_number(point_group) == 3 -def test_can_understand_C4v_symmetry(): +def test_can_understand_C4v_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C4v symmetry.""" data = datasets.logfiles["symmetries"]["OF4Xe"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1094,25 +1056,13 @@ def test_can_understand_C4v_symmetry(): assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" assert mirror_axes[3][0] == "v" - # assert mirror_axes[0][1] == pytest.approx( - # [0.9999835391906019, 0.005719503675732009, -0.00045675545024613507] - # ) - # assert mirror_axes[1][1] == pytest.approx( - # [-0.00505092778575004, 0.9999871320942353, -0.0004730480416265371] - # ) - # assert mirror_axes[2][1] == pytest.approx( - # [-0.7031857811796408, -0.7110059899310466, 0.0004893147767132002] - # ) - # assert mirror_axes[3][1] == pytest.approx( - # [-0.7112312161823279, 0.7029581474041968, -1.1219010926151304e-5] - # ) assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C4v" assert coords.symmetry_number(point_group) == 4 -def test_can_understand_C5v_symmetry(): +def test_can_understand_C5v_symmetry(): # noqa: N802 """Ensure values match regression logfiles for C5v symmetry.""" data = datasets.logfiles["symmetries"]["corannulene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1165,7 +1115,7 @@ def test_can_understand_C5v_symmetry(): assert coords.symmetry_number(point_group) == 5 -def test_can_understand_D2_symmetry(): +def test_can_understand_D2_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D2 symmetry.""" data = datasets.logfiles["symmetries"]["biphenyl"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1205,13 +1155,12 @@ def test_can_understand_D2_symmetry(): assert coords.symmetry_number(point_group) == 4 -def test_can_understand_D3_symmetry(): +def test_can_understand_D3_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D3 symmetry.""" data = datasets.logfiles["symmetries"]["tris-ethylenediamine-RuII"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([716.90346743, 716.9163632, 1112.40527375]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 7 assert len(groups[0]) == 1 @@ -1229,7 +1178,6 @@ def test_can_understand_D3_symmetry(): assert proper_axes[1][0] == 2 assert proper_axes[2][0] == 2 assert proper_axes[3][0] == 2 - # assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[1][1] == pytest.approx( [-0.007801928433068849, 0.999969564493194, -1.3114109559063874e-7] ) @@ -1298,7 +1246,7 @@ def test_can_understand_D3_symmetry(): assert coords.symmetry_number(point_group) == 6 -def test_can_understand_D5_symmetry(): +def test_can_understand_D5_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D5 symmetry.""" data = datasets.logfiles["symmetries"]["ferrocene-twisted"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1357,7 +1305,7 @@ def test_can_understand_D5_symmetry(): assert coords.symmetry_number(point_group) == 10 -def test_can_understand_D2h_symmetry(): +def test_can_understand_D2h_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D2h symmetry.""" data = datasets.logfiles["symmetries"]["ethylene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1376,8 +1324,6 @@ def test_can_understand_D2h_symmetry(): assert proper_axes[1][0] == 2 assert proper_axes[2][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - # assert proper_axes[1][1] == pytest.approx([0.0, 1.0, 0.0]) - # assert proper_axes[2][1] == pytest.approx([0.0, 0.0, 1.0]) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -1396,8 +1342,6 @@ def test_can_understand_D2h_symmetry(): assert mirror_axes[1][0] == "h" assert mirror_axes[2][0] == "h" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - # assert mirror_axes[1][1] == pytest.approx([0.0, 1.0, 0.0]) - # assert mirror_axes[2][1] == pytest.approx([0.0, 0.0, 1.0]) assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D2h" @@ -1407,7 +1351,6 @@ def test_can_understand_D2h_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([6.26383693, 26.96388268, 29.40025824]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 2 @@ -1421,8 +1364,6 @@ def test_can_understand_D2h_symmetry(): assert proper_axes[1][0] == 2 assert proper_axes[2][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - # assert proper_axes[1][1] == pytest.approx([0.0, 0.0, 1.0]) - # assert proper_axes[2][1] == pytest.approx([0.0, 1.0, 0.0]) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -1441,8 +1382,6 @@ def test_can_understand_D2h_symmetry(): assert mirror_axes[1][0] == "h" assert mirror_axes[2][0] == "h" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - # assert mirror_axes[1][1] == pytest.approx([0.0, 0.0, 1.0]) - # assert mirror_axes[2][1] == pytest.approx([0.0, 1.0, 0.0]) assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D2h" @@ -1541,7 +1480,7 @@ def test_can_understand_D2h_symmetry(): assert coords.symmetry_number(point_group) == 4 -def test_can_understand_D3h_symmetry(): +def test_can_understand_D3h_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D3h symmetry.""" data = datasets.logfiles["ethane"]["eclipsed@B97-3c"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1612,7 +1551,6 @@ def test_can_understand_D3h_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([50.77255975, 50.7862414, 101.55880103]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 2 assert len(groups[0]) == 1 @@ -1625,7 +1563,6 @@ def test_can_understand_D3h_symmetry(): assert proper_axes[1][0] == 2 assert proper_axes[2][0] == 2 assert proper_axes[3][0] == 2 - # assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[1][1] == pytest.approx( [0.786485610329844, -0.6176086014998113, 9.876227954894027e-6] ) @@ -1649,7 +1586,6 @@ def test_can_understand_D3h_symmetry(): assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" assert mirror_axes[3][0] == "v" - # assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert mirror_axes[1][1] == pytest.approx( [0.3722848618205517, -0.9281185170328478, 1.1628857803315213e-9] ) @@ -1668,11 +1604,6 @@ def test_can_understand_D3h_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([452.37354879, 558.48639882, 558.6442966]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [[1.0, 0.0, 0.0], [0.0, 1.0, -1.11821663e-12], [0.0, 1.11810561e-12, 1.0]] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 1 @@ -1687,15 +1618,6 @@ def test_can_understand_D3h_symmetry(): assert proper_axes[2][0] == 2 assert proper_axes[3][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - # assert proper_axes[1][1] == pytest.approx( - # [0.0001997060253834037, -0.33600385261575644, 0.9418605900794833] - # ) - # assert proper_axes[2][1] == pytest.approx( - # [-0.00012559744182296924, -0.9836343455164556, 0.18017618751016082] - # ) - # assert proper_axes[3][1] == pytest.approx( - # [-0.00032535420422918877, -0.6480520885057931, -0.7615959458452503] - # ) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -1711,21 +1633,12 @@ def test_can_understand_D3h_symmetry(): assert mirror_axes[2][0] == "v" assert mirror_axes[3][0] == "v" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - # assert mirror_axes[1][1] == pytest.approx( - # [0.0001544181847713839, -0.76190637662992, 0.647687153960684] - # ) - # assert mirror_axes[2][1] == pytest.approx( - # [-0.0001486955790155652, -0.941961644198146, -0.33572047710729574] - # ) - # assert mirror_axes[3][1] == pytest.approx( - # [-0.00030318766112059263, -0.18019063014134656, -0.9836316611854798] - # ) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D3h" assert coords.symmetry_number(point_group) == 6 -def test_can_understand_D4h_symmetry(): +def test_can_understand_D4h_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D4h symmetry.""" data = datasets.logfiles["symmetries"]["XeF4"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1746,18 +1659,6 @@ def test_can_understand_D4h_symmetry(): assert proper_axes[3][0] == 2 assert proper_axes[4][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - # assert proper_axes[1][1] == pytest.approx( - # [-0.1038959947038264, -0.9945881671749733, -1.722176640137799e-7] - # ) - # assert proper_axes[2][1] == pytest.approx( - # [-0.6297499896948396, 0.7767978826434407, -1.2938984477698114e-7] - # ) - # assert proper_axes[3][1] == pytest.approx( - # [-0.7768900176339207, -0.6296363240004132, -1.1409827074055784e-7] - # ) - # assert proper_axes[4][1] == pytest.approx( - # [-0.9945789090852918, 0.10398458348563748, -1.721587770986498e-7] - # ) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -1782,18 +1683,6 @@ def test_can_understand_D4h_symmetry(): assert mirror_axes[3][0] == "v" assert mirror_axes[4][0] == "v" assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - # assert mirror_axes[1][1] == pytest.approx( - # [0.9945939007358418, -0.10384109311376788, -1.0806855373154067e-8] - # ) - # assert mirror_axes[2][1] == pytest.approx( - # [0.10411808372214175, 0.994564942395432, -1.0802010730760494e-8] - # ) - # assert mirror_axes[3][1] == pytest.approx( - # [-0.6298927524585732, 0.7766821231367197, 6.24992618671696e-12] - # ) - # assert mirror_axes[4][1] == pytest.approx( - # [-0.776841781663576, -0.6296958363065147, -2.913051691777635e-11] - # ) assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D4h" @@ -1873,7 +1762,7 @@ def test_can_understand_D4h_symmetry(): assert coords.symmetry_number(point_group) == 8 -def test_can_understand_D5h_symmetry(): +def test_can_understand_D5h_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D5h symmetry.""" data = datasets.logfiles["symmetries"]["cyclopentadienyl-"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1904,21 +1793,6 @@ def test_can_understand_D5h_symmetry(): assert proper_axes[4][0] == 2 assert proper_axes[5][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - # assert proper_axes[1][1] == pytest.approx( - # [0.9852635321302113, -0.1710431876018575, -1.5142524986039497e-5] - # ) - # assert proper_axes[2][1] == pytest.approx( - # [0.8976888382803988, 0.4406299460094585, 1.7506847806145937e-5] - # ) - # assert proper_axes[3][1] == pytest.approx( - # [0.46736242714771226, 0.8840658119171837, 4.347194495240259e-5] - # ) - # assert proper_axes[4][1] == pytest.approx( - # [-0.14169717322488817, 0.989910050980385, 4.547623249634363e-5] - # ) - # assert proper_axes[5][1] == pytest.approx( - # [-0.6966055119393046, 0.717454360799123, 3.0101515311866436e-5] - # ) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -1936,21 +1810,6 @@ def test_can_understand_D5h_symmetry(): assert mirror_axes[4][0] == "v" assert mirror_axes[5][0] == "v" assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - # assert mirror_axes[1][1] == pytest.approx( - # [0.7175304768309594, 0.6965271097667781, -1.3366924475017621e-5] - # ) - # assert mirror_axes[2][1] == pytest.approx( - # [0.1712137266526045, 0.9852339109556842, 2.2554246915974823e-5] - # ) - # assert mirror_axes[3][1] == pytest.approx( - # [-0.44063308377390153, 0.8976872968896024, 4.986923808926847e-5] - # ) - # assert mirror_axes[4][1] == pytest.approx( - # [-0.8842015694852551, 0.4671055383465718, 2.3785937837845682e-5] - # ) - # assert mirror_axes[5][1] == pytest.approx( - # [-0.9899102667835931, -0.14169567243616252, -1.1370992919649144e-5] - # ) assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D5h" @@ -1960,11 +1819,6 @@ def test_can_understand_D5h_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([228.8186135, 480.633784, 480.63796274]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [[1.0, 0.0, 0.0], [0.0, 1.0, 1.73114301e-12], [0.0, -1.73112913e-12, 1.0]] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 1 @@ -2030,15 +1884,12 @@ def test_can_understand_D5h_symmetry(): assert coords.symmetry_number(point_group) == 10 -def test_can_understand_D6h_symmetry(): +def test_can_understand_D6h_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D6h symmetry.""" data = datasets.logfiles["symmetries"]["benzene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([90.78768809, 90.79030869, 181.57799671]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array([[1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [0.0, 0.0, -1.0]]) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 2 assert len(groups[0]) == 6 @@ -2054,7 +1905,6 @@ def test_can_understand_D6h_symmetry(): assert proper_axes[4][0] == 2 assert proper_axes[5][0] == 2 assert proper_axes[6][0] == 2 - # assert proper_axes[0][1] == pytest.approx([0.0, 0.0, -1.0]) assert proper_axes[1][1] == pytest.approx( [0.9815106205020463, -0.19140768362000038, 2.2201659599405544e-5] ) @@ -2102,7 +1952,6 @@ def test_can_understand_D6h_symmetry(): assert mirror_axes[4][0] == "v" assert mirror_axes[5][0] == "v" assert mirror_axes[6][0] == "v" - # assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, -1.0]) assert mirror_axes[1][1] == pytest.approx( [0.9815122368811188, -0.19139939609355305, -5.257917527921303e-6] ) @@ -2127,7 +1976,7 @@ def test_can_understand_D6h_symmetry(): assert coords.symmetry_number(point_group) == 12 -def test_can_understand_D7h_symmetry(): +def test_can_understand_D7h_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D7h symmetry.""" data = datasets.logfiles["symmetries"]["C7H7+"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -2218,7 +2067,7 @@ def test_can_understand_D7h_symmetry(): assert coords.symmetry_number(point_group) == 14 -def test_can_understand_D8h_symmetry(): +def test_can_understand_D8h_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D8h symmetry.""" data = datasets.logfiles["symmetries"]["C8H8-2"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -2342,17 +2191,12 @@ def test_can_understand_D8h_symmetry(): assert coords.symmetry_number(point_group) == 16 -def test_can_understand_D2d_symmetry(): +def test_can_understand_D2d_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D2d symmetry.""" data = datasets.logfiles["symmetries"]["allene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([3.59943307, 58.28028795, 58.2804547]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [[1.0, 0.0, 0.0], [0.0, 1.0, 8.04637468e-11], [0.0, -8.04637468e-11, 1.0]] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 1 @@ -2399,13 +2243,6 @@ def test_can_understand_D2d_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([191.055088155, 191.055088155, 338.69081546]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [[-1.0, -6.58647258e-10, 0.0], - # [-6.58647258e-10, 1.0, 0.0], - # [0.0, 0.0, 1.0]] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 2 assert len(groups[0]) == 8 @@ -2417,10 +2254,6 @@ def test_can_understand_D2d_symmetry(): assert proper_axes[0][0] == 2 assert proper_axes[1][0] == 2 assert proper_axes[2][0] == 2 - # assert proper_axes[0][1] == pytest.approx( - # [0.99999999999998, 1.9484724096899716e-7, -4.445039596172754e-8] - # ) - # assert proper_axes[1][1] == pytest.approx([2.527746904635184e-10, -1.0, 0.0]) assert proper_axes[2][1] == pytest.approx([0.0, 0.0, 1.0]) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes @@ -2446,7 +2279,7 @@ def test_can_understand_D2d_symmetry(): assert coords.symmetry_number(point_group) == 4 -def test_can_understand_D3d_symmetry(): +def test_can_understand_D3d_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D3d symmetry.""" data = datasets.logfiles["ethane"]["staggered@B97-3c"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -2521,7 +2354,6 @@ def test_can_understand_D3d_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([119.83069224, 119.84744745, 209.85483434]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 6 @@ -2579,13 +2411,12 @@ def test_can_understand_D3d_symmetry(): assert coords.symmetry_number(point_group) == 6 -def test_can_understand_D4d_symmetry(): +def test_can_understand_D4d_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D4d symmetry.""" data = datasets.logfiles["symmetries"]["S8"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([810.52396682, 810.88788286, 1489.78398196]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 1 assert len(groups[0]) == 8 @@ -2598,7 +2429,6 @@ def test_can_understand_D4d_symmetry(): assert proper_axes[2][0] == 2 assert proper_axes[3][0] == 2 assert proper_axes[4][0] == 2 - # assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[1][1] == pytest.approx( [0.963244226087016, 0.26862717752913695, -2.0068760230898394e-5] ) @@ -2643,7 +2473,7 @@ def test_can_understand_D4d_symmetry(): assert coords.symmetry_number(point_group) == 8 -def test_can_understand_D5d_symmetry(): +def test_can_understand_D5d_symmetry(): # noqa: N802 """Ensure values match regression logfiles for D5d symmetry.""" data = datasets.logfiles["symmetries"]["ferrocene-staggered"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -2732,7 +2562,7 @@ def test_can_understand_D5d_symmetry(): assert coords.symmetry_number(point_group) == 10 -def test_can_understand_S4_symmetry(): +def test_can_understand_S4_symmetry(): # noqa: N802 """Ensure values match regression logfiles for S4 symmetry.""" data = datasets.logfiles["symmetries"]["tetrachloroneopentane"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -2779,11 +2609,6 @@ def test_can_understand_S4_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([1124.75960399, 1124.76010676, 1717.87114398]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [[1.0, -8.47946613e-11, 0.0], [8.47946613e-11, 1.0, 0.0], [0.0, 0.0, 1.0]] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 3 assert len(groups[0]) == 4 @@ -2814,11 +2639,6 @@ def test_can_understand_S4_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([2328.48397615, 2573.6635109, 2573.66376861]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [[1.0, 0.0, 0.0], [0.0, -1.0, 1.78502646e-9], [0.0, -1.78502657e-9, -1.0]] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 12 assert len(groups[0]) == 1 @@ -2855,7 +2675,7 @@ def test_can_understand_S4_symmetry(): assert coords.symmetry_number(point_group) == 2 -def test_can_understand_Td_symmetry(): +def test_can_understand_Td_symmetry(): # noqa: N802 """Ensure values match regression logfiles for Td symmetry.""" data = datasets.logfiles["tanaka1996"][ "methane@UMP2/6-311G(2df,2pd)" @@ -3016,7 +2836,7 @@ def test_can_understand_Td_symmetry(): assert coords.symmetry_number(point_group) == 12 -def test_can_understand_Oh_symmetry(): +def test_can_understand_Oh_symmetry(): # noqa: N802 """Ensure values match regression logfiles for Oh symmetry.""" data = datasets.logfiles["symmetries"]["cubane"] # hexahedron aka cube moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -3171,15 +2991,6 @@ def test_can_understand_Oh_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([195.62987814, 195.64569248, 195.66607271]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [ - # [1.0, 0.0, 0.0], - # [0.0, -1.0, -3.53539420e-12], - # [0.0, 3.53528318e-12, -1.0], - # ] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 2 assert len(groups[0]) == 1 @@ -3316,13 +3127,12 @@ def test_can_understand_Oh_symmetry(): assert coords.symmetry_number(point_group) == 24 -def test_can_understand_Ih_symmetry(): +def test_can_understand_Ih_symmetry(): # noqa: N802 """Ensure values match regression logfiles for Ih symmetry.""" data = datasets.logfiles["symmetries"]["B12H12-2"] # icosahedron moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([323.38198873, 323.39397591, 323.41051849]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx(np.eye(3)) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 2 assert len(groups[0]) == 12 @@ -3414,16 +3224,6 @@ def test_can_understand_Ih_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([913.24407956, 913.29418754, 913.31698587]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [ - # [1.0, 1.70162761e-12, -9.25867193e-13], - # [-1.70162761e-12, 1.0, -1.20725652e-11], - # [9.25867193e-13, 1.20723431e-11, 1.0], - # ] - # ), - # abs=1e-6, - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 2 assert len(groups[0]) == 20 @@ -3458,84 +3258,6 @@ def test_can_understand_Ih_symmetry(): assert proper_axes[23][0] == 2 assert proper_axes[24][0] == 2 assert proper_axes[25][0] == 2 - # assert proper_axes[0][1] == pytest.approx( - # [0.30812755902834976, -0.8903567199966111, -0.3351452200526021] - # ) - # assert proper_axes[1][1] == pytest.approx( - # [0.8726443120221634, 0.48109350478653806, 0.08391033516540448] - # ) - # assert proper_axes[2][1] == pytest.approx( - # [0.8614074576994745, -0.10001871102175852, 0.49796932562686447] - # ) - # assert proper_axes[3][1] == pytest.approx( - # [0.7596892134828486, 0.27409255736379445, -0.5896995581782184] - # ) - # assert proper_axes[4][1] == pytest.approx( - # [0.7414824163231822, -0.666144750744675, 0.0803429980698362] - # ) - # assert proper_axes[5][1] == pytest.approx( - # [0.3302346609505096, 0.9016241192927089, 0.27931884328943724] - # ) - # assert proper_axes[6][1] == pytest.approx( - # [0.3120109859687541, -0.03865184151950474, 0.9492919360143943] - # ) - # assert proper_axes[7][1] == pytest.approx( - # [-0.016260703551204576, 0.5804485493590502, 0.8141345534166905] - # ) - # assert proper_axes[8][1] == pytest.approx( - # [-0.1179699843211733, 0.9546064692510375, -0.27351338479739845] - # ) - # assert proper_axes[9][1] == pytest.approx( - # [-0.1474452224156102, -0.5667983189879612, 0.8105551011370126] - # ) - # assert proper_axes[10][1] == pytest.approx( - # [-0.6786441697763973, 0.4349077820354078, 0.5918591994330631] - # ) - # assert proper_axes[11][1] == pytest.approx( - # [0.928118614537316, 0.20396514164540264, 0.31143869114627337] - # ) - # assert proper_axes[12][1] == pytest.approx( - # [0.8736884535306767, 0.4042058565781007, -0.27071407734940317] - # ) - # assert proper_axes[13][1] == pytest.approx( - # [0.8579208244577288, -0.41007394027335836, 0.3095338793580648] - # ) - # assert proper_axes[14][1] == pytest.approx( - # [0.6438263259775652, 0.7400631620921857, 0.19440724804478193] - # ) - # assert proper_axes[15][1] == pytest.approx( - # [0.6280638876411975, -0.07422235787999441, 0.7746139649088178] - # ) - # assert proper_axes[16][1] == pytest.approx( - # [0.46001318415311654, -0.8674778123468325, 0.18939407459386004] - # ) - # assert proper_axes[17][1] == pytest.approx( - # [0.1680489404647018, 0.7932497720982239, 0.585247257725149] - # ) - # assert proper_axes[18][1] == pytest.approx( - # [0.15829526011504383, 0.2899900056203697, 0.943847661047803] - # ) - # assert proper_axes[19][1] == pytest.approx( - # [0.113610536873139, 0.9935205074099875, 0.003106005022207571] - # ) - # assert proper_axes[20][1] == pytest.approx( - # [0.08808142660688456, -0.32405646870648736, 0.9419283769885995] - # ) - # assert proper_axes[21][1] == pytest.approx( - # [-0.015762043382657284, -0.8143123041659879, 0.5802129171884083] - # ) - # assert proper_axes[22][1] == pytest.approx( - # [-0.3719270798702417, 0.5434681154659787, 0.7525374772933587] - # ) - # assert proper_axes[23][1] == pytest.approx( - # [-0.48556796883698194, -0.4501297827597275, 0.7494043810335033] - # ) - # assert proper_axes[24][1] == pytest.approx( - # [-0.7601520620354372, 0.5892327485753275, 0.27381309426256056] - # ) - # assert proper_axes[25][1] == pytest.approx( - # [-0.7698674324966721, 0.08601045747669914, 0.6323814810584122] - # ) improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes ) @@ -3611,51 +3333,6 @@ def test_can_understand_Ih_symmetry(): assert mirror_axes[12][0] == "v" assert mirror_axes[13][0] == "v" assert mirror_axes[14][0] == "v" - # assert mirror_axes[0][1] == pytest.approx( - # [0.8579334690639634, -0.41004375526345205, 0.3095388205529633] - # ) - # assert mirror_axes[1][1] == pytest.approx( - # [0.7601521051800151, -0.5892326301810166, -0.2738132292646812] - # ) - # assert mirror_axes[2][1] == pytest.approx( - # [0.6438181879254126, 0.7400694139687545, 0.19441039942447158] - # ) - # assert mirror_axes[3][1] == pytest.approx( - # [0.4600545615068519, -0.8674583597729, 0.18938266683318256] - # ) - # assert mirror_axes[4][1] == pytest.approx( - # [0.16806298579330683, 0.7932770116125302, 0.5852063017888072] - # ) - # assert mirror_axes[5][1] == pytest.approx( - # [0.1582924990882815, 0.2900529423545288, 0.9438287849837315] - # ) - # assert mirror_axes[6][1] == pytest.approx( - # [0.11360805419593054, 0.9935208368212058, 0.0030914113129076734] - # ) - # assert mirror_axes[7][1] == pytest.approx( - # [-0.015761991718039978, -0.8143123203369762, 0.580212895896403] - # ) - # assert mirror_axes[8][1] == pytest.approx( - # [-0.37192961468555336, 0.5434156210090533, 0.7525741322708354] - # ) - # assert mirror_axes[9][1] == pytest.approx( - # [-0.7699024189242863, 0.0859974901764, 0.632340649506176] - # ) - # assert mirror_axes[10][1] == pytest.approx( - # [0.9281410528012134, 0.20390316557611038, 0.3114124036917868] - # ) - # assert mirror_axes[11][1] == pytest.approx( - # [0.8737016660226733, 0.40421412598335454, -0.2706590828786609] - # ) - # assert mirror_axes[12][1] == pytest.approx( - # [0.6280308059506817, -0.0742510540729961, 0.7746380365990211] - # ) - # assert mirror_axes[13][1] == pytest.approx( - # [0.08809637894462627, -0.3239897263884152, 0.9419499377417064] - # ) - # assert mirror_axes[14][1] == pytest.approx( - # [-0.4855678974971889, -0.4501298612905931, 0.7494043800877273] - # ) assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Ih" @@ -3665,15 +3342,6 @@ def test_can_understand_Ih_symmetry(): moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([6133.59929944, 6133.81659269, 6134.15217423]) assert axes.T @ axes == pytest.approx(np.eye(3)) - # assert axes == pytest.approx( - # np.array( - # [ - # [1.0, -5.34640329e-12, -1.79924976e-13], - # [5.34640329e-12, 1.0, -6.49480469e-14], - # [1.79924976e-13, 6.49480469e-14, 1.0], - # ] - # ) - # ) groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 1 assert len(groups[0]) == 60 @@ -3957,7 +3625,6 @@ def test_match_regression_logfiles(): proper_axes = coords._get_proper_axes(atomcoords, groups, axes, rotor_class) assert len(proper_axes) == 1 assert proper_axes[0][0] == 3 - # assert proper_axes[0][1] == pytest.approx([-1.0, 0.0, 0.0]) # dichloromethane data = datasets.logfiles["symmetries"]["dichloromethane"] diff --git a/tests/test_rates.py b/tests/test_rates.py index d8e60a99..cab17efc 100644 --- a/tests/test_rates.py +++ b/tests/test_rates.py @@ -15,16 +15,20 @@ def test_sanity_for_chemical_kinetics(): This partially ensures we do similar analysis as Gaussian, see https://gaussian.com/thermo/. """ - freeenergies_H = np.array( + freeenergies_H = np.array( # noqa: N806 [-98.579127, -454.557870, -553.109488, -98.001318, -455.146251] ) - freeenergies_D = np.array( + freeenergies_D = np.array( # noqa: N806 [-98.582608, -454.557870, -553.110424, -98.001318, -455.149092] ) scheme = rx.parse_reactions("FH + Cl -> FHCl‑ -> F + HCl") - delta_freeenergies_H = rx.thermo.get_delta(scheme.B, freeenergies_H)[0] - delta_freeenergies_D = rx.thermo.get_delta(scheme.B, freeenergies_D)[0] + delta_freeenergies_H = rx.thermo.get_delta(scheme.B, freeenergies_H)[ # noqa: N806 + 0 + ] # noqa: RUF100 + delta_freeenergies_D = rx.thermo.get_delta(scheme.B, freeenergies_D)[ # noqa: N806 + 0 + ] # noqa: RUF100 assert delta_freeenergies_H == pytest.approx(0.027509) assert delta_freeenergies_H * (constants.hartree * constants.N_A) / ( constants.kcal @@ -34,11 +38,11 @@ def test_sanity_for_chemical_kinetics(): constants.kcal ) == pytest.approx(18.86, 5e-5) - k_H = rx.get_k( + k_H = rx.get_k( # noqa: N806 scheme, delta_freeenergies=delta_freeenergies_H * constants.hartree * constants.N_A, ) - k_D = rx.get_k( + k_D = rx.get_k( # noqa: N806 scheme, delta_freeenergies=delta_freeenergies_D * constants.hartree * constants.N_A, ) @@ -278,7 +282,8 @@ def test_second_order_conversion_rate_example(): def test_second_order_conversion_rates_match_literature(): """Ensure calculated second order factors are correct. - References are given in the comments.""" + References are given in the comments. + """ for temperature in [200.0, 273.15, 298.15, 300.0, 373.15, 400.0]: # to cm3 mol-1 s-1 (doi:10.1021/ed046p54) assert rx.rates.convert_rate_constant( @@ -673,7 +678,8 @@ def test_second_order_conversion_rates_match_literature(): def test_third_order_conversion_rates_match_literature(): """Ensure calculated third order factors are correct. - References are given in the comments.""" + References are given in the comments. + """ for temperature in [200.0, 273.15, 298.15, 300.0, 373.15, 400.0]: # to cm3 mol-1 s-1 # () diff --git a/tests/test_regressions.py b/tests/test_regressions.py index c3643521..b83433f9 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -2,7 +2,8 @@ """Regressions against experimental/reference values. -This also tests the high-level application programming interface.""" +This also tests the high-level application programming interface. +""" import numpy as np import pytest @@ -24,7 +25,7 @@ def test_basic_example_for_solvation_equilibria(): """ model = rx.parse_model("data/acetate/Orca4/model.k") temperature = 298.15 - pK = 4.756 # doi:10.1063/1.1416902 + pK = 4.756 # doi:10.1063/1.1416902 # noqa: N806 acid_energy = -constants.R * temperature * np.log(10**-pK) / constants.kcal solv_energy = ( @@ -82,7 +83,7 @@ def test_basic_example_for_solvation_equilibria(): def test_basic_example_for_solvation_phase_kinetics(): - """Reproduce literature data for NH3(w) + OHΒ·(w) -> NH2Β·(w) + H2O(w). + """Reproduce literature data for NH3(w) + OHΒ·(w) -> NH2Β·(w) + H2O(w). This uses raw data from from doi:10.1002/qua.25686 and no calls from overreact.api. @@ -144,7 +145,7 @@ def test_basic_example_for_solvation_phase_kinetics(): def test_basic_example_for_gas_phase_kinetics(): - """Reproduce literature data for CH4 + Clβ‹… -> CH3Β· + HCl. + """Reproduce literature data for CH4 + Clβ‹… -> CH3Β· + HCl. This uses raw data from from doi:10.1002/qua.25686 and no calls from overreact.api. @@ -214,7 +215,7 @@ def test_basic_example_for_gas_phase_kinetics(): def test_rate_constants_for_hickel1992(): - """Reproduce literature data for NH3(w) + OHΒ·(w) -> NH2Β·(w) + H2O(w). + """Reproduce literature data for NH3(w) + OHΒ·(w) -> NH2Β·(w) + H2O(w). Data is as cited in doi:10.1002/qua.25686 and is experimental except when otherwise indicated in the comments. @@ -247,7 +248,6 @@ def test_rate_constants_for_hickel1992(): rx.get_k( model.scheme, model.compounds, - # tunneling="eckart", # this is default qrrho=(False, True), scale="M-1 s-1", temperature=temperature, @@ -262,7 +262,7 @@ def test_rate_constants_for_hickel1992(): assert np.log10(k_cla) == pytest.approx(np.log10(k_cla_ref), 8e-3) assert np.log10(k_eck) == pytest.approx(np.log10(k_eck_ref), 5e-3) - for k, k_ref, tols in zip( + for k, k_ref, tols in zip( # noqa: B905 [k_cla, k_eck], [k_cla_ref, k_eck_ref], [(1.0e-1, 0.62, 2e-3, 5e-8, 3e-2), (1.1e-1, 0.75, 2e-3, 3e-8, 2e-2)], @@ -278,7 +278,7 @@ def test_rate_constants_for_hickel1992(): def test_rate_constants_for_tanaka1996(): - """Reproduce literature data for CH4 + Clβ‹… -> CH3Β· + HCl. + """Reproduce literature data for CH4 + Clβ‹… -> CH3Β· + HCl. Data is as cited in doi:10.1007/BF00058703 and doi:10.1002/qua.25686 and is experimental except when otherwise indicated in the comments. @@ -355,7 +355,6 @@ def test_rate_constants_for_tanaka1996(): rx.get_k( model.scheme, model.compounds, - # tunneling="eckart", # this is default qrrho=True, scale="cm3 particle-1 s-1", temperature=temperature, @@ -373,7 +372,7 @@ def test_rate_constants_for_tanaka1996(): assert np.log10(k_eck) == pytest.approx(np.log10(k_eck_ref), 2e-2) assert np.log10(k_eck[:-1]) == pytest.approx(np.log10(k_exp), 3e-3) - for k, k_ref, tols in zip( + for k, k_ref, tols in zip( # noqa: B905 [k_cla, k_eck, k_eck[:-1]], [k_cla_ref, k_eck_ref, k_exp], [ @@ -393,7 +392,7 @@ def test_rate_constants_for_tanaka1996(): def test_delta_energies_for_hickel1992(): - """Reproduce literature data for NH3(w) + OHΒ·(w) -> NH2Β·(w) + H2O(w). + """Reproduce literature data for NH3(w) + OHΒ·(w) -> NH2Β·(w) + H2O(w). Data is as cited in doi:10.1002/qua.25686 and is experimental except when otherwise indicated in the comments. @@ -441,7 +440,7 @@ def test_delta_energies_for_hickel1992(): def test_delta_energies_for_tanaka1996(): - """Reproduce literature data for CH4 + Clβ‹… -> CH3Β· + HCl. + """Reproduce literature data for CH4 + Clβ‹… -> CH3Β· + HCl. Data is as cited in doi:10.1007/BF00058703 and doi:10.1002/qua.25686 and is experimental except when otherwise indicated in the comments. @@ -501,7 +500,7 @@ def test_delta_energies_for_tanaka1996(): def test_logfiles_for_hickel1992(): - """Reproduce literature data for NH3(w) + OHΒ·(w) -> NH2Β·(w) + H2O(w). + """Reproduce literature data for NH3(w) + OHΒ·(w) -> NH2Β·(w) + H2O(w). Data is as cited in doi:10.1002/qua.25686 and is experimental except when otherwise indicated in the comments. @@ -512,7 +511,6 @@ def test_logfiles_for_hickel1992(): theory = "UM06-2X" basisset = "6-311++G(d,p)" - # NH3(w) data = datasets.logfiles["hickel1992"][f"NH3@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) assert rx.coords.symmetry_number(point_group) == 3 @@ -524,7 +522,6 @@ def test_logfiles_for_hickel1992(): [1065.8, 1621.5, 1620.6, 3500.2, 3615.5, 3617.3], 4e-2 ) # M06-2X/6-311++G(d,p) from doi:10.1002/qua.25686 - # OHΒ·(w) data = datasets.logfiles["hickel1992"][f"OHΒ·@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) assert rx.coords.symmetry_number(point_group) == 1 @@ -534,7 +531,6 @@ def test_logfiles_for_hickel1992(): [3724.3], 2e-2 ) # M06-2X/6-311++G(d,p) from doi:10.1002/qua.25686 - # NH2Β·(w) data = datasets.logfiles["hickel1992"][f"NH2Β·@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) assert rx.coords.symmetry_number(point_group) == 2 @@ -546,7 +542,6 @@ def test_logfiles_for_hickel1992(): [1471.2, 3417.6, 3500.8], 9e-3 ) # M06-2X/6-311++G(d,p) from doi:10.1002/qua.25686 - # H2O(w) data = datasets.logfiles["hickel1992"][f"H2O@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) assert rx.coords.symmetry_number(point_group) == 2 @@ -558,7 +553,6 @@ def test_logfiles_for_hickel1992(): [1570.4, 3847.9, 3928.9], 6e-3 ) # M06-2X/6-311++G(d,p) from doi:10.1002/qua.25686 - # NH3Β·OH#(w) data = datasets.logfiles["hickel1992"][f"NH3Β·OH@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) assert rx.coords.symmetry_number(point_group) == 1 @@ -568,7 +562,7 @@ def test_logfiles_for_hickel1992(): def test_logfiles_for_tanaka1996(): - """Reproduce literature data for CH4 + Clβ‹… -> CH3Β· + HCl. + """Reproduce literature data for CH4 + Clβ‹… -> CH3Β· + HCl. Data is as cited in doi:10.1007/BF00058703 and doi:10.1002/qua.25686 and is experimental except when otherwise indicated in the comments. diff --git a/tests/test_thermo_gas.py b/tests/test_thermo_gas.py index c6b71e8a..b416229b 100644 --- a/tests/test_thermo_gas.py +++ b/tests/test_thermo_gas.py @@ -1175,7 +1175,8 @@ def test_can_calculate_reaction_entropies(): """Ensure we can calculate reaction translational entropies. This contribution is due to indistinguishability of some reactants or - products.""" + products. + """ assert rx.thermo.get_reaction_entropies([-1, 1]) == pytest.approx(0.0) assert rx.thermo.get_reaction_entropies([-2, 1]) == pytest.approx( -constants.R * np.log(2) diff --git a/tests/test_thermo_solv.py b/tests/test_thermo_solv.py index 93024231..f4eda4cd 100644 --- a/tests/test_thermo_solv.py +++ b/tests/test_thermo_solv.py @@ -70,19 +70,6 @@ def test_entropy_liquid_phase(): assert (solv_entropy - gas_entropy) / constants.calorie == pytest.approx( -26.9, abs=constants.kilo / 298.15 ) - # solv_entropy = rx.thermo.calc_entropy( - # data.atommasses, - # data.atomnos, - # data.atomcoords, - # moments=moments, - # symmetry_number=symmetry_number, - # vibfreqs=data.vibfreqs, - # environment="water", - # method="garza", - # ) - # assert (solv_entropy - gas_entropy) / constants.calorie == pytest.approx( - # -27.2, abs=constants.kilo / 298.15 - # ) solv_entropy = rx.thermo.calc_entropy( data.atommasses, data.atomnos, @@ -163,58 +150,6 @@ def test_entropy_liquid_phase(): assert (solv_entropy - gas_entropy) / constants.calorie == pytest.approx( -18.6, abs=constants.kilo / 298.15 ) - # solv_entropy = rx.thermo.calc_entropy( - # data.atommasses, - # data.atomnos, - # data.atomcoords, - # moments=moments, - # symmetry_number=symmetry_number, - # vibfreqs=data.vibfreqs, - # environment="toluene", - # method="garza", - # ) - # assert (solv_entropy - gas_entropy) / constants.calorie == pytest.approx( - # -17.6, abs=constants.kilo / 298.15 - # ) - # solv_entropy = rx.thermo.calc_entropy( - # data.atommasses, - # data.atomnos, - # data.atomcoords, - # moments=moments, - # symmetry_number=symmetry_number, - # vibfreqs=data.vibfreqs, - # environment="cyclohexane", - # method="garza", - # ) - # assert (solv_entropy - gas_entropy) / constants.calorie == pytest.approx( - # -12.3, abs=constants.kilo / 298.15 - # ) - # solv_entropy = rx.thermo.calc_entropy( - # data.atommasses, - # data.atomnos, - # data.atomcoords, - # moments=moments, - # symmetry_number=symmetry_number, - # vibfreqs=data.vibfreqs, - # environment="n-hexane", - # method="garza", - # ) - # assert (solv_entropy - gas_entropy) / constants.calorie == pytest.approx( - # -12.7, abs=constants.kilo / 298.15 - # ) - # solv_entropy = rx.thermo.calc_entropy( - # data.atommasses, - # data.atomnos, - # data.atomcoords, - # moments=moments, - # symmetry_number=symmetry_number, - # vibfreqs=data.vibfreqs, - # environment="chloroform", - # method="garza", - # ) - # assert (solv_entropy - gas_entropy) / constants.calorie == pytest.approx( - # -19.4, abs=constants.kilo / 298.15 - # ) def test_translational_entropy_liquid_phase(): @@ -238,9 +173,6 @@ def test_translational_entropy_liquid_phase(): free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato" ) - # assert free_volume / (constants.angstrom ** 3 * constants.N_A) == pytest.approx( - # 0.0993, 1.13105e-1 - # ) assert rx.thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords @@ -298,7 +230,6 @@ def test_translational_entropy_liquid_phase(): data.atomnos, data.atomcoords, full_output=True, method="izato" ) assert err < 0.263 - # assert cav_volume == pytest.approx(77.98, 7e-2) assert vdw_volume == pytest.approx(53.66, 8e-2) free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato" @@ -331,7 +262,6 @@ def test_translational_entropy_liquid_phase(): ) assert err < 0.263 assert cav_volume == pytest.approx(100.25, 7e-2) - # assert vdw_volume == pytest.approx(77.97, 1.656e-1) free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato" ) @@ -623,9 +553,6 @@ def test_translational_entropy_liquid_phase(): free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato" ) - # assert free_volume / (constants.angstrom ** 3 * constants.N_A) == pytest.approx( - # 0.143, 1e-1 - # ) assert rx.thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(159.4036577560442, 5e-2) @@ -655,9 +582,6 @@ def test_translational_entropy_liquid_phase(): free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato" ) - # assert free_volume / (constants.angstrom ** 3 * constants.N_A) == pytest.approx( - # 0.183, 7e-2 - # ) assert rx.thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(163.10201307782876, 1e-2) @@ -809,7 +733,6 @@ def test_translational_entropy_liquid_phase(): vdw_volume, cav_volume, err = coords.get_molecular_volume( data.atomnos, data.atomcoords, full_output=True, method="izato" ) - # assert err < 0.263 assert cav_volume == pytest.approx(156.61, 8e-2) assert vdw_volume == pytest.approx(112.34, 9e-2) free_volume = rx.thermo._solv.molar_free_volume( diff --git a/tests/test_tunnel.py b/tests/test_tunnel.py index 73cba6ed..7c24023c 100644 --- a/tests/test_tunnel.py +++ b/tests/test_tunnel.py @@ -9,7 +9,7 @@ def test_wigner_tunneling_corrections_are_correct(): """Ensure Wigner tunneling values are correct.""" - with pytest.raises(ValueError): + with pytest.raises(ValueError): # noqa: PT011 rx.tunnel.wigner(0.0) assert rx.tunnel.wigner(0.1) == pytest.approx(1.0, 1e-8) @@ -26,10 +26,10 @@ def test_wigner_tunneling_corrections_are_correct(): def test_eckart_tunneling_corrections_are_correct(): """Ensure Eckart tunneling values are correct.""" - with pytest.raises(ValueError): + with pytest.raises(ValueError): # noqa: PT011 rx.tunnel.eckart(0.0, 15781.6) - with pytest.raises(ValueError): + with pytest.raises(ValueError): # noqa: PT011 rx.tunnel.eckart(0.0, 56813.61, 94689.35) # values below are at the lower limit for which Eckart is computable @@ -48,12 +48,12 @@ def test_eckart_tunneling_corrections_are_correct(): def test_eckart_is_symmetric(): """Ensure Eckart has symmetry under interchange of H1 and H2.""" vibfreq = 3e3 - H1 = 1e4 - H2 = 10 * H1 + H1 = 1e4 # noqa: N806 + H2 = 10 * H1 # noqa: N806 assert rx.tunnel.eckart(vibfreq, H1, H2) == rx.tunnel.eckart(vibfreq, H2, H1) -def test_low_level_eckart_against_johnston1962(): +def test_low_level_eckart_against_johnston1962(): # noqa: C901 """Reproduce all values from Table 1 of doi:10.1021/j100809a040.""" us = [2, 3, 4, 5, 6, 8, 10, 12, 16] # columns @@ -65,63 +65,63 @@ def test_low_level_eckart_against_johnston1962(): # examples. gammas = [1.16, 1.25, 1.34, 1.44, 1.55, 1.80, 2.09, 2.42, 3.26] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 0.5) == pytest.approx(gamma, 2e-2) gammas = [1.13, 1.21, 1.29, 1.38, 1.47, 1.68, 1.93, 2.22, 2.94] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 0.5, 1) == pytest.approx(gamma, 2e-2) gammas = [1.09, 1.14, 1.20, 1.27, 1.34, 1.51, 1.71, 1.94, 2.53] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 0.5, 2) == pytest.approx(gamma, 9e-3) gammas = [1.04, 1.07, 1.11, 1.16, 1.22, 1.35, 1.50, 1.69, 2.16] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 0.5, 4) == pytest.approx(gamma, 1e-2) gammas = [0.99, 1.00, 1.03, 1.06, 1.11, 1.21, 1.34, 1.49, 1.88] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 0.5, 8) == pytest.approx(gamma, 9e-3) gammas = [0.96, 0.97, 0.99, 1.02, 1.06, 1.15, 1.26, 1.40, 1.76] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 0.5, 12) == pytest.approx(gamma, 8e-3) gammas = [0.94, 0.95, 0.97, 0.99, 1.02, 1.11, 1.22, 1.35, 1.68] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 0.5, 16) == pytest.approx(gamma, 8e-3) gammas = [0.93, 0.94, 0.95, 0.97, 1.00, 1.08, 1.19, 1.31, 1.64] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 0.5, 20) == pytest.approx(gamma, 1e-2) gammas = [1.27, 1.43, 1.62, 1.83, 2.09, 2.72, 3.56, 4.68, 8.19] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 1) == pytest.approx(gamma, 2e-2) gammas = [1.21, 1.35, 1.51, 1.71, 1.93, 2.50, 3.26, 4.28, 7.48] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 1, 2) == pytest.approx(gamma, 6e-3) gammas = [1.14, 1.24, 1.37, 1.53, 1.71, 2.16, 2.78, 3.60, 6.16] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 1, 4) == pytest.approx(gamma, 5e-3) gammas = [1.08, 1.16, 1.26, 1.39, 1.54, 1.92, 2.43, 3.12, 5.25] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 1, 8) == pytest.approx(gamma, 5e-3) gammas = [1.06, 1.12, 1.21, 1.33, 1.46, 1.81, 2.28, 2.91, 4.88] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 1, 12) == pytest.approx(gamma, 9e-3) gammas = [1.04, 1.10, 1.18, 1.29, 1.42, 1.75, 2.20, 2.80, 4.66] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 1, 16) == pytest.approx(gamma, 5e-3) gammas = [1.03, 1.08, 1.16, 1.26, 1.39, 1.70, 2.14, 2.72, 4.52] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 1, 20) == pytest.approx(gamma, 7e-3) # The next examples are not in the imaginary region anymore and our @@ -130,47 +130,47 @@ def test_low_level_eckart_against_johnston1962(): # this section. gammas = [1.32, 1.58, 1.91, 2.34, 2.90, 4.55, 7.34, 12.1, 34.0] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 2) == pytest.approx(gamma, 4e-3) gammas = [1.26, 1.47, 1.77, 2.16, 2.66, 4.20, 6.85, 11.4, 33.4] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 2, 4) == pytest.approx(gamma, 5e-3) gammas = [1.19, 1.36, 1.61, 1.93, 2.36, 3.65, 5.87, 9.69, 28.0] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 2, 8) == pytest.approx(gamma, 4e-3) gammas = [1.16, 1.32, 1.54, 1.84, 2.23, 3.41, 5.44, 8.94, 25.6] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 2, 12) == pytest.approx(gamma, 5e-3) gammas = [1.14, 1.29, 1.50, 1.78, 2.15, 3.27, 5.20, 8.51, 24.2] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 2, 16) == pytest.approx(gamma, 4e-3) gammas = [1.12, 1.27, 1.47, 1.74, 2.10, 3.18, 5.03, 8.22, 23.3] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 2, 20) == pytest.approx(gamma, 4e-3) gammas = [1.30, 1.58, 2.02, 2.69, 3.69, 7.60, 17.3, 42.4, 304] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 4, 4) == pytest.approx(gamma, 8e-3) gammas = [1.25, 1.51, 1.93, 2.56, 3.56, 7.57, 18.0, 46.7, 376] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 4, 8) == pytest.approx(gamma, 5e-3) gammas = [1.22, 1.47, 1.86, 2.46, 3.39, 7.16, 17.0, 44.0, 354] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 4, 12) == pytest.approx(gamma, 3e-3) gammas = [1.20, 1.44, 1.81, 2.39, 3.28, 6.88, 16.2, 41.9, 335] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 4, 16) == pytest.approx(gamma, 3e-3) gammas = [1.19, 1.42, 1.78, 2.34, 3.20, 6.68, 15.7, 40.3, 321] - for u, gamma in zip(us, gammas): + for u, gamma in zip(us, gammas): # noqa: B905 assert rx.tunnel._eckart(u, 4, 20) == pytest.approx(gamma, 2e-3) # The examples below have larger tunneling corrections and the precision of @@ -178,41 +178,41 @@ def test_low_level_eckart_against_johnston1962(): # places for most of the examples here. gammas = [1.24, 1.56, 2.04, 2.94, 4.54, 13.8, 57.0, 307] - for u, gamma in zip(us[:-1], gammas): + for u, gamma in zip(us[:-1], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 8, 8) == pytest.approx(gamma, 2e-2) gammas = [1.22, 1.54, 2.04, 2.96, 4.68, 15.4, 71.7, 445] - for u, gamma in zip(us[:-1], gammas): + for u, gamma in zip(us[:-1], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 8, 12) == pytest.approx(gamma, 2e-2) gammas = [1.21, 1.53, 2.02, 2.93, 4.65, 15.6, 74.4, 473] - for u, gamma in zip(us[:-1], gammas): + for u, gamma in zip(us[:-1], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 8, 16) == pytest.approx(gamma, 2e-2) gammas = [1.20, 1.51, 2.00, 2.90, 4.61, 15.5, 74.2, 474] - for u, gamma in zip(us[:-1], gammas): + for u, gamma in zip(us[:-1], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 8, 20) == pytest.approx(gamma, 2e-2) gammas = [1.2, 1.5, 2.1, 3.1, 5.2, 22, 162, 1970] - for u, gamma in zip(us[:-1], gammas): + for u, gamma in zip(us[:-1], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 12, 12) == pytest.approx(gamma, 2e-2) gammas = [1.2, 1.5, 2.1, 3.1, 5.4, 25, 220, 3300] - for u, gamma in zip(us[:-1], gammas): + for u, gamma in zip(us[:-1], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 12, 16) == pytest.approx(gamma, 2e-2) gammas = [1.2, 1.5, 2.1, 3.1, 5.4, 26, 246, 3920] - for u, gamma in zip(us[:-1], gammas): + for u, gamma in zip(us[:-1], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 12, 20) == pytest.approx(gamma, 2e-2) gammas = [1.2, 1.5, 2.1, 3.2, 5.7, 32, 437] - for u, gamma in zip(us[:-2], gammas): + for u, gamma in zip(us[:-2], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 16, 16) == pytest.approx(gamma, 2e-2) gammas = [1.2, 1.5, 2.1, 3.2, 5.9, 37, 616] - for u, gamma in zip(us[:-2], gammas): + for u, gamma in zip(us[:-2], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 16, 20) == pytest.approx(gamma, 2e-2) gammas = [1.2, 1.5, 2.1, 3.2, 6.1, 46, 1150] - for u, gamma in zip(us[:-2], gammas): + for u, gamma in zip(us[:-2], gammas): # noqa: B905 assert rx.tunnel._eckart(u, 20, 20) == pytest.approx(gamma, 4e-2)