From 06ffd256bc492f671e10f864ffeabaedf696a305 Mon Sep 17 00:00:00 2001 From: Mikolaj-A-Kowalski <32641577+Mikolaj-A-Kowalski@users.noreply.github.com> Date: Thu, 19 Mar 2020 11:23:12 +0000 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: Patrick Shriwise --- openmc/cell.py | 10 +++++----- tests/unit_tests/test_cell.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/openmc/cell.py b/openmc/cell.py index 9b16c36e3..0173ac495 100644 --- a/openmc/cell.py +++ b/openmc/cell.py @@ -88,7 +88,7 @@ class Cell(IDManagerMixin): calculated in a stochastic volume calculation and added via the :meth:`Cell.add_volume_information` method. For 'distribmat' cells it is the total volume of all instances. - atoms : dict + atoms : collections.OrderedDict Mapping of nuclides to the total number of atoms for each nuclide present in the cell, or in all of its instances for a 'distribmat' fill. For example, {'U235': 1.0e22, 'U238': 5.0e22, ...}. @@ -199,7 +199,7 @@ class Cell(IDManagerMixin): Returns ------- atoms: collections.OrderedDict - Dictionary in which keys are nuclides and values the number of + Dictionary in which keys are nuclides and values are the number of atoms. For example, {'H1':1.0e22, 'O16':0.5e22, ...} Raises @@ -224,7 +224,7 @@ class Cell(IDManagerMixin): elif self.fill_type in ['lattice', 'universe']: msg = ('Universe and Lattice cells can contain multiple ' 'materials in diffrent proportions. Atom content must ' - 'be calculated with stochastic volume calculation') + 'be calculated with stochastic volume calculation.') raise ValueError(msg) elif self.fill_type == 'material': @@ -244,14 +244,14 @@ class Cell(IDManagerMixin): for mat in self.fill: for key, nuclide in mat.get_nuclide_atom_densities().items(): # To account for overlap of nuclides between distribmat - # we need to append new atoms # to any existing value + # we need to append new atoms to any existing value # hence it is necessary to ask for default. atom = self._atoms.setdefault(key, 0) atom += nuclide[1] * partial_volume * 1.0e+24 self._atoms[key] = atom else: - msg = 'Unrecognised fill_type:{}'.format(self.fill_type) + msg = 'Unrecognised fill_type: {}'.format(self.fill_type) raise ValueError(msg) return self._atoms diff --git a/tests/unit_tests/test_cell.py b/tests/unit_tests/test_cell.py index 1a01a0f6c..e5ab58201 100644 --- a/tests/unit_tests/test_cell.py +++ b/tests/unit_tests/test_cell.py @@ -150,7 +150,7 @@ def test_atoms_material_cell(uo2, water): expected_nucs = ['U235', 'O16'] # Precalculate the expected number of atoms - M = ((atomic_mass('U235') + 2 * atomic_mass('O16'))/3) + M = (atomic_mass('U235') + 2 * atomic_mass('O16')) / 3 expected_atoms = list() expected_atoms.append(1/3 * uo2.density/M * AVOGADRO * 2.0) # U235 expected_atoms.append(2/3 * uo2.density/M * AVOGADRO * 2.0) # O16 @@ -174,7 +174,7 @@ def test_atoms_material_cell(uo2, water): # Change material and check if OK c.fill = water expected_nucs = ['H1', 'O16'] - M = ((2 * atomic_mass('H1') + atomic_mass('O16'))/3) + M = (2 * atomic_mass('H1') + atomic_mass('O16')) / 3 expected_atoms = list() expected_atoms.append(2/3 * water.density/M * AVOGADRO * 3.0) # H1 expected_atoms.append(1/3 * water.density/M * AVOGADRO * 3.0) # O16 @@ -194,8 +194,8 @@ def test_atoms_distribmat_cell(uo2, water): # Calculate the expected number of atoms expected_nucs = ['U235', 'O16', 'H1'] - M_uo2 = ((atomic_mass('U235') + 2 * atomic_mass('O16'))/3) - M_water = ((2 * atomic_mass('H1') + atomic_mass('O16'))/3) + M_uo2 = (atomic_mass('U235') + 2 * atomic_mass('O16')) / 3 + M_water = (2 * atomic_mass('H1') + atomic_mass('O16')) / 3 expected_atoms = list() expected_atoms.append(1/3 * uo2.density/M_uo2 * AVOGADRO * 3.0) # U235 expected_atoms.append(2/3 * uo2.density/M_uo2 * AVOGADRO * 3.0 +