From 687b1e1107c422f8cc44698e5324944188f96f30 Mon Sep 17 00:00:00 2001 From: Christian Hill Date: Thu, 13 Jul 2023 16:58:13 +0200 Subject: [PATCH] Fix deprecated open_text call in atom_data.py and remind zsh users how to install pyvalem in dev environment --- README.rst | 6 ++++++ src/pyvalem/atom_data.py | 8 ++++++-- src/pyvalem/states/atomic_term_symbol.py | 2 +- src/pyvalem/states/molecular_term_symbol.py | 1 - src/pyvalem/states/rotational_state.py | 1 - tests/test_atomic_configurations.py | 1 - tests/test_racah_symbols.py | 1 - tests/test_stateful_species.py | 2 -- tests/test_vibrational_state.py | 2 -- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 8e5a5cf..01e531c 100644 --- a/README.rst +++ b/README.rst @@ -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) diff --git a/src/pyvalem/atom_data.py b/src/pyvalem/atom_data.py index eb62772..0f2efdd 100644 --- a/src/pyvalem/atom_data.py +++ b/src/pyvalem/atom_data.py @@ -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: @@ -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 = [ diff --git a/src/pyvalem/states/atomic_term_symbol.py b/src/pyvalem/states/atomic_term_symbol.py index e6f6e34..8f864d8 100644 --- a/src/pyvalem/states/atomic_term_symbol.py +++ b/src/pyvalem/states/atomic_term_symbol.py @@ -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: diff --git a/src/pyvalem/states/molecular_term_symbol.py b/src/pyvalem/states/molecular_term_symbol.py index e1959f1..c26135b 100644 --- a/src/pyvalem/states/molecular_term_symbol.py +++ b/src/pyvalem/states/molecular_term_symbol.py @@ -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: diff --git a/src/pyvalem/states/rotational_state.py b/src/pyvalem/states/rotational_state.py index 2d8f75a..26220c0 100644 --- a/src/pyvalem/states/rotational_state.py +++ b/src/pyvalem/states/rotational_state.py @@ -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": diff --git a/tests/test_atomic_configurations.py b/tests/test_atomic_configurations.py index e03a590..fa91b67 100644 --- a/tests/test_atomic_configurations.py +++ b/tests/test_atomic_configurations.py @@ -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") diff --git a/tests/test_racah_symbols.py b/tests/test_racah_symbols.py index e025fbc..cc73bc7 100644 --- a/tests/test_racah_symbols.py +++ b/tests/test_racah_symbols.py @@ -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]1") self.assertEqual(r0.principal, 5) diff --git a/tests/test_stateful_species.py b/tests/test_stateful_species.py index 13fa69d..05e59ec 100644 --- a/tests/test_stateful_species.py +++ b/tests/test_stateful_species.py @@ -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") @@ -45,7 +44,6 @@ def test_stateful_species_parsing(self): self.assertEqual(ss4.states[0].html, "3p'[3/2]1") def test_stateful_species_equality(self): - ss1 = StatefulSpecies("HCl v=2;J=0") ss2 = StatefulSpecies("HCl J=0;v=2") diff --git a/tests/test_vibrational_state.py b/tests/test_vibrational_state.py index 8860455..95d2470 100644 --- a/tests/test_vibrational_state.py +++ b/tests/test_vibrational_state.py @@ -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") @@ -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")