chemql-python 0.2.0__tar.gz → 0.2.1__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.
Files changed (24) hide show
  1. {chemql_python-0.2.0/src/chemql_python.egg-info → chemql_python-0.2.1}/PKG-INFO +6 -7
  2. {chemql_python-0.2.0 → chemql_python-0.2.1}/README.md +5 -6
  3. {chemql_python-0.2.0 → chemql_python-0.2.1}/pyproject.toml +1 -1
  4. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/__init__.py +9 -23
  5. {chemql_python-0.2.0 → chemql_python-0.2.1/src/chemql_python.egg-info}/PKG-INFO +6 -7
  6. {chemql_python-0.2.0 → chemql_python-0.2.1}/tests/test_public_api.py +1 -1
  7. {chemql_python-0.2.0 → chemql_python-0.2.1}/tests/test_reactions.py +4 -4
  8. {chemql_python-0.2.0 → chemql_python-0.2.1}/LICENSE +0 -0
  9. {chemql_python-0.2.0 → chemql_python-0.2.1}/setup.cfg +0 -0
  10. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/__main__.py +0 -0
  11. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/data/BondEnergies.json +0 -0
  12. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/data/MoleculeBonds.json +0 -0
  13. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/data/Molecules.json +0 -0
  14. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/data/PeriodicTableJSON.json +0 -0
  15. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/data/Reactions.json +0 -0
  16. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +0 -0
  17. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +0 -0
  18. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql/html/periodic_table.html +0 -0
  19. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql_python.egg-info/SOURCES.txt +0 -0
  20. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql_python.egg-info/dependency_links.txt +0 -0
  21. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql_python.egg-info/entry_points.txt +0 -0
  22. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql_python.egg-info/requires.txt +0 -0
  23. {chemql_python-0.2.0 → chemql_python-0.2.1}/src/chemql_python.egg-info/top_level.txt +0 -0
  24. {chemql_python-0.2.0 → chemql_python-0.2.1}/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.0
3
+ Version: 0.2.1
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 //reversible
167
- balance O2 + H2 <-> H2O //irreversible
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 optional `//reversible` and `//irreversible` annotations set the returned
175
- reaction direction; without an annotation, `->` is irreversible and `<->` is
176
- reversible. The function API is
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 //reversible
155
- balance O2 + H2 <-> H2O //irreversible
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 optional `//reversible` and `//irreversible` annotations set the returned
163
- reaction direction; without an annotation, `->` is irreversible and `<->` is
164
- reversible. The function API is
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
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chemql-python"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "A chemistry-focused query language and REPL"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -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
- "Usage: balance <reactants> ->|<-> <products> "
1087
- "[//reversible|//irreversible]"
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 //reversible
2755
- balance O2 + H2 <-> H2O //irreversible
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
- Direction annotations override the arrow: `//reversible` or `//irreversible`.
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.0",
3202
+ version="0.2.1",
3217
3203
  )
3218
3204
 
3219
3205
  args = parser.parse_args()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chemql-python
3
- Version: 0.2.0
3
+ Version: 0.2.1
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 //reversible
167
- balance O2 + H2 <-> H2O //irreversible
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 optional `//reversible` and `//irreversible` annotations set the returned
175
- reaction direction; without an annotation, `->` is irreversible and `<->` is
176
- reversible. The function API is
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
 
@@ -25,4 +25,4 @@ def test_cli_version_option_prints_version(monkeypatch, capsys, option):
25
25
  chemql.main()
26
26
 
27
27
  assert exception.value.code == 0
28
- assert capsys.readouterr().out == "0.2.0\n"
28
+ assert capsys.readouterr().out == "0.2.1\n"
@@ -20,16 +20,16 @@ def test_balance_stoichiometry_returns_minimal_reaction_coefficients():
20
20
  ] == [3, 2, 1, 6]
21
21
 
22
22
 
23
- def test_balance_syntax_preserves_direction_annotation(capsys):
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₂ ⇌ 2 H₂O" in capsys.readouterr().out
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 False
32
- assert "1 O₂ + 2 H₂ → 2 H₂O" in str(reaction)
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