chemql-python 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {chemql_python-0.2.0/src/chemql_python.egg-info → chemql_python-0.2.2}/PKG-INFO +6 -7
- {chemql_python-0.2.0 → chemql_python-0.2.2}/README.md +5 -6
- {chemql_python-0.2.0 → chemql_python-0.2.2}/pyproject.toml +1 -1
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/__init__.py +12 -25
- {chemql_python-0.2.0 → chemql_python-0.2.2/src/chemql_python.egg-info}/PKG-INFO +6 -7
- {chemql_python-0.2.0 → chemql_python-0.2.2}/tests/test_public_api.py +1 -1
- {chemql_python-0.2.0 → chemql_python-0.2.2}/tests/test_reactions.py +4 -4
- {chemql_python-0.2.0 → chemql_python-0.2.2}/LICENSE +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/setup.cfg +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/__main__.py +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/data/BondEnergies.json +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/data/MoleculeBonds.json +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/data/Molecules.json +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/data/PeriodicTableJSON.json +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/data/Reactions.json +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql/html/periodic_table.html +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql_python.egg-info/SOURCES.txt +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql_python.egg-info/dependency_links.txt +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql_python.egg-info/entry_points.txt +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql_python.egg-info/requires.txt +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/src/chemql_python.egg-info/top_level.txt +0 -0
- {chemql_python-0.2.0 → chemql_python-0.2.2}/tests/test_external_molecule_lookup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chemql-python
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: A chemistry-focused query language and REPL
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -163,18 +163,17 @@ add catalyst "Vanadium oxide"
|
|
|
163
163
|
remove catalyst "Vanadium oxide"
|
|
164
164
|
conditions
|
|
165
165
|
react N2 3H2
|
|
166
|
-
balance O2 + H2 -> H2O
|
|
167
|
-
balance O2 + H2 <-> H2O
|
|
166
|
+
balance O2 + H2 -> H2O
|
|
167
|
+
balance O2 + H2 <-> H2O
|
|
168
168
|
```
|
|
169
169
|
|
|
170
170
|
Temperature accepts `C`, `F`, or `K`; pressure accepts `Pa`, `N/m^2`, `Nm^-2`, `bar`, or `atm`. The keywords `standard` and `room` are also accepted.
|
|
171
171
|
|
|
172
172
|
`balance` accepts chemical formulas on each side, separated by `+`. It returns
|
|
173
173
|
a `Reaction` with the smallest positive integer stoichiometric coefficients.
|
|
174
|
-
The
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
`balance_stoichiometry(reactants, products, reversible=None)`.
|
|
174
|
+
The arrow determines reaction direction: `->` is irreversible and `<->` is
|
|
175
|
+
reversible. `//` begins a comment, as it does elsewhere in ChemQL. The function
|
|
176
|
+
API is `balance_stoichiometry(reactants, products, reversible=None)`.
|
|
178
177
|
|
|
179
178
|
## Operators
|
|
180
179
|
|
|
@@ -151,18 +151,17 @@ add catalyst "Vanadium oxide"
|
|
|
151
151
|
remove catalyst "Vanadium oxide"
|
|
152
152
|
conditions
|
|
153
153
|
react N2 3H2
|
|
154
|
-
balance O2 + H2 -> H2O
|
|
155
|
-
balance O2 + H2 <-> H2O
|
|
154
|
+
balance O2 + H2 -> H2O
|
|
155
|
+
balance O2 + H2 <-> H2O
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
Temperature accepts `C`, `F`, or `K`; pressure accepts `Pa`, `N/m^2`, `Nm^-2`, `bar`, or `atm`. The keywords `standard` and `room` are also accepted.
|
|
159
159
|
|
|
160
160
|
`balance` accepts chemical formulas on each side, separated by `+`. It returns
|
|
161
161
|
a `Reaction` with the smallest positive integer stoichiometric coefficients.
|
|
162
|
-
The
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
`balance_stoichiometry(reactants, products, reversible=None)`.
|
|
162
|
+
The arrow determines reaction direction: `->` is irreversible and `<->` is
|
|
163
|
+
reversible. `//` begins a comment, as it does elsewhere in ChemQL. The function
|
|
164
|
+
API is `balance_stoichiometry(reactants, products, reversible=None)`.
|
|
166
165
|
|
|
167
166
|
## Operators
|
|
168
167
|
|
|
@@ -1075,23 +1075,16 @@ def balance_stoichiometry(reactants, products, reversible=None):
|
|
|
1075
1075
|
|
|
1076
1076
|
|
|
1077
1077
|
def _execute_balance_command(text):
|
|
1078
|
+
text = text.split("//", 1)[0].rstrip()
|
|
1078
1079
|
match = re.fullmatch(
|
|
1079
|
-
r"\s*balance\s+(.+?)\s*(<->|->)\s*(.+?)"
|
|
1080
|
-
r"(?:\s*//\s*(reversible|irreversible)\s*)?",
|
|
1080
|
+
r"\s*balance\s+(.+?)\s*(<->|->)\s*(.+?)\s*",
|
|
1081
1081
|
text,
|
|
1082
1082
|
re.IGNORECASE,
|
|
1083
1083
|
)
|
|
1084
1084
|
if not match:
|
|
1085
|
-
raise ValueError(
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
)
|
|
1089
|
-
reactants, arrow, products, direction = match.groups()
|
|
1090
|
-
reversible = (
|
|
1091
|
-
direction.lower() == "reversible"
|
|
1092
|
-
if direction
|
|
1093
|
-
else arrow == "<->"
|
|
1094
|
-
)
|
|
1085
|
+
raise ValueError("Usage: balance <reactants> ->|<-> <products>")
|
|
1086
|
+
reactants, arrow, products = match.groups()
|
|
1087
|
+
reversible = arrow == "<->"
|
|
1095
1088
|
return balance_stoichiometry(reactants, products, reversible)
|
|
1096
1089
|
|
|
1097
1090
|
|
|
@@ -1723,13 +1716,6 @@ def find_endblock(lines, start):
|
|
|
1723
1716
|
raise SyntaxError("Missing `[endblock]`")
|
|
1724
1717
|
|
|
1725
1718
|
def remove_comments(line):
|
|
1726
|
-
if re.fullmatch(
|
|
1727
|
-
r"\s*balance\b.*//\s*(?:reversible|irreversible)\s*",
|
|
1728
|
-
line,
|
|
1729
|
-
re.IGNORECASE,
|
|
1730
|
-
):
|
|
1731
|
-
return line
|
|
1732
|
-
|
|
1733
1719
|
in_quote = None
|
|
1734
1720
|
escaped = False
|
|
1735
1721
|
|
|
@@ -2751,15 +2737,15 @@ HELP = """\033[1;36mChemql - Python Chemistry Query Language\033[0m
|
|
|
2751
2737
|
set catalysts
|
|
2752
2738
|
conditions
|
|
2753
2739
|
react N2 3H2
|
|
2754
|
-
balance O2 + H2 -> H2O
|
|
2755
|
-
balance O2 + H2 <-> H2O
|
|
2740
|
+
balance O2 + H2 -> H2O
|
|
2741
|
+
balance O2 + H2 <-> H2O
|
|
2756
2742
|
|
|
2757
2743
|
Temperature accepts C, F, or K. Pressure accepts Pa, N/m^2, Nm^-2, or bar.
|
|
2758
2744
|
`standard` means 0 C and 100000 Pa; `room` means 25 C and 101325 Pa.
|
|
2759
2745
|
Unset values appear as `Not Set` in `conditions`.
|
|
2760
2746
|
Reaction matching allows 5 K temperature and 5% pressure tolerance.
|
|
2761
2747
|
`balance` returns a Reaction with the smallest positive integer coefficients.
|
|
2762
|
-
|
|
2748
|
+
The `->` arrow is irreversible; `<->` is reversible. `//` starts a comment.
|
|
2763
2749
|
|
|
2764
2750
|
\033[1;33mRESULTS\033[0m
|
|
2765
2751
|
\033[1mfirst\033[0m
|
|
@@ -3213,7 +3199,7 @@ def main():
|
|
|
3213
3199
|
"-v",
|
|
3214
3200
|
"--version",
|
|
3215
3201
|
action="version",
|
|
3216
|
-
version="0.2.
|
|
3202
|
+
version="0.2.2",
|
|
3217
3203
|
)
|
|
3218
3204
|
|
|
3219
3205
|
args = parser.parse_args()
|
|
@@ -3249,8 +3235,9 @@ def run_interactive():
|
|
|
3249
3235
|
except EOFError:
|
|
3250
3236
|
print("\n\033[34mUse \033[1mCTRL+C\033[22m or type '\033[1mexit\033[22m' to exit\033[0m")
|
|
3251
3237
|
continue
|
|
3252
|
-
|
|
3253
|
-
|
|
3238
|
+
if first_line.strip() == "":
|
|
3239
|
+
continue
|
|
3240
|
+
elif first_line.strip() == "exit":
|
|
3254
3241
|
break
|
|
3255
3242
|
|
|
3256
3243
|
elif first_line.strip() in ("?", "help"):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chemql-python
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: A chemistry-focused query language and REPL
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -163,18 +163,17 @@ add catalyst "Vanadium oxide"
|
|
|
163
163
|
remove catalyst "Vanadium oxide"
|
|
164
164
|
conditions
|
|
165
165
|
react N2 3H2
|
|
166
|
-
balance O2 + H2 -> H2O
|
|
167
|
-
balance O2 + H2 <-> H2O
|
|
166
|
+
balance O2 + H2 -> H2O
|
|
167
|
+
balance O2 + H2 <-> H2O
|
|
168
168
|
```
|
|
169
169
|
|
|
170
170
|
Temperature accepts `C`, `F`, or `K`; pressure accepts `Pa`, `N/m^2`, `Nm^-2`, `bar`, or `atm`. The keywords `standard` and `room` are also accepted.
|
|
171
171
|
|
|
172
172
|
`balance` accepts chemical formulas on each side, separated by `+`. It returns
|
|
173
173
|
a `Reaction` with the smallest positive integer stoichiometric coefficients.
|
|
174
|
-
The
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
`balance_stoichiometry(reactants, products, reversible=None)`.
|
|
174
|
+
The arrow determines reaction direction: `->` is irreversible and `<->` is
|
|
175
|
+
reversible. `//` begins a comment, as it does elsewhere in ChemQL. The function
|
|
176
|
+
API is `balance_stoichiometry(reactants, products, reversible=None)`.
|
|
178
177
|
|
|
179
178
|
## Operators
|
|
180
179
|
|
|
@@ -20,16 +20,16 @@ def test_balance_stoichiometry_returns_minimal_reaction_coefficients():
|
|
|
20
20
|
] == [3, 2, 1, 6]
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def
|
|
23
|
+
def test_balance_syntax_infers_direction_from_arrow_and_honors_comments(capsys):
|
|
24
24
|
chemql.process_lines(["balance O2 + H2 -> H2O //reversible"])
|
|
25
|
-
assert "1 O₂ + 2 H₂
|
|
25
|
+
assert "1 O₂ + 2 H₂ → 2 H₂O" in capsys.readouterr().out
|
|
26
26
|
|
|
27
27
|
reaction = chemql.execute_query_text(
|
|
28
28
|
"balance O2 + H2 <-> H2O //irreversible"
|
|
29
29
|
)
|
|
30
30
|
assert isinstance(reaction, chemql.Reaction)
|
|
31
|
-
assert reaction.reversible is
|
|
32
|
-
assert "1 O₂ + 2 H₂
|
|
31
|
+
assert reaction.reversible is True
|
|
32
|
+
assert "1 O₂ + 2 H₂ ⇌ 2 H₂O" in str(reaction)
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
def test_balance_stoichiometry_rejects_invalid_formula():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|