Make AtomicRepresentation private (leading underscore)

This commit is contained in:
Paul Romano 2022-04-26 16:41:49 -05:00
parent 751d09836c
commit f685827912
3 changed files with 26 additions and 28 deletions

View file

@ -24,7 +24,6 @@ and product yields.
FissionProductYields
WindowedMultipole
ProbabilityTables
AtomicRepresentation
The following classes are used for storing atomic data (incident photon cross
sections, atomic relaxation):
@ -65,11 +64,11 @@ Core Functions
dose_coefficients
gnd_name
isotopes
kalbach_slope
linearize
thin
water_density
zam
return_kalbach_slope
One-dimensional Functions
-------------------------

View file

@ -13,7 +13,7 @@ from .data import EV_PER_MEV
from .endf import get_list_record, get_tab2_record
class AtomicRepresentation(EqualityMixin):
class _AtomicRepresentation(EqualityMixin):
"""Atomic representation of an isotope or a particle.
Parameters
@ -56,20 +56,20 @@ class AtomicRepresentation(EqualityMixin):
self._a = a
def __add__(self, other):
"""Adds two AtomicRepresentations.
"""Adds two _AtomicRepresentations.
"""
z = self.z + other.z
a = self.a + other.a
return AtomicRepresentation(z=z, a=a)
return _AtomicRepresentation(z=z, a=a)
def __sub__(self, other):
"""Substracts two AtomicRepresentations.
"""Substracts two _AtomicRepresentations.
"""
z = self.z - other.z
a = self.a - other.a
return AtomicRepresentation(z=z, a=a)
return _AtomicRepresentation(z=z, a=a)
@property
def a(self):
@ -89,7 +89,7 @@ class AtomicRepresentation(EqualityMixin):
@classmethod
def from_za(cls, za):
"""Instantiates an AtomicRepresentation from a ZA identifier.
"""Instantiate an _AtomicRepresentation from a ZA identifier.
Parameters
----------
@ -99,7 +99,7 @@ class AtomicRepresentation(EqualityMixin):
Returns
-------
AtomicRepresentation
_AtomicRepresentation
Atomic representation of the isotope/particle
"""
@ -115,11 +115,11 @@ def _separation_energy(compound, nucleus, particle):
Parameters
----------
compound : AtomicRepresentation
compound : _AtomicRepresentation
Atomic representation of the compound (C)
nucleus : AtomicRepresentation
nucleus : _AtomicRepresentation
Atomic representation of the nucleus (A or B)
particle : AtomicRepresentation
particle : _AtomicRepresentation
Atomic representation of the particle (a or b)
Returns
@ -219,9 +219,9 @@ def kalbach_slope(energy_projectile, energy_emitted, za_projectile,
if za_target == 6000:
za_target = 6012
projectile = AtomicRepresentation.from_za(za_projectile)
emitted = AtomicRepresentation.from_za(za_emitted)
target = AtomicRepresentation.from_za(za_target)
projectile = _AtomicRepresentation.from_za(za_projectile)
emitted = _AtomicRepresentation.from_za(za_emitted)
target = _AtomicRepresentation.from_za(za_target)
compound = projectile + target
residual = compound - emitted

View file

@ -6,8 +6,7 @@ import pytest
import numpy as np
from openmc.data import IncidentNeutron
from openmc.data import AtomicRepresentation
from openmc.data.kalbach_mann import _separation_energy
from openmc.data.kalbach_mann import _separation_energy, _AtomicRepresentation
from openmc.data import kalbach_slope
from openmc.data import KalbachMann
@ -17,43 +16,43 @@ from . import needs_njoy
@pytest.fixture(scope='module')
def neutron():
"""Neutron AtomicRepresentation."""
return AtomicRepresentation(z=0, a=1)
return _AtomicRepresentation(z=0, a=1)
@pytest.fixture(scope='module')
def triton():
"""Triton AtomicRepresentation."""
return AtomicRepresentation(z=1, a=3)
return _AtomicRepresentation(z=1, a=3)
@pytest.fixture(scope='module')
def b10():
"""B10 AtomicRepresentation."""
return AtomicRepresentation(z=5, a=10)
return _AtomicRepresentation(z=5, a=10)
@pytest.fixture(scope='module')
def c12():
"""C12 AtomicRepresentation."""
return AtomicRepresentation(z=6, a=12)
return _AtomicRepresentation(z=6, a=12)
@pytest.fixture(scope='module')
def c13():
"""C13 AtomicRepresentation."""
return AtomicRepresentation(z=6, a=13)
return _AtomicRepresentation(z=6, a=13)
@pytest.fixture(scope='module')
def na23():
"""Na23 AtomicRepresentation."""
return AtomicRepresentation(z=11, a=23)
return _AtomicRepresentation(z=11, a=23)
def test_atomic_representation(neutron, triton, b10, c12, c13, na23):
"""Test the AtomicRepresentation class."""
# Test instantiation from_za
assert b10 == AtomicRepresentation.from_za(5010)
assert b10 == _AtomicRepresentation.from_za(5010)
# Test addition
assert c13 + b10 == na23
@ -76,13 +75,13 @@ def test_atomic_representation(neutron, triton, b10, c12, c13, na23):
# Test instanciation errors
with pytest.raises(ValueError):
AtomicRepresentation(z=5, a=1)
_AtomicRepresentation(z=5, a=1)
with pytest.raises(ValueError):
AtomicRepresentation(z=-1, a=1)
_AtomicRepresentation(z=-1, a=1)
with pytest.raises(ValueError):
AtomicRepresentation(z=5, a=0)
_AtomicRepresentation(z=5, a=0)
with pytest.raises(ValueError):
AtomicRepresentation(z=5, a=-2)
_AtomicRepresentation(z=5, a=-2)
with pytest.raises(ValueError):
neutron - triton