Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ Known issues
Change history
==============

2026-02-13 R2.0.3
-----------------

Modified:

* Update b_c bp bm and incoherent attributes for C-13
* Update nuclear_spin for Se-77 Hf-177 W-182
* Add comparison tables checking b_c and σ_i against b+ and b-
* Add type hinting to many of the functions

2024-12-19 R2.0.2
-----------------

Expand Down
2 changes: 2 additions & 0 deletions doc/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
('py:class', 'type'),
('py:class', 'object'),

('py:class', 'collections.abc.Buffer'),
('py:class', 'collections.abc.Callable'),
('py:class', 'collections.abc.Iterator'),
('py:class', 'collections.abc.Sequence'),
Expand All @@ -59,6 +60,7 @@
('py:class', 'numpy.ndarray'),
('py:class', 'numpy.float64'),
('py:class', 'numpy._typing._array_like._Buffer'),
('py:class', 'numpy._typing._array_like._ScalarType_co'),
('py:class', 'numpy._typing._array_like._SupportsArray'),
('py:class', 'numpy._typing._array_like._ScalarT'),
('py:class', 'numpy._typing._nested_sequence._NestedSequence'),
Expand Down
3 changes: 1 addition & 2 deletions periodictable/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,7 @@ def init(table, reload=False):
columns = row.split('\t')
if columns[0].strip() in ('', 'xx'):
continue
columns = [c[1:-1] if c.startswith('"') else c
for c in columns]
columns = [c[1:-1] if c.startswith('"') else c for c in columns]
#print columns
for c in INT_COLUMNS:
columns[c] = int(columns[c])
Expand Down
18 changes: 10 additions & 8 deletions periodictable/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
__docformat__ = 'restructuredtext en'
__all__ = ['delayed_load', 'define_elements', 'get_data_path',
'default_table', 'change_table',
'Ion', 'Isotope', 'Element', 'PeriodicTable',
'Ion', 'IonSet', 'Isotope', 'Element', 'PeriodicTable',
'isatom', 'iselement', 'isisotope', 'ision']

from pathlib import Path
Expand Down Expand Up @@ -653,16 +653,18 @@ def __repr__(self) -> str:
return repr(self.element)+'.ion[%d]'%self.charge
def __reduce__(self):
try:
return _make_isotope_ion, (self.element.table,
self.element.number,
self.element.isotope,
self.charge)
iso = cast("Isotope", self.element)
return _make_isotope_ion, (iso.table, iso.number, iso.isotope, self.charge)
except Exception:
return _make_ion, (self.element.table,
self.element.number,
self.charge)
el = cast("Element", self.element)
return _make_ion, (el.table, el.number, self.charge)

class IonSet:
"""
The set of ions associated with an element or isotope.

This is a dictionary interface indexed by ion charge.
"""
element_or_isotope: Union["Element", "Isotope"]
ionset: dict[int, "Ion"]

Expand Down
1 change: 1 addition & 0 deletions periodictable/cromermann.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def _update_cmformulas() -> None:
# #N 11
# #L a1 a2 a3 a4 a5 c b1 b2 b3 b4 b5
# <a1 a2 a3 a4 a5> <c> <b1 b2 b3 b4 b5>
symbol = None
with open(path) as fp:
for line in fp:
if line.startswith("#S"):
Expand Down
8 changes: 6 additions & 2 deletions periodictable/formulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def mix_by_weight(*args, **kw) -> "Formula":
return result

def _mix_by_weight_pairs(pairs: list[tuple["Formula", float]]) -> "Formula":
from .formulas import Formula # For running as __main__

# Drop pairs with zero quantity
# Note: must be first statement in order to accept iterators
Expand Down Expand Up @@ -175,6 +176,7 @@ def mix_by_volume(*args, **kw) -> "Formula":
return result

def _mix_by_volume_pairs(pairs: list[tuple["Formula", float]]) -> "Formula":
from .formulas import Formula # For running as __main__

# Drop pairs with zero quantity
# Note: must be first statement in order to accept iterators
Expand Down Expand Up @@ -285,6 +287,8 @@ def formula(
The representations are simple, but preserve some of the structure for
display purposes.
"""
from .formulas import Formula # For running as __main__

structure: Structure
if compound is None or compound == '':
structure = tuple()
Expand Down Expand Up @@ -704,7 +708,7 @@ def _isotope_substitution(compound: "Formula", source: Atom, target: Atom, porti

# TODO: Grammar should be independent of table
# TODO: Parser can't handle meters as 'm' because it conflicts with the milli prefix
LENGTH_UNITS = {'nm': 1e-9, 'um': 1e-6, 'mm': 1e-3, 'cm': 1e-2}
LENGTH_UNITS = {'nm': 1e-9, 'um': 1e-6, 'μm': 1e-6, 'mm': 1e-3, 'cm': 1e-2}
MASS_UNITS = {'ng': 1e-9, 'ug': 1e-6, 'mg': 1e-3, 'g': 1e+0, 'kg': 1e+3}
VOLUME_UNITS = {'nL': 1e-9, 'uL': 1e-6, 'mL': 1e-3, 'L': 1e+0}
LENGTH_RE = '('+'|'.join(LENGTH_UNITS.keys())+')'
Expand Down Expand Up @@ -909,7 +913,7 @@ def convert_by_layer(string, location, tokens):
fract = []
for p1, p2 in zip(tokens[0::2], tokens[1::2]):
if isinstance(p1, Formula):
f = p1.absthick * float(p2)
f = p1.thickness * float(p2)
p = p1
else:
f = float(p1[0]) * LENGTH_UNITS[p1[1]]
Expand Down
Loading