Skip to content

Commit

Permalink
Merge pull request #174 from bjodah/fix-gh171-gh172
Browse files Browse the repository at this point in the history
  • Loading branch information
bjodah authored Jul 5, 2020
2 parents f307afd + 0488c60 commit c03a0d2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 55 deletions.
17 changes: 0 additions & 17 deletions .circleci/config.yml

This file was deleted.

27 changes: 0 additions & 27 deletions appveyor.yml

This file was deleted.

8 changes: 4 additions & 4 deletions chempy/util/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def _get_formula_parser():
# element = Word(alphas.upper(), alphas.lower())
# or if you want to be more specific, use this Regex
element = Regex(
r"A[cglmrstu]|B[aehikr]?|C[adeflmorsu]?|D[bsy]|E[rsu]|F[emr]?|"
"G[ade]|H[efgos]?|I[nr]?|Kr?|L[airu]|M[dgnot]|N[abdeiop]?|"
"Os?|P[abdmortu]?|R[abefghnu]|S[bcegimnr]?|T[abcehilm]|"
"Uu[bhopqst]|U|V|W|Xe|Yb?|Z[nr]")
r"A[cglmrstu]|B[aehikr]?|C[adeflmnorsu]?|D[bsy]|E[rsu]|F[elmr]?|"
"G[ade]|H[efgos]?|I[nr]?|Kr?|L[airuv]|M[cdgnot]|N[abdehiop]?|"
"O[gs]?|P[abdmortu]?|R[abefghnu]|S[bcegimnr]?|T[abcehilms]|"
"U|V|W|Xe|Yb?|Z[nr]")

# forward declare 'formula' so it can be used in definition of 'term'
formula = Forward()
Expand Down
10 changes: 5 additions & 5 deletions chempy/util/periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn',
'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf',
'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds',
'Rg', 'Cn', 'Uut', 'Fl', 'Uup', 'Lv', 'Uus', 'Uuo'
'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og'
)

period_lengths = (2, 8, 8, 18, 18, 32, 32)
Expand Down Expand Up @@ -43,8 +43,8 @@
'Berkelium', 'Californium', 'Einsteinium', 'Fermium', 'Mendelevium',
'Nobelium', 'Lawrencium', 'Rutherfordium', 'Dubnium', 'Seaborgium',
'Bohrium', 'Hassium', 'Meitnerium', 'Darmstadtium', 'Roentgenium',
'Copernicium', '(Ununtrium)', 'Flerovium', '(Ununpentium)',
'Livermorium', '(Ununseptium)', '(Ununoctium)'
'Copernicium', 'Nihonium', 'Flerovium', 'Moscovium',
'Livermorium', 'Tennessine', 'Oganesson'
)

lower_names = tuple(n.lower().lstrip('(').rstrip(')') for n in names)
Expand Down Expand Up @@ -74,8 +74,8 @@ def atomic_number(name):
" 186.207(1) 190.23(3) 192.217(3) 195.084(9) 196.966569(5) 200.592(3)"
" 204.38 207.2(1) 208.98040(1) [209] [210] [222] [223] [226] [227]"
" 232.0377(4) 231.03588(2) 238.02891(3) [237] [244] [243] [247] [247]"
" [251] [252] [257] [258] [259] [266] [267] [268] [269] [270] [269]"
" [278] [281] [282] [285] [286] [289] [289] [293] [294] [294]"
" [251] [252] [257] [258] [259] [266] [267] [268] [269] [270] [271]"
" [278] [281] [282] [285] [286] [289] [290] [293] [294] [294]"
)


Expand Down
23 changes: 21 additions & 2 deletions chempy/util/tests/test_periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

import pytest

from ..periodic import atomic_number, mass_from_composition, relative_atomic_masses, groups
from ..periodic import atomic_number, mass_from_composition, relative_atomic_masses, groups, symbols
from ..testing import requires
from ..parsing import formula_to_composition, parsing_library


def test_atomic_number():
assert atomic_number('U') == 92
assert atomic_number('carbon') == 6
assert atomic_number('ununpentium') == 115
assert atomic_number('oganesson') == 118
with pytest.raises(ValueError):
atomic_number('unobtainium')

Expand Down Expand Up @@ -43,3 +43,22 @@ def test_mass_from_composition__formula():

Fminus = mass_from_composition(formula_to_composition('F/-'))
assert abs(Fminus - 18.998403163 - 5.489e-4) < 1e-7


def test_molar_masses_of_the_elements_gh172():
from chempy import Substance
previous_mass = 0
for symbol in symbols:
this_mass = Substance.from_formula(symbol).mass
# Note that any average atomic masses of naturally occurring isotopes loose their
# meaning for trans-uranium elements. The numbers are almost to be considered arbitrary
# and the user needs to know what isotope they have at hand (and use isotopic mass).
if symbol in ('K', 'Ni', 'I', 'Pa', 'Np', 'Am'):
assert this_mass < previous_mass
elif symbol in ('Bk', 'Og'):
assert this_mass == previous_mass
else:
assert this_mass > previous_mass
previous_mass = this_mass

assert Substance.from_formula('Hs').mass == 271

0 comments on commit c03a0d2

Please sign in to comment.