Skip to content

Commit 37cca8d

Browse files
Correct some user-facing types
1 parent b1c7456 commit 37cca8d

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

overreact/api.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010

11-
from __future__ import annotations
11+
from typing import Union
1212

1313
__all__ = [
1414
"get_k",
@@ -258,7 +258,7 @@ def get_entropies(
258258
return np.array(entropies)
259259

260260

261-
def _check_qrrho(qrrho: bool | tuple[bool, bool]) -> tuple[bool, bool]:
261+
def _check_qrrho(qrrho: Union[bool, tuple[bool, bool]]) -> tuple[bool, bool]:
262262
"""Get options for QRRHO for both enthalpy and entropy.
263263
264264
Parameters
@@ -306,7 +306,7 @@ def get_freeenergies(
306306
bias: float = 0.0,
307307
environment: Optional[Text] = None,
308308
method: Text = "standard",
309-
qrrho: bool | tuple[bool, bool] = True,
309+
qrrho: Union[bool, tuple[bool, bool]] = True,
310310
temperature: float = 298.15,
311311
pressure: float = constants.atm,
312312
):
@@ -399,7 +399,7 @@ def get_k(
399399
compounds: Optional[dict] = None,
400400
bias: float = 0.0,
401401
tunneling: Text = "eckart",
402-
qrrho: bool | tuple[bool, bool] = True,
402+
qrrho: Union[bool, tuple[bool, bool]] = True,
403403
scale: Text = "l mol-1 s-1",
404404
temperature: float = 298.15,
405405
pressure: float = constants.atm,

overreact/core.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
"""Module dedicated to parsing and modeling of chemical reaction networks."""
44

55

6-
from __future__ import annotations
7-
86
__all__ = ["Scheme", "parse_reactions"]
97

108

119
import itertools
1210
import re
13-
from typing import NamedTuple, Sequence, Text
11+
from typing import NamedTuple, Sequence, Text, Union
1412

1513
import numpy as np
1614

@@ -52,7 +50,7 @@ class Scheme(NamedTuple):
5250
}
5351

5452

55-
def _check_scheme(scheme_or_text: Scheme | Text) -> Scheme:
53+
def _check_scheme(scheme_or_text: Union[Scheme, Text]) -> Scheme:
5654
"""Interface transparently between strings and schemes.
5755
5856
Parameters
@@ -400,7 +398,7 @@ def is_transition_state(name):
400398
return False
401399

402400

403-
def parse_reactions(text: Text | Sequence[Text]) -> Scheme:
401+
def parse_reactions(text: Union[Text, Sequence[Text]]) -> Scheme:
404402
"""
405403
Parse a kinetic model as a chemical reaction scheme.
406404

overreact/rates.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from __future__ import annotations
77

8-
from typing import Optional
8+
from typing import Optional, Union
99

1010
__all__ = ["eyring"]
1111

@@ -281,9 +281,9 @@ def convert_rate_constant(
281281

282282

283283
def eyring(
284-
delta_freeenergy: float | np.ndarray,
284+
delta_freeenergy: Union[float, np.ndarray],
285285
molecularity: Optional[int] = None,
286-
temperature: float | np.ndarray = 298.15,
286+
temperature: Union[float, np.ndarray] = 298.15,
287287
pressure: float = constants.atm,
288288
volume: Optional[float] = None,
289289
):

overreact/thermo/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
import logging
12-
from typing import Optional
12+
from typing import Optional, Union
1313

1414
import numpy as np
1515
from scipy.misc import derivative
@@ -604,9 +604,9 @@ def get_delta(transform, property):
604604

605605

606606
def equilibrium_constant(
607-
delta_freeenergy: float | np.ndarray,
608-
delta_moles: Optional[int | np.ndarray] = None,
609-
temperature: float | np.ndarray = 298.15,
607+
delta_freeenergy: Union[float, np.ndarray],
608+
delta_moles: Optional[Union[int, np.ndarray]] = None,
609+
temperature: Union[float, np.ndarray] = 298.15,
610610
pressure: float = constants.atm,
611611
volume: Optional[float] = None,
612612
):
@@ -751,7 +751,7 @@ def change_reference_state(
751751
new_reference: float = 1.0 / constants.liter,
752752
old_reference: Optional[float] = None,
753753
sign: int = 1,
754-
temperature: float | np.ndarray = 298.15,
754+
temperature: Union[float, np.ndarray] = 298.15,
755755
pressure: float = constants.atm,
756756
volume: Optional[float] = None,
757757
):

overreact/tunnel.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
import logging
12-
from typing import Optional
12+
from typing import Optional, Union
1313

1414
import numpy as np
1515
from scipy.integrate import fixed_quad
@@ -53,7 +53,7 @@ def _check_nu(vibfreq: float) -> float:
5353
return np.abs(vibfreq) * constants.c / constants.centi
5454

5555

56-
def wigner(vibfreq: float, temperature: float | np.ndarray = 298.15) -> float:
56+
def wigner(vibfreq: float, temperature: Union[float, np.ndarray] = 298.15) -> float:
5757
"""Calculate the Wigner correction to quantum tunneling.
5858
5959
Parameters
@@ -100,8 +100,8 @@ def eckart(
100100
vibfreq: float,
101101
delta_forward: float,
102102
delta_backward: Optional[float] = None,
103-
temperature: float | np.ndarray = 298.15,
104-
) -> float:
103+
temperature: Union[float, np.ndarray] = 298.15,
104+
) -> Union[float, np.ndarray]:
105105
"""Calculate the Eckart correction to quantum tunneling.
106106
107107
References are

0 commit comments

Comments
 (0)