diff --git a/README.rst b/README.rst
index b8e3f11..e68c77e 100644
--- a/README.rst
+++ b/README.rst
@@ -140,7 +140,7 @@ As ``Formula``, also ``StatefulSpecies`` have ``html`` and ``latex`` attributes.
\mathrm{Ne}^{+} \; 1s^{2}2s^{2}2p^{5}; \; {}^{2}P_{1/2}
>>> StatefulSpecies('(52Cr)(1H) 1sigma2.2sigma1.1delta2.1pi2; 6SIGMA+; v=0; J=2').html
- '52Cr1H 1σ2.2σ1.1δ2.1π2; 6Σ+; v=0; J=2'
+ '52Cr1H 1σ2.2σ1.1δ2.1π2 6Σ+ v=0 J=2'
Reaction
@@ -155,13 +155,13 @@ separated by ``' -> '``, such as
>>> from pyvalem.reaction import Reaction
>>> reaction = Reaction('He+2 + H -> He+ 3p1 + H+ + hv')
>>> reaction
- He+2 + H → He+ 3p1 + H+ + hν
+ He+2 + H → He+ 3p + H+ + hν
>>> reaction.html
- 'He2+ + H → He+ 3p1 + H+ + hν'
+ 'He2+ + H → He+ 3p + H+ + hν'
>>> print(reaction.latex)
- \mathrm{He}^{2+} + \mathrm{H} \rightarrow \mathrm{He}^{+} \; 3p^{1} + \mathrm{H}^{+} + h\nu
+ \mathrm{He}^{2+} + \mathrm{H} \rightarrow \mathrm{He}^{+} \; 3p + \mathrm{H}^{+} + h\nu
The ``Reaction`` class also watches out for charge balance and stoichiometry
conservation during instantiation.
@@ -216,4 +216,4 @@ Always make sure to format your code before submitting a pull request, by runnin
.. _GitHub: https://github.com/xnx/pyvalem
.. _PyPI: https://pypi.org/project/pyvalem/
-.. _numpydoc: https://numpydoc.readthedocs.io/en/latest/format.html
\ No newline at end of file
+.. _numpydoc: https://numpydoc.readthedocs.io/en/latest/format.html
diff --git a/doc/introduction.rst b/doc/introduction.rst
index 4ccbb44..0295ac9 100644
--- a/doc/introduction.rst
+++ b/doc/introduction.rst
@@ -126,14 +126,14 @@ As ``Formula``, also ``StatefulSpecies`` have ``html`` and ``latex`` attributes.
\mathrm{Ne}^{+} \; 1s^{2}2s^{2}2p^{5}; \; {}^{2}P_{1/2}
>>> StatefulSpecies('(52Cr)(1H) 1sigma2.2sigma1.1delta2.1pi2; 6SIGMA+; v=0; J=2').html
- '52Cr1H 1σ2.2σ1.1δ2.1π2; 6Σ+; v=0; J=2'
+ '52Cr1H 1σ2.2σ1.1δ2.1π2 6Σ+ v=0 J=2'
These two examples render as:
.. raw:: html
- Ne+ 1s22s22p5; 2P1/2
- 52Cr1H 1σ2.2σ1.1δ2.1π2; 6Σ+; v=0; J=2
+ Ne+ 1s22s22p5 2P1/2
+ 52Cr1H 1σ2.2σ1.1δ2.1π2 6Σ+ v=0 J=2
Reaction
@@ -148,13 +148,13 @@ separated by ``' -> '``, such as
>>> from pyvalem.reaction import Reaction
>>> reaction = Reaction('He+2 + H -> He+ 3p1 + H+ + hv')
>>> reaction
- He+2 + H → He+ 3p1 + H+ + hν
+ He+2 + H → He+ 3p + H+ + hν
>>> reaction.html
- 'He2+ + H → He+ 3p1 + H+ + hν'
+ 'He2+ + H → He+ 3p + H+ + hν'
>>> print(reaction.latex)
- \mathrm{He}^{2+} + \mathrm{H} \rightarrow \mathrm{He}^{+} \; 3p^{1} + \mathrm{H}^{+} + h\nu
+ \mathrm{He}^{2+} + \mathrm{H} \rightarrow \mathrm{He}^{+} \; 3p + \mathrm{H}^{+} + h\nu
The ``Reaction`` class also watches out for charge balance and stoichiometry
conservation during instantiation.
diff --git a/doc/reaction.rst b/doc/reaction.rst
index 9140dbb..ae3e6ac 100644
--- a/doc/reaction.rst
+++ b/doc/reaction.rst
@@ -23,7 +23,7 @@ Examples
An HTML representation of the reaction is stored as the ``html`` attribute::
>>> print(r2.html)
- CO v=1 + O2 J=2; X3Σ-g → CO2 + O
+ CO v=1 + O2 J=2 X3Σ-g → CO2 + O
>>> print(r4.html)
C6H5OH + 7O2 → 6CO2 + 3H2O
diff --git a/doc/stateful_species.rst b/doc/stateful_species.rst
index 4088f05..646c594 100644
--- a/doc/stateful_species.rst
+++ b/doc/stateful_species.rst
@@ -26,13 +26,13 @@ An HTML representation is accessible through the ``html`` attribute:
.. code-block:: pycon
>>> print(ss4.html)
- CrH 1σ2.2σ1.1π4.3σ1; 6Σ+
+ CrH 1σ2.2σ1.1π4.3σ1 6Σ+
This example renders as:
.. raw:: html
- CrH 1σ2.2σ1.1π4.3σ1; 6Σ+
+ CrH 1σ2.2σ1.1π4.3σ1 6Σ+
The ``Formula`` object and a list of the parse ``State`` objects are returned by the
@@ -70,4 +70,4 @@ This is checked for:
>>> StatefulSpecies('Li 1s2.2s1; 1s2.2p1')
Traceback (most recent call last):
...
- pyvalem.stateful_species.StatefulSpeciesError: Multiple states of type AtomicConfiguration specified for Li 1s2.2p1;1s2.2s1
+ pyvalem.stateful_species.StatefulSpeciesError: Multiple states of type AtomicConfiguration specified for Li 1s2.2p;1s2.2s
diff --git a/setup.py b/setup.py
index 212d313..65bec1e 100644
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@
setup(
name="pyvalem",
- version="2.5.2",
+ version="2.5.3",
description="A package for managing simple chemical species and states",
long_description=long_description,
long_description_content_type="text/x-rst",
diff --git a/src/pyvalem/reaction.py b/src/pyvalem/reaction.py
index 9c24f55..2df3f57 100644
--- a/src/pyvalem/reaction.py
+++ b/src/pyvalem/reaction.py
@@ -120,7 +120,7 @@ class Reaction:
>>> # HTML attribute
>>> r1.html
- 'CO v=1 + O2 J=2; X3Σ-g → CO2 + O'
+ 'CO v=1 + O2 J=2 X3Σ-g → CO2 + O'
>>> # Consistency checks
>>> Reaction('BeH+ + I2 <-> BeI + HI')
diff --git a/src/pyvalem/stateful_species.py b/src/pyvalem/stateful_species.py
index f349b60..02610b2 100644
--- a/src/pyvalem/stateful_species.py
+++ b/src/pyvalem/stateful_species.py
@@ -139,7 +139,7 @@ def verify_multiple_key_value_pairs(self):
def html(self):
if not self.states:
return self.formula.html
- return "{} {}".format(self.formula.html, "; ".join(s.html for s in self.states))
+ return "{} {}".format(self.formula.html, " ".join(s.html for s in self.states))
@property
def latex(self):
diff --git a/src/pyvalem/states/atomic_configuration.py b/src/pyvalem/states/atomic_configuration.py
index 06a914f..b13bc65 100644
--- a/src/pyvalem/states/atomic_configuration.py
+++ b/src/pyvalem/states/atomic_configuration.py
@@ -63,7 +63,7 @@ class AtomicOrbital:
l : int, optional
The azimuthal quantum number (0, 1, 2, ..., n-1)
At least one of {`l`, `lletter`} must be passed.
- nocc : int, default: 0
+ nocc : int, default: 1
Number of occupied electrons.
lletter : str, optional
The letter corresponding to l: 's', 'p', 'd', ... for l = 0, 1, 2, ...
@@ -115,7 +115,9 @@ def __init__(self, n, l=None, nocc=0, lletter=None):
self._validate_atomic_orbital()
def __repr__(self):
- return "{}{}{}".format(self.n, self.lletter, self.nocc)
+ if self.nocc != 1:
+ return "{}{}{}".format(self.n, self.lletter, self.nocc)
+ return "{}{}".format(self.n, self.lletter)
@property
def html(self):
@@ -125,7 +127,9 @@ def html(self):
-------
str
"""
- return "{}{}{}".format(self.n, self.lletter, self.nocc)
+ if self.nocc != 1:
+ return "{}{}{}".format(self.n, self.lletter, self.nocc)
+ return "{}{}".format(self.n, self.lletter)
@property
def latex(self):
@@ -135,7 +139,9 @@ def latex(self):
-------
str
"""
- return "{}{}^{{{}}}".format(self.n, self.lletter, self.nocc)
+ if self.nocc != 1:
+ return "{}{}^{{{}}}".format(self.n, self.lletter, self.nocc)
+ return "{}{}".format(self.n, self.lletter)
def _validate_atomic_orbital(self):
"""Validator method for the atomic orbital class.
@@ -209,11 +215,11 @@ class AtomicConfiguration(State):
(3, 1, 1)
>>> repr(ac1)
- '1s2.2s2.2p6.3p1'
+ '1s2.2s2.2p6.3p'
>>> ac2 = AtomicConfiguration("[Ne].3p")
>>> repr(ac2)
- '1s2.2s2.2p6.3p1'
+ '1s2.2s2.2p6.3p'
"""
def __init__(self, state_str):
diff --git a/tests/test_atomic_configurations.py b/tests/test_atomic_configurations.py
index e908927..f994b64 100644
--- a/tests/test_atomic_configurations.py
+++ b/tests/test_atomic_configurations.py
@@ -18,7 +18,7 @@ def test_atomic_configuration(self):
c2 = AtomicConfiguration("1s2.2s2.2p6")
c3 = AtomicConfiguration("1s2.2s2.2p6.3s2.3d10")
c4 = AtomicConfiguration("[He].2s1")
- c5 = AtomicConfiguration("2s2.2p1.3s1")
+ c5 = AtomicConfiguration("2s2.2p1.3s")
self.assertRaises(AtomicConfigurationError, AtomicConfiguration, "s4.w2")
self.assertRaises(AtomicConfigurationError, AtomicConfiguration, "1s 2.2s2")
@@ -71,8 +71,8 @@ def test_excited_atomic_configuration(self):
def test_atomic_configuration_repr(self):
c1 = AtomicConfiguration("1s2.2s2.2p6.3s2.3p6.4s2.3d")
c2 = AtomicConfiguration("[Ar].4s2.3d1")
- self.assertEqual(repr(c1), "1s2.2s2.2p6.3s2.3p6.4s2.3d1")
- self.assertEqual(repr(c2), "1s2.2s2.2p6.3s2.3p6.4s2.3d1")
+ self.assertEqual(repr(c1), "1s2.2s2.2p6.3s2.3p6.4s2.3d")
+ self.assertEqual(repr(c2), "1s2.2s2.2p6.3s2.3p6.4s2.3d")
def test_atomic_configuration_default_nocc(self):
c1 = AtomicConfiguration("1s")
diff --git a/tests/test_reaction.py b/tests/test_reaction.py
index dd3d274..c1c2dbc 100644
--- a/tests/test_reaction.py
+++ b/tests/test_reaction.py
@@ -68,7 +68,7 @@ def test_reaction_parsing(self):
self.assertEqual(r2.reactants[1][1].states[1].__repr__(), "X(3Σ-g)")
self.assertEqual(
r2.html,
- "CO v=1 + O2 J=2; "
+ "CO v=1 + O2 J=2 "
"X3Σ-g → "
"CO2 + O",
)
diff --git a/tests/test_stateful_species.py b/tests/test_stateful_species.py
index 23f4800..6b33137 100644
--- a/tests/test_stateful_species.py
+++ b/tests/test_stateful_species.py
@@ -68,7 +68,7 @@ def test_atomic_configuration_verification(self):
self.assertTrue(ss1.verify_atomic_configuration())
ss2 = StatefulSpecies("Ar+ 1s2.2s2.2p6.3s2.3p6")
ss3 = StatefulSpecies("Ar+ [Ne].3s2.3p6")
- ss4 = StatefulSpecies("Ar+ [Ne].3s2.3p6.4s1")
+ ss4 = StatefulSpecies("Ar+ [Ne].3s2.3p6.4s")
for ss in (ss2, ss3, ss4):
self.assertRaises(StatefulSpeciesError, ss.verify_atomic_configuration)
@@ -97,10 +97,10 @@ def test_stateful_species_repr(self):
self.assertEqual(repr(ss2), "(235U) 3*;l=0;n=1")
for ss_text in ["C+ 4P;2s2.2p1", "C+ 2s2.2p1;4P"]:
- self.assertEqual(repr(StatefulSpecies(ss_text)), "C+ 2s2.2p1;4P")
+ self.assertEqual(repr(StatefulSpecies(ss_text)), "C+ 2s2.2p;4P")
for ss_text in ["C+ 2P;2s2.2p1", "C+ 2s2.2p1;2P"]:
- self.assertEqual(repr(StatefulSpecies(ss_text)), "C+ 2s2.2p1;2P")
+ self.assertEqual(repr(StatefulSpecies(ss_text)), "C+ 2s2.2p;2P")
if __name__ == "__main__":