mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Use literal empty dict and list instead of dict() and list()
This commit is contained in:
parent
764ab84f01
commit
eb38ee3b88
12 changed files with 78 additions and 78 deletions
|
|
@ -4,7 +4,7 @@ def sort_xml_elements(tree):
|
|||
elements = tree.getchildren()
|
||||
|
||||
# Initialize empty lists for the sorted and comment elements
|
||||
sorted_elements = list()
|
||||
sorted_elements = []
|
||||
|
||||
# Initialize an empty set of tags (e.g., Surface, Cell, and Lattice)
|
||||
tags = set()
|
||||
|
|
@ -14,7 +14,7 @@ def sort_xml_elements(tree):
|
|||
tags.add(element.tag)
|
||||
|
||||
# Initialize an empty list for the comment elements
|
||||
comment_elements = list()
|
||||
comment_elements = []
|
||||
|
||||
# Find the comment elements and record their ordering within the
|
||||
# tree using a precedence with respect to the subsequent nodes
|
||||
|
|
@ -38,7 +38,7 @@ def sort_xml_elements(tree):
|
|||
continue
|
||||
|
||||
# Initialize an empty list of tuples to sort (id, element)
|
||||
tagged_data = list()
|
||||
tagged_data = []
|
||||
|
||||
# Retrieve the IDs for each of the elements
|
||||
for element in tagged_elements:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Element(object):
|
|||
|
||||
|
||||
def __hash__(self):
|
||||
hashable = list()
|
||||
hashable = []
|
||||
hashable.append(self._name)
|
||||
hashable.append(self._xs)
|
||||
return hash(tuple(hashable))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Geometry(object):
|
|||
|
||||
# Initialize Geometry class attributes
|
||||
self._root_universe = None
|
||||
self._offsets = dict()
|
||||
self._offsets = {}
|
||||
|
||||
|
||||
def get_offset(self, path, filter_offset):
|
||||
|
|
@ -61,7 +61,7 @@ class Geometry(object):
|
|||
|
||||
def get_all_nuclides(self):
|
||||
|
||||
nuclides = dict()
|
||||
nuclides = {}
|
||||
materials = self.get_all_materials()
|
||||
|
||||
for material in materials:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import numpy as np
|
|||
|
||||
|
||||
# A list of all IDs for all Materials created
|
||||
MATERIAL_IDS = list()
|
||||
MATERIAL_IDS = []
|
||||
|
||||
# A static variable for auto-generated Material IDs
|
||||
AUTO_MATERIAL_ID = 10000
|
||||
|
|
@ -18,7 +18,7 @@ AUTO_MATERIAL_ID = 10000
|
|||
def reset_auto_material_id():
|
||||
global AUTO_MATERIAL_ID, MATERIAL_IDS
|
||||
AUTO_MATERIAL_ID = 10000
|
||||
MATERIAL_IDS = list()
|
||||
MATERIAL_IDS = []
|
||||
|
||||
|
||||
# Units for density supported by OpenMC
|
||||
|
|
@ -47,15 +47,15 @@ class Material(object):
|
|||
# A dictionary of Nuclides
|
||||
# Keys - Nuclide names
|
||||
# Values - tuple (nuclide, percent, percent type)
|
||||
self._nuclides = dict()
|
||||
self._nuclides = {}
|
||||
|
||||
# A dictionary of Elements
|
||||
# Keys - Element names
|
||||
# Values - tuple (element, percent, percent type)
|
||||
self._elements = dict()
|
||||
self._elements = {}
|
||||
|
||||
# If specified, a list of tuples of (table name, xs identifier)
|
||||
self._sab = list()
|
||||
self._sab = []
|
||||
|
||||
# If true, the material will be initialized as distributed
|
||||
self._convert_to_distrib_comps = False
|
||||
|
|
@ -241,7 +241,7 @@ class Material(object):
|
|||
|
||||
def get_all_nuclides(self):
|
||||
|
||||
nuclides = dict()
|
||||
nuclides = {}
|
||||
|
||||
for nuclide_name, nuclide_tuple in self._nuclides.items():
|
||||
nuclide = nuclide_tuple[0]
|
||||
|
|
@ -318,7 +318,7 @@ class Material(object):
|
|||
|
||||
def get_nuclides_xml(self, nuclides, distrib=False):
|
||||
|
||||
xml_elements = list()
|
||||
xml_elements = []
|
||||
|
||||
for nuclide in nuclides.values():
|
||||
xml_elements.append(self.get_nuclide_xml(nuclide, distrib))
|
||||
|
|
@ -328,7 +328,7 @@ class Material(object):
|
|||
|
||||
def get_elements_xml(self, elements, distrib=False):
|
||||
|
||||
xml_elements = list()
|
||||
xml_elements = []
|
||||
|
||||
for element in elements.values():
|
||||
xml_elements.append(self.get_element_xml(element, distrib))
|
||||
|
|
@ -414,7 +414,7 @@ class MaterialsFile(object):
|
|||
def __init__(self):
|
||||
|
||||
# Initialize MaterialsFile class attributes
|
||||
self._materials = list()
|
||||
self._materials = []
|
||||
self._default_xs = None
|
||||
self._materials_file = ET.Element("materials")
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Nuclide(object):
|
|||
|
||||
|
||||
def __hash__(self):
|
||||
hashable = list()
|
||||
hashable = []
|
||||
hashable.append(self._name)
|
||||
hashable.append(self._xs)
|
||||
return hash(tuple(hashable))
|
||||
|
|
|
|||
|
|
@ -7,52 +7,52 @@ import numpy as np
|
|||
# A dictionary of all OpenMC Materials created
|
||||
# Keys - Material IDs
|
||||
# Values - Materials
|
||||
OPENMC_MATERIALS = dict()
|
||||
OPENMC_MATERIALS = {}
|
||||
|
||||
# A dictionary of all OpenCG Materials created
|
||||
# Keys - Material IDs
|
||||
# Values - Materials
|
||||
OPENCG_MATERIALS = dict()
|
||||
OPENCG_MATERIALS = {}
|
||||
|
||||
# A dictionary of all OpenMC Surfaces created
|
||||
# Keys - Surface IDs
|
||||
# Values - Surfaces
|
||||
OPENMC_SURFACES = dict()
|
||||
OPENMC_SURFACES = {}
|
||||
|
||||
# A dictionary of all OpenCG Surfaces created
|
||||
# Keys - Surface IDs
|
||||
# Values - Surfaces
|
||||
OPENCG_SURFACES = dict()
|
||||
OPENCG_SURFACES = {}
|
||||
|
||||
# A dictionary of all OpenMC Cells created
|
||||
# Keys - Cell IDs
|
||||
# Values - Cells
|
||||
OPENMC_CELLS = dict()
|
||||
OPENMC_CELLS = {}
|
||||
|
||||
# A dictionary of all OpenCG Cells created
|
||||
# Keys - Cell IDs
|
||||
# Values - Cells
|
||||
OPENCG_CELLS = dict()
|
||||
OPENCG_CELLS = {}
|
||||
|
||||
# A dictionary of all OpenMC Universes created
|
||||
# Keys - Universes IDs
|
||||
# Values - Universes
|
||||
OPENMC_UNIVERSES = dict()
|
||||
OPENMC_UNIVERSES = {}
|
||||
|
||||
# A dictionary of all OpenCG Universes created
|
||||
# Keys - Universes IDs
|
||||
# Values - Universes
|
||||
OPENCG_UNIVERSES = dict()
|
||||
OPENCG_UNIVERSES = {}
|
||||
|
||||
# A dictionary of all OpenMC Lattices created
|
||||
# Keys - Lattice IDs
|
||||
# Values - Lattices
|
||||
OPENMC_LATTICES = dict()
|
||||
OPENMC_LATTICES = {}
|
||||
|
||||
# A dictionary of all OpenCG Lattices created
|
||||
# Keys - Lattice IDs
|
||||
# Values - Lattices
|
||||
OPENCG_LATTICES = dict()
|
||||
OPENCG_LATTICES = {}
|
||||
|
||||
|
||||
|
||||
|
|
@ -408,7 +408,7 @@ def get_compatible_opencg_cells(opencg_cell, opencg_surface, halfspace):
|
|||
raise ValueError(msg)
|
||||
|
||||
# Initialize an empty list for the new compatible cells
|
||||
compatible_cells = list()
|
||||
compatible_cells = []
|
||||
|
||||
# SquarePrism Surfaces
|
||||
if opencg_surface._type in ['x-squareprism',
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ class PlotsFile(object):
|
|||
def __init__(self):
|
||||
|
||||
# Initialize PlotsFile class attributes
|
||||
self._plots = list()
|
||||
self._plots = []
|
||||
self._plots_file = ET.Element("plots")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ class StatePoint(object):
|
|||
# Initialize dictionaries for the Meshes
|
||||
# Keys - Mesh IDs
|
||||
# Values - Mesh objects
|
||||
self._meshes = dict()
|
||||
self._meshes = {}
|
||||
|
||||
# Read the number of Meshes
|
||||
self._n_meshes = self._get_int(path='tallies/meshes/n_meshes')[0]
|
||||
|
|
@ -203,8 +203,8 @@ class StatePoint(object):
|
|||
path='tallies/meshes/keys')
|
||||
|
||||
else:
|
||||
self._mesh_keys = list()
|
||||
self._mesh_ids = list()
|
||||
self._mesh_keys = []
|
||||
self._mesh_ids = []
|
||||
|
||||
# Build dictionary of Meshes
|
||||
base = 'tallies/meshes/mesh '
|
||||
|
|
@ -251,7 +251,7 @@ class StatePoint(object):
|
|||
# Initialize dictionaries for the Tallies
|
||||
# Keys - Tally IDs
|
||||
# Values - Tally objects
|
||||
self._tallies = dict()
|
||||
self._tallies = {}
|
||||
|
||||
# Read the number of tallies
|
||||
self._n_tallies = self._get_int(path='/tallies/n_tallies')[0]
|
||||
|
|
@ -268,8 +268,8 @@ class StatePoint(object):
|
|||
self._n_tallies, path='tallies/keys')
|
||||
|
||||
else:
|
||||
self._tally_keys = list()
|
||||
self._tally_ids = list()
|
||||
self._tally_keys = []
|
||||
self._tally_ids = []
|
||||
|
||||
base = 'tallies/tally '
|
||||
|
||||
|
|
@ -376,7 +376,7 @@ class StatePoint(object):
|
|||
path='{0}{1}/n_user_score_bins'.format(base, tally_key))[0]
|
||||
|
||||
# Read scattering moment order strings (e.g., P3, Y-1,2, etc.)
|
||||
moments = list()
|
||||
moments = []
|
||||
subbase = '{0}{1}/moments/'.format(base, tally_key)
|
||||
|
||||
# Extract the moment order string for each score
|
||||
|
|
@ -664,25 +664,25 @@ class StatePoint(object):
|
|||
for filter in tally._filters:
|
||||
|
||||
if filter._type == 'surface':
|
||||
surface_ids = list()
|
||||
surface_ids = []
|
||||
for bin in filter._bins:
|
||||
surface_ids.append(summary.surfaces[bin]._id)
|
||||
filter.set_bin_edges(surface_ids)
|
||||
|
||||
if filter._type in ['cell', 'distribcell']:
|
||||
distribcell_ids = list()
|
||||
distribcell_ids = []
|
||||
for bin in filter._bins:
|
||||
distribcell_ids.append(summary.cells[bin]._id)
|
||||
filter.set_bin_edges(distribcell_ids)
|
||||
|
||||
if filter._type == 'universe':
|
||||
universe_ids = list()
|
||||
universe_ids = []
|
||||
for bin in filter._bins:
|
||||
universe_ids.append(summary.universes[bin]._id)
|
||||
filter.set_bin_edges(universe_ids)
|
||||
|
||||
if filter._type == 'material':
|
||||
material_ids = list()
|
||||
material_ids = []
|
||||
for bin in filter._bins:
|
||||
material_ids.append(summary.materials[bin]._id)
|
||||
filter.set_bin_edges(material_ids)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class Summary(object):
|
|||
# Initialize dictionary for each Nuclide
|
||||
# Keys - Nuclide ZAIDs
|
||||
# Values - Nuclide objects
|
||||
self.nuclides = dict()
|
||||
self.nuclides = {}
|
||||
|
||||
for key in self._f['nuclides'].keys():
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ class Summary(object):
|
|||
# Initialize dictionary for each Material
|
||||
# Keys - Material keys
|
||||
# Values - Material objects
|
||||
self.materials = dict()
|
||||
self.materials = {}
|
||||
|
||||
for key in self._f['materials'].keys():
|
||||
|
||||
|
|
@ -109,8 +109,8 @@ class Summary(object):
|
|||
nuclides = self._f['materials'][key]['nuclides'][...]
|
||||
n_sab = self._f['materials'][key]['n_sab'][0]
|
||||
|
||||
sab_names = list()
|
||||
sab_xs = list()
|
||||
sab_names = []
|
||||
sab_xs = []
|
||||
|
||||
# Read the names of the S(a,b) tables for this Material
|
||||
for i in range(1, n_sab+1):
|
||||
|
|
@ -154,7 +154,7 @@ class Summary(object):
|
|||
# Initialize dictionary for each Surface
|
||||
# Keys - Surface keys
|
||||
# Values - Surfacee objects
|
||||
self.surfaces = dict()
|
||||
self.surfaces = {}
|
||||
|
||||
for key in self._f['geometry/surfaces'].keys():
|
||||
|
||||
|
|
@ -237,7 +237,7 @@ class Summary(object):
|
|||
# Initialize dictionary for each Cell
|
||||
# Keys - Cell keys
|
||||
# Values - Cell objects
|
||||
self.cells = dict()
|
||||
self.cells = {}
|
||||
|
||||
# Initialize dictionary for each Cell's fill
|
||||
# (e.g., Material, Universe or Lattice ID)
|
||||
|
|
@ -245,7 +245,7 @@ class Summary(object):
|
|||
# the corresponding objects
|
||||
# Keys - Cell keys
|
||||
# Values - Filling Material, Universe or Lattice ID
|
||||
self._cell_fills = dict()
|
||||
self._cell_fills = {}
|
||||
|
||||
for key in self._f['geometry/cells'].keys():
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ class Summary(object):
|
|||
if 'surfaces' in self._f['geometry/cells'][key].keys():
|
||||
surfaces = self._f['geometry/cells'][key]['surfaces'][...]
|
||||
else:
|
||||
surfaces = list()
|
||||
surfaces = []
|
||||
|
||||
# Create this Cell
|
||||
cell = openmc.Cell(cell_id=cell_id)
|
||||
|
|
@ -308,7 +308,7 @@ class Summary(object):
|
|||
# Initialize dictionary for each Universe
|
||||
# Keys - Universe keys
|
||||
# Values - Universe objects
|
||||
self.universes = dict()
|
||||
self.universes = {}
|
||||
|
||||
for key in self._f['geometry/universes'].keys():
|
||||
|
||||
|
|
@ -338,7 +338,7 @@ class Summary(object):
|
|||
# Initialize lattices for each Lattice
|
||||
# Keys - Lattice keys
|
||||
# Values - Lattice objects
|
||||
self.lattices = dict()
|
||||
self.lattices = {}
|
||||
|
||||
for key in self._f['geometry/lattices'].keys():
|
||||
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ class Surface(object):
|
|||
# A dictionary of the quadratic surface coefficients
|
||||
# Key - coefficeint name
|
||||
# Value - coefficient value
|
||||
self._coeffs = dict()
|
||||
self._coeffs = {}
|
||||
|
||||
# An ordered list of the coefficient names to export to XML in the
|
||||
# proper order
|
||||
self._coeff_keys = list()
|
||||
self._coeff_keys = []
|
||||
|
||||
self.set_id(surface_id)
|
||||
self.set_boundary_type(bc_type)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class Filter(object):
|
|||
|
||||
|
||||
def __hash__(self):
|
||||
hashable = list()
|
||||
hashable = []
|
||||
hashable.append(self._type)
|
||||
hashable.append(self._bins)
|
||||
return hash(tuple(hashable))
|
||||
|
|
@ -530,9 +530,9 @@ class Tally(object):
|
|||
# Initialize Tally class attributes
|
||||
self._id = None
|
||||
self._label = None
|
||||
self._filters = list()
|
||||
self._nuclides = list()
|
||||
self._scores = list()
|
||||
self._filters = []
|
||||
self._nuclides = []
|
||||
self._scores = []
|
||||
self._estimator = None
|
||||
|
||||
self._num_score_bins = 0
|
||||
|
|
@ -565,15 +565,15 @@ class Tally(object):
|
|||
clone._mean = copy.deepcopy(self._mean, memo)
|
||||
clone._std_dev = copy.deepcopy(self._std_dev, memo)
|
||||
|
||||
clone._filters = list()
|
||||
clone._filters = []
|
||||
for filter in self._filters:
|
||||
clone.add_filter(copy.deepcopy(filter, memo))
|
||||
|
||||
clone._nuclides = list()
|
||||
clone._nuclides = []
|
||||
for nuclide in self._nuclides:
|
||||
clone.add_nuclide(copy.deepcopy(nuclide, memo))
|
||||
|
||||
clone._scores = list()
|
||||
clone._scores = []
|
||||
for score in self._scores:
|
||||
clone.add_score(score)
|
||||
|
||||
|
|
@ -610,7 +610,7 @@ class Tally(object):
|
|||
|
||||
|
||||
def __hash__(self):
|
||||
hashable = list()
|
||||
hashable = []
|
||||
|
||||
for filter in self._filters:
|
||||
hashable.append((filter._type, tuple(filter._bins)))
|
||||
|
|
@ -1103,7 +1103,7 @@ class Tally(object):
|
|||
tally_group.create_dataset('scores', data=np.array(self._scores))
|
||||
|
||||
# Add a string array of the nuclides to the HDF5 group
|
||||
nuclides = list()
|
||||
nuclides = []
|
||||
|
||||
for nuclide in self._nuclides:
|
||||
nuclides.append(nuclide._name)
|
||||
|
|
@ -1138,10 +1138,10 @@ class Tally(object):
|
|||
if os.path.exists(filename) and append:
|
||||
tally_results = pickle.load(file(filename, 'rb'))
|
||||
else:
|
||||
tally_results = dict()
|
||||
tally_results = {}
|
||||
|
||||
# Create a nested dictionary within the file for this particular Tally
|
||||
tally_results['Tally-{0}'.format(self._id)] = dict()
|
||||
tally_results['Tally-{0}'.format(self._id)] = {}
|
||||
tally_group = tally_results['Tally-{0}'.format(self._id)]
|
||||
|
||||
# Add basic Tally data to the nested dictionary
|
||||
|
|
@ -1151,7 +1151,7 @@ class Tally(object):
|
|||
tally_group['scores'] = np.array(self._scores)
|
||||
|
||||
# Add a string array of the nuclides to the HDF5 group
|
||||
nuclides = list()
|
||||
nuclides = []
|
||||
|
||||
for nuclide in self._nuclides:
|
||||
nuclides.append(nuclide._name)
|
||||
|
|
@ -1159,7 +1159,7 @@ class Tally(object):
|
|||
tally_group['nuclides']= np.array(nuclides)
|
||||
|
||||
# Create a nested dictionary for the Filters
|
||||
tally_group['filters'] = dict()
|
||||
tally_group['filters'] = {}
|
||||
filter_group = tally_group['filters']
|
||||
|
||||
for filter in self._filters:
|
||||
|
|
@ -1180,8 +1180,8 @@ class TalliesFile(object):
|
|||
def __init__(self):
|
||||
|
||||
# Initialize TalliesFile class attributes
|
||||
self._tallies = list()
|
||||
self._meshes = list()
|
||||
self._tallies = []
|
||||
self._meshes = []
|
||||
self._tallies_file = ET.Element("tallies")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class Cell(object):
|
|||
self._name = None
|
||||
self._fill = None
|
||||
self._type = None
|
||||
self._surfaces = dict()
|
||||
self._surfaces = {}
|
||||
self._rotation = None
|
||||
self._translation = None
|
||||
self._offset = None
|
||||
|
|
@ -226,7 +226,7 @@ class Cell(object):
|
|||
|
||||
def get_all_nuclides(self):
|
||||
|
||||
nuclides = dict()
|
||||
nuclides = {}
|
||||
|
||||
if self._type != 'void':
|
||||
nuclides.update(self._fill.get_all_nuclides())
|
||||
|
|
@ -236,7 +236,7 @@ class Cell(object):
|
|||
|
||||
def get_all_cells(self):
|
||||
|
||||
cells = dict()
|
||||
cells = {}
|
||||
|
||||
if self._type == 'fill' or self._type == 'lattice':
|
||||
cells.update(self._fill.get_all_cells())
|
||||
|
|
@ -246,7 +246,7 @@ class Cell(object):
|
|||
|
||||
def get_all_universes(self):
|
||||
|
||||
universes = dict()
|
||||
universes = {}
|
||||
|
||||
if self._type == 'fill':
|
||||
universes[self._fill._id] = self._fill
|
||||
|
|
@ -380,7 +380,7 @@ class Universe(object):
|
|||
|
||||
# Keys - Cell IDs
|
||||
# Values - Cells
|
||||
self._cells = dict()
|
||||
self._cells = {}
|
||||
|
||||
# Keys - Cell IDs
|
||||
# Values - Offsets
|
||||
|
|
@ -483,7 +483,7 @@ class Universe(object):
|
|||
|
||||
def get_all_nuclides(self):
|
||||
|
||||
nuclides = dict()
|
||||
nuclides = {}
|
||||
|
||||
# Append all Nuclides in each Cell in the Universe to the dictionary
|
||||
for cell_id, cell in self._cells.items():
|
||||
|
|
@ -494,7 +494,7 @@ class Universe(object):
|
|||
|
||||
def get_all_cells(self):
|
||||
|
||||
cells = dict()
|
||||
cells = {}
|
||||
|
||||
# Add this Universe's cells to the dictionary
|
||||
cells.update(self._cells)
|
||||
|
|
@ -511,7 +511,7 @@ class Universe(object):
|
|||
# Get all Cells in this Universe
|
||||
cells = self.get_all_cells()
|
||||
|
||||
universes = dict()
|
||||
universes = {}
|
||||
|
||||
# Append all Universes containing each Cell to the dictionary
|
||||
for cell_id, cell in cells.items():
|
||||
|
|
@ -633,7 +633,7 @@ class Lattice(object):
|
|||
def get_unique_universes(self):
|
||||
|
||||
unique_universes = np.unique(self._universes.ravel())
|
||||
universes = dict()
|
||||
universes = {}
|
||||
|
||||
for universe in unique_universes:
|
||||
universes[universe._id] = universe
|
||||
|
|
@ -643,7 +643,7 @@ class Lattice(object):
|
|||
|
||||
def get_all_nuclides(self):
|
||||
|
||||
nuclides = dict()
|
||||
nuclides = {}
|
||||
|
||||
# Get all unique Universes contained in each of the lattice cells
|
||||
unique_universes = self.get_unique_universes()
|
||||
|
|
@ -657,7 +657,7 @@ class Lattice(object):
|
|||
|
||||
def get_all_cells(self):
|
||||
|
||||
cells = dict()
|
||||
cells = {}
|
||||
unique_universes = self.get_unique_universes()
|
||||
|
||||
for universe_id, universe in unique_universes.items():
|
||||
|
|
@ -670,7 +670,7 @@ class Lattice(object):
|
|||
|
||||
# Initialize a dictionary of all Universes contained by the Lattice
|
||||
# in each nested Universe level
|
||||
all_universes = dict()
|
||||
all_universes = {}
|
||||
|
||||
# Get all unique Universes contained in each of the lattice cells
|
||||
unique_universes = self.get_unique_universes()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue