Skip to content

Commit

Permalink
Fix deprecated open_text call in atom_data.py and remind zsh users ho…
Browse files Browse the repository at this point in the history
…w to install pyvalem in dev environment
  • Loading branch information
xnx committed Jul 13, 2023
1 parent a358627 commit 687b1e1
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
6 changes: 6 additions & 0 deletions README.rst
Expand Up @@ -191,6 +191,12 @@ installed into the virtual environment in editable mode with
pip install -e .[dev]
or on zsh:

.. code-block:: zsh
pip install -e .'[dev]'
The ``[dev]`` extra installs (apart from the package dependencies) also several
development-related packages, such as ``pytest``, ``black``, ``tox`` or ``ipython.``
The tests can then be executed by running (from the project root directory)
Expand Down
8 changes: 6 additions & 2 deletions src/pyvalem/atom_data.py
Expand Up @@ -179,7 +179,9 @@ def float_or_none(f):
# Atom data is from Meija et al., "Atomic weights of the elements 2013
# (IUPAC Technical Report)", Pure Appl. Chem. 88(3), 265-291, 2016.
# See https://ciaaw.org/atomic-weights.htm
with pkg_resources.open_text("pyvalem", "_data_atomic_weights.txt") as fi:
with pkg_resources.files("pyvalem").joinpath("_data_atomic_weights.txt").open(
"r", encoding="utf8"
) as fi:
reader = csv.reader(fi, delimiter=",")
header = ["Symbol", "Name", "Z", "atomic_weight", "atomic_weight_unc"]
for row in reader:
Expand All @@ -199,7 +201,9 @@ def float_or_none(f):
# 030002 (2017); Wang et al., "The Ame2016 atomic mass evaluation (II)",
# Chinese Physics C41, 030003 (2017).
# See http://amdc.impcas.ac.cn/masstables/Ame2016/mass16.txt
with pkg_resources.open_text("pyvalem", "_data_isotope_masses.txt") as fi:
with pkg_resources.files("pyvalem").joinpath("_data_isotope_masses.txt").open(
"r", encoding="utf8"
) as fi:
reader = csv.reader(fi, delimiter=",")
header = ["Z", "A", "Symbol", "mass", "mass_unc", "estimated_flag"]
iso_attribs = [
Expand Down
2 changes: 1 addition & 1 deletion src/pyvalem/states/atomic_term_symbol.py
Expand Up @@ -87,7 +87,7 @@ def html(self):

@property
def latex(self):
latex_chunks = ["{{}}^{{{}}}\mathrm{{{}}}".format(self.Smult, self.Lletter)]
latex_chunks = [r"{{}}^{{{}}}\mathrm{{{}}}".format(self.Smult, self.Lletter)]
if self.parity:
latex_chunks.append("^o")
if self.J is not None:
Expand Down
1 change: 0 additions & 1 deletion src/pyvalem/states/molecular_term_symbol.py
Expand Up @@ -203,7 +203,6 @@ def __init__(self, state_str):
self._parse_state(state_str)

def _parse_state(self, state_str):

try:
components = molecule_term_with_label.parseString(state_str)
except pp.ParseException:
Expand Down
1 change: 0 additions & 1 deletion src/pyvalem/states/rotational_state.py
Expand Up @@ -30,7 +30,6 @@ def __init__(self, state_str):
self._parse_state(state_str)

def _parse_state(self, state_str):

try:
k, v = state_str.split("=")
if k.strip() != "J":
Expand Down
1 change: 0 additions & 1 deletion tests/test_atomic_configurations.py
Expand Up @@ -12,7 +12,6 @@

class AtomicConfigurationTest(unittest.TestCase):
def test_atomic_configuration(self):

c0 = AtomicConfiguration("1s2")
c1 = AtomicConfiguration("1s2.2s2")
c2 = AtomicConfiguration("1s2.2s2.2p6")
Expand Down
1 change: 0 additions & 1 deletion tests/test_racah_symbols.py
Expand Up @@ -9,7 +9,6 @@

class RacahSymbolTest(unittest.TestCase):
def test_racah_symbol(self):

r0 = RacahSymbol("5s'[1/2]_1")
self.assertEqual(r0.html, "5s'[1/2]<sub>1</sub>")
self.assertEqual(r0.principal, 5)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_stateful_species.py
Expand Up @@ -12,7 +12,6 @@

class StatefulSpeciesTest(unittest.TestCase):
def test_stateful_species_parsing(self):

_ = StatefulSpecies("Ar *")
_ = StatefulSpecies("CrH 1sigma2.2sigma1.1pi4.3sigma1; 6SIGMA+")
_ = StatefulSpecies("H(35Cl) J=2")
Expand Down Expand Up @@ -45,7 +44,6 @@ def test_stateful_species_parsing(self):
self.assertEqual(ss4.states[0].html, "3p'[3/2]<sub>1</sub>")

def test_stateful_species_equality(self):

ss1 = StatefulSpecies("HCl v=2;J=0")
ss2 = StatefulSpecies("HCl J=0;v=2")

Expand Down
2 changes: 0 additions & 2 deletions tests/test_vibrational_state.py
Expand Up @@ -70,7 +70,6 @@ def test_generic_excited_vibrational_state(self):
self.assertRaises(VibrationalStateError, VibrationalState, "v=***x")

def test_vibrational_state_equality(self):

v1 = VibrationalState("v1+3v4")
v2 = VibrationalState("ν1+3ν4")
v3 = VibrationalState("3v4+v1")
Expand All @@ -86,7 +85,6 @@ def test_vibrational_state_equality(self):
self.assertNotEqual(v6, v7)

def test_vibrational_state_repr(self):

v1 = VibrationalState("3v1+v3")
v2 = VibrationalState("3ν1+ν3")
self.assertTrue(repr(v1) == repr(v2) == "3ν1+ν3")
Expand Down

0 comments on commit 687b1e1

Please sign in to comment.