diff --git a/openmc/element.py b/openmc/element.py index d091db37d..2f81b9f30 100644 --- a/openmc/element.py +++ b/openmc/element.py @@ -73,6 +73,6 @@ class Element(object): self._name = name def __repr__(self): - string = 'Element - "{0}"\n'.format(self._name) - string += '{0: <16}"{1}""{2}"\n'.format('\tXS', '=\t', self._xs) + string = 'Element - {0}\n'.format(self._name) + string += '{0: <16}{1}{2}\n'.format('\tXS', '=\t', self._xs) return string diff --git a/openmc/executor.py b/openmc/executor.py index 1c1ff40c6..54c8a64c1 100644 --- a/openmc/executor.py +++ b/openmc/executor.py @@ -92,16 +92,16 @@ class Executor(object): pre_args = '' if isinstance(particles, Integral) and particles > 0: - post_args += '-n "{0}" '.format(particles) + post_args += '-n {0} '.format(particles) if isinstance(threads, Integral) and threads > 0: - post_args += '-s "{0}" '.format(threads) + post_args += '-s {0} '.format(threads) if geometry_debug: post_args += '-g ' if isinstance(restart_file, basestring): - post_args += '-r "{0}" '.format(restart_file) + post_args += '-r {0} '.format(restart_file) if tracks: post_args += '-t' @@ -121,7 +121,7 @@ class Executor(object): pre_args += mpi_exec + ' ' else: pre_args += 'mpirun ' - pre_args += '-n "{0}" '.format(mpi_procs) + pre_args += '-n {0} '.format(mpi_procs) command = pre_args + openmc_exec + ' ' + post_args diff --git a/openmc/filter.py b/openmc/filter.py index 8bae47fa4..93ee09453 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -109,7 +109,7 @@ class Filter(object): if type is None: self._type = type elif type not in FILTER_TYPES.values(): - msg = 'Unable to set Filter type to ""{0}"" since it is not one ' \ + msg = 'Unable to set Filter type to ""{0}" since it is not one ' \ 'of the supported types'.format(type) raise ValueError(msg) @@ -120,7 +120,7 @@ class Filter(object): if bins is None: self.num_bins = 0 elif self._type is None: - msg = 'Unable to set bins for Filter to ""{0}"" since ' \ + msg = 'Unable to set bins for Filter to "{0}" since ' \ 'the Filter type has not yet been set'.format(bins) raise ValueError(msg) @@ -136,30 +136,30 @@ class Filter(object): 'universe', 'distribcell']: for edge in bins: if not isinstance(edge, Integral): - msg = 'Unable to add bin ""{0}"" to a "{1}" Filter since ' \ + msg = 'Unable to add bin "{0}" to a "{1}" Filter since ' \ 'it is not an integer'.format(edge, self._type) raise ValueError(msg) elif edge < 0: - msg = 'Unable to add bin ""{0}"" to a "{1}" Filter since ' \ + msg = 'Unable to add bin "{0}" to a "{1}" Filter since ' \ 'it is negative'.format(edge, self._type) raise ValueError(msg) elif self._type in ['energy', 'energyout']: for edge in bins: if not isinstance(edge, Real): - msg = 'Unable to add bin edge ""{0}"" to a "{1}" Filter ' \ + msg = 'Unable to add bin edge "{0}" to a "{1}" Filter ' \ 'since it is a non-integer or floating point ' \ 'value'.format(edge, self._type) raise ValueError(msg) elif edge < 0.: - msg = 'Unable to add bin edge ""{0}"" to a "{1}" Filter ' \ + msg = 'Unable to add bin edge "{0}" to a "{1}" Filter ' \ 'since it is a negative value'.format(edge, self._type) raise ValueError(msg) # Check that bin edges are monotonically increasing for index in range(len(bins)): if index > 0 and bins[index] < bins[index-1]: - msg = 'Unable to add bin edges ""{0}"" to a "{1}" Filter ' \ + msg = 'Unable to add bin edges "{0}" to a "{1}" Filter ' \ 'since they are not monotonically ' \ 'increasing'.format(bins, self._type) raise ValueError(msg) @@ -167,15 +167,15 @@ class Filter(object): # mesh filters elif self._type == 'mesh': if not len(bins) == 1: - msg = 'Unable to add bins ""{0}"" to a mesh Filter since ' \ + msg = 'Unable to add bins "{0}" to a mesh Filter since ' \ 'only a single mesh can be used per tally'.format(bins) raise ValueError(msg) elif not isinstance(bins[0], Integral): - msg = 'Unable to add bin ""{0}"" to mesh Filter since it ' \ + msg = 'Unable to add bin "{0}" to mesh Filter since it ' \ 'is a non-integer'.format(bins[0]) raise ValueError(msg) elif bins[0] < 0: - msg = 'Unable to add bin ""{0}"" to mesh Filter since it ' \ + msg = 'Unable to add bin "{0}" to mesh Filter since it ' \ 'is a negative integer'.format(bins[0]) raise ValueError(msg) @@ -186,7 +186,7 @@ class Filter(object): @num_bins.setter def num_bins(self, num_bins): if not isinstance(num_bins, Integral) or num_bins < 0: - msg = 'Unable to set the number of bins ""{0}"" for a "{1}" Filter ' \ + msg = 'Unable to set the number of bins "{0}" for a "{1}" Filter ' \ 'since it is not a positive ' \ 'integer'.format(num_bins, self._type) raise ValueError(msg) @@ -210,7 +210,7 @@ class Filter(object): def stride(self, stride): check_type('filter stride', stride, Integral) if stride < 0: - msg = 'Unable to set stride ""{0}"" for a "{1}" Filter since it is a ' \ + msg = 'Unable to set stride "{0}" for a "{1}" Filter since it is a ' \ 'negative value'.format(stride, self._type) raise ValueError(msg) @@ -336,7 +336,7 @@ class Filter(object): filter_index = val except ValueError: - msg = 'Unable to get the bin index for Filter since ""{0}"" ' \ + msg = 'Unable to get the bin index for Filter since "{0}" ' \ 'is not one of the bins'.format(filter_bin) raise ValueError(msg) @@ -344,7 +344,7 @@ class Filter(object): def __repr__(self): string = 'Filter\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._type) - string += '{0: <16}"{1}""{2}"\n'.format('\tBins', '=\t', self._bins) - string += '{0: <16}"{1}""{2}"\n'.format('\tOffset', '=\t', self._offset) + string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type) + string += '{0: <16}{1}{2}\n'.format('\tBins', '=\t', self._bins) + string += '{0: <16}{1}{2}\n'.format('\tOffset', '=\t', self._offset) return string diff --git a/openmc/material.py b/openmc/material.py index 84498bf06..0f5a5a443 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -332,18 +332,18 @@ class Material(object): return nuclides - def _repr__(self): + def __repr__(self): string = 'Material\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id) - string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name) + string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) + string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) - string += '{0: <16}"{1}""{2}"'.format('\tDensity', '=\t', self._density) + string += '{0: <16}{1}{2}'.format('\tDensity', '=\t', self._density) string += ' ["{0}"]\n'.format(self._density_units) string += '{0: <16}\n'.format('\tS(a,b) Tables') for sab in self._sab: - string += '{0: <16}"{1}"["{2}""{3}"]\n'.format('\tS(a,b)', '=\t', + string += '{0: <16}{1}[{2}{3}]\n'.format('\tS(a,b)', '=\t', sab[0], sab[1]) string += '{0: <16}\n'.format('\tNuclides') @@ -351,16 +351,16 @@ class Material(object): for nuclide in self._nuclides: percent = self._nuclides[nuclide][1] percent_type = self._nuclides[nuclide][2] - string += '{0: <16}'.format('\t"{0}"'.format(nuclide)) - string += '=\t{0: <12} ["{1}"]\n'.format(percent, percent_type) + string += '{0: <16}'.format('\t{0}'.format(nuclide)) + string += '=\t{0: <12} [{1}]\n'.format(percent, percent_type) string += '{0: <16}\n'.format('\tElements') for element in self._elements: percent = self._nuclides[element][1] percent_type = self._nuclides[element][2] - string += '{0: >16}'.format('\t"{0}"'.format(element)) - string += '=\t{0: <12} ["{1}"]\n'.format(percent, percent_type) + string += '{0: >16}'.format('\t{0}'.format(element)) + string += '=\t{0: <12} [{1}]\n'.format(percent, percent_type) return string diff --git a/openmc/mesh.py b/openmc/mesh.py index 7ef371941..7e907aaa5 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -185,13 +185,13 @@ class Mesh(object): def __repr__(self): string = 'Mesh\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id) - string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name) - string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._type) - string += '{0: <16}"{1}""{2}"\n'.format('\tBasis', '=\t', self._dimension) - string += '{0: <16}"{1}""{2}"\n'.format('\tWidth', '=\t', self._lower_left) - string += '{0: <16}"{1}""{2}"\n'.format('\tOrigin', '=\t', self._upper_right) - string += '{0: <16}"{1}""{2}"\n'.format('\tPixels', '=\t', self._width) + string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) + string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) + string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type) + string += '{0: <16}{1}{2}\n'.format('\tBasis', '=\t', self._dimension) + string += '{0: <16}{1}{2}\n'.format('\tWidth', '=\t', self._lower_left) + string += '{0: <16}{1}{2}\n'.format('\tOrigin', '=\t', self._upper_right) + string += '{0: <16}{1}{2}\n'.format('\tPixels', '=\t', self._width) return string def get_mesh_xml(self): diff --git a/openmc/nuclide.py b/openmc/nuclide.py index cc0267c65..6f6f75f9c 100644 --- a/openmc/nuclide.py +++ b/openmc/nuclide.py @@ -89,7 +89,7 @@ class Nuclide(object): def __repr__(self): string = 'Nuclide - "{0}"\n'.format(self._name) - string += '{0: <16}"{1}""{2}"\n'.format('\tXS', '=\t', self._xs) + string += '{0: <16}{1}{2}\n'.format('\tXS', '=\t', self._xs) if self._zaid is not None: - string += '{0: <16}"{1}""{2}"\n'.format('\tZAID', '=\t', self._zaid) + string += '{0: <16}{1}{2}\n'.format('\tZAID', '=\t', self._zaid) return string diff --git a/openmc/particle_restart.py b/openmc/particle_restart.py index 41ac5f81a..d664de1ae 100644 --- a/openmc/particle_restart.py +++ b/openmc/particle_restart.py @@ -75,7 +75,7 @@ class Particle(object): self.uvw = self._get_double(3, path='uvw') def _get_data(self, n, typeCode, size): - return list(struct.unpack('="{0}""{1}"'.format(n, typeCode), + return list(struct.unpack('={0}{1}'.format(n, typeCode), self._f.read(n*size))) def _get_int(self, n=1, path=None): diff --git a/openmc/plots.py b/openmc/plots.py index c3131b753..66419a6ff 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -245,20 +245,20 @@ class Plot(object): def __repr__(self): string = 'Plot\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id) - string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name) - string += '{0: <16}"{1}""{2}"\n'.format('\tFilename', '=\t', self._filename) - string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._type) - string += '{0: <16}"{1}""{2}"\n'.format('\tBasis', '=\t', self._basis) - string += '{0: <16}"{1}""{2}"\n'.format('\tWidth', '=\t', self._width) - string += '{0: <16}"{1}""{2}"\n'.format('\tOrigin', '=\t', self._origin) - string += '{0: <16}"{1}""{2}"\n'.format('\tPixels', '=\t', self._origin) - string += '{0: <16}"{1}""{2}"\n'.format('\tColor', '=\t', self._color) - string += '{0: <16}"{1}""{2}"\n'.format('\tMask', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) + string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) + string += '{0: <16}{1}{2}\n'.format('\tFilename', '=\t', self._filename) + string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type) + string += '{0: <16}{1}{2}\n'.format('\tBasis', '=\t', self._basis) + string += '{0: <16}{1}{2}\n'.format('\tWidth', '=\t', self._width) + string += '{0: <16}{1}{2}\n'.format('\tOrigin', '=\t', self._origin) + string += '{0: <16}{1}{2}\n'.format('\tPixels', '=\t', self._origin) + string += '{0: <16}{1}{2}\n'.format('\tColor', '=\t', self._color) + string += '{0: <16}{1}{2}\n'.format('\tMask', '=\t', self._mask_components) - string += '{0: <16}"{1}""{2}"\n'.format('\tMask', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tMask', '=\t', self._mask_background) - string += '{0: <16}"{1}""{2}"\n'.format('\tCol Spec', '=\t', self._col_spec) + string += '{0: <16}{1}{2}\n'.format('\tCol Spec', '=\t', self._col_spec) return string def get_plot_xml(self): diff --git a/openmc/statepoint.py b/openmc/statepoint.py index ffee8c449..6a4713e91 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -36,10 +36,10 @@ class SourceSite(object): def __repr__(self): string = 'SourceSite\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tweight', '=\t', self._weight) - string += '{0: <16}"{1}""{2}"\n'.format('\tE', '=\t', self._E) - string += '{0: <16}"{1}""{2}"\n'.format('\t(x,y,z)', '=\t', self._xyz) - string += '{0: <16}"{1}""{2}"\n'.format('\t(u,v,w)', '=\t', self._uvw) + string += '{0: <16}{1}{2}\n'.format('\tweight', '=\t', self._weight) + string += '{0: <16}{1}{2}\n'.format('\tE', '=\t', self._E) + string += '{0: <16}{1}{2}\n'.format('\t(x,y,z)', '=\t', self._xyz) + string += '{0: <16}{1}{2}\n'.format('\t(u,v,w)', '=\t', self._uvw) return string @property @@ -230,21 +230,21 @@ class StatePoint(object): if self._cmfd_on == 1: - self._cmfd_indices = self._get_int(4, path='"{0}"/indices'.format(base)) + self._cmfd_indices = self._get_int(4, path='{0}/indices'.format(base)) self._k_cmfd = self._get_double(self._current_batch, - path='"{0}"/k_cmfd'.format(base)) + path='{0}/k_cmfd'.format(base)) self._cmfd_src = self._get_double_array(np.product(self._cmfd_indices), - path='"{0}"/cmfd_src'.format(base)) + path='{0}/cmfd_src'.format(base)) self._cmfd_src = np.reshape(self._cmfd_src, tuple(self._cmfd_indices), order='F') self._cmfd_entropy = self._get_double(self._current_batch, - path='"{0}"/cmfd_entropy'.format(base)) + path='{0}/cmfd_entropy'.format(base)) self._cmfd_balance = self._get_double(self._current_batch, - path='"{0}"/cmfd_balance'.format(base)) + path='{0}/cmfd_balance'.format(base)) self._cmfd_dominance = self._get_double(self._current_batch, - path='"{0}"/cmfd_dominance'.format(base)) + path='{0}/cmfd_dominance'.format(base)) self._cmfd_srccmp = self._get_double(self._current_batch, - path='"{0}"/cmfd_srccmp'.format(base)) + path='{0}/cmfd_srccmp'.format(base)) def _read_meshes(self): # Initialize dictionaries for the Meshes @@ -277,23 +277,23 @@ class StatePoint(object): for mesh_key in self._mesh_keys: # Read the user-specified Mesh ID and type - mesh_id = self._get_int(path='"{0}""{1}"/id'.format(base, mesh_key))[0] - mesh_type = self._get_int(path='"{0}""{1}"/type'.format(base, mesh_key))[0] + mesh_id = self._get_int(path='{0}{1}/id'.format(base, mesh_key))[0] + mesh_type = self._get_int(path='{0}{1}/type'.format(base, mesh_key))[0] # Get the Mesh dimension n_dimension = self._get_int( - path='"{0}""{1}"/n_dimension'.format(base, mesh_key))[0] + path='{0}{1}/n_dimension'.format(base, mesh_key))[0] # Read the mesh dimensions, lower-left coordinates, # upper-right coordinates, and width of each mesh cell dimension = self._get_int( - n_dimension, path='"{0}""{1}"/dimension'.format(base, mesh_key)) + n_dimension, path='{0}{1}/dimension'.format(base, mesh_key)) lower_left = self._get_double( - n_dimension, path='"{0}""{1}"/lower_left'.format(base, mesh_key)) + n_dimension, path='{0}{1}/lower_left'.format(base, mesh_key)) upper_right = self._get_double( - n_dimension, path='"{0}""{1}"/upper_right'.format(base, mesh_key)) + n_dimension, path='{0}{1}/upper_right'.format(base, mesh_key)) width = self._get_double( - n_dimension, path='"{0}""{1}"/width'.format(base, mesh_key)) + n_dimension, path='{0}{1}/width'.format(base, mesh_key)) # Create the Mesh and assign properties to it mesh = openmc.Mesh(mesh_id) @@ -340,11 +340,11 @@ class StatePoint(object): # Read integer Tally estimator type code (analog or tracklength) estimator_type = self._get_int( - path='"{0}""{1}"/estimator'.format(base, tally_key))[0] + path='{0}{1}/estimator'.format(base, tally_key))[0] # Read the Tally size specifications n_realizations = self._get_int( - path='"{0}""{1}"/n_realizations'.format(base, tally_key))[0] + path='{0}{1}/n_realizations'.format(base, tally_key))[0] # Create Tally object and assign basic properties tally = openmc.Tally(tally_key) @@ -353,41 +353,41 @@ class StatePoint(object): # Read the number of Filters n_filters = self._get_int( - path='"{0}""{1}"/n_filters'.format(base, tally_key))[0] + path='{0}{1}/n_filters'.format(base, tally_key))[0] - subbase = '"{0}""{1}"/filter '.format(base, tally_key) + subbase = '{0}{1}/filter '.format(base, tally_key) # Initialize all Filters for j in range(1, n_filters+1): # Read the integer Filter type code filter_type = self._get_int( - path='"{0}""{1}"/type'.format(subbase, j))[0] + path='{0}{1}/type'.format(subbase, j))[0] # Read the Filter offset offset = self._get_int( - path='"{0}""{1}"/offset'.format(subbase, j))[0] + path='{0}{1}/offset'.format(subbase, j))[0] n_bins = self._get_int( - path='"{0}""{1}"/n_bins'.format(subbase, j))[0] + path='{0}{1}/n_bins'.format(subbase, j))[0] if n_bins <= 0: - msg = 'Unable to create Filter "{0}" for Tally ID="{2}" ' \ + msg = 'Unable to create Filter "{0}" for Tally ID="{1}" ' \ 'since no bins were specified'.format(j, tally_key) raise ValueError(msg) # Read the bin values if FILTER_TYPES[filter_type] in ['energy', 'energyout']: bins = self._get_double( - n_bins+1, path='"{0}""{1}"/bins'.format(subbase, j)) + n_bins+1, path='{0}{1}/bins'.format(subbase, j)) elif FILTER_TYPES[filter_type] in ['mesh', 'distribcell']: bins = self._get_int( - path='"{0}""{1}"/bins'.format(subbase, j))[0] + path='{0}{1}/bins'.format(subbase, j))[0] else: bins = self._get_int( - n_bins, path='"{0}""{1}"/bins'.format(subbase, j)) + n_bins, path='{0}{1}/bins'.format(subbase, j)) # Create Filter object filter = openmc.Filter(FILTER_TYPES[filter_type], bins) @@ -403,10 +403,10 @@ class StatePoint(object): # Read Nuclide bins n_nuclides = self._get_int( - path='"{0}""{1}"/n_nuclides'.format(base, tally_key))[0] + path='{0}{1}/n_nuclides'.format(base, tally_key))[0] nuclide_zaids = self._get_int( - n_nuclides, path='"{0}""{1}"/nuclides'.format(base, tally_key)) + n_nuclides, path='{0}{1}/nuclides'.format(base, tally_key)) # Add all Nuclides to the Tally for nuclide_zaid in nuclide_zaids: @@ -414,14 +414,14 @@ class StatePoint(object): # Read score bins n_score_bins = self._get_int( - path='"{0}""{1}"/n_score_bins'.format(base, tally_key))[0] + path='{0}{1}/n_score_bins'.format(base, tally_key))[0] tally.num_score_bins = n_score_bins scores = [SCORE_TYPES[j] for j in self._get_int( - n_score_bins, path='"{0}""{1}"/score_bins'.format(base, tally_key))] + n_score_bins, path='{0}{1}/score_bins'.format(base, tally_key))] n_user_scores = self._get_int( - path='"{0}""{1}"/n_user_score_bins'.format(base, tally_key))[0] + path='{0}{1}/n_user_score_bins'.format(base, tally_key))[0] # Compute and set the filter strides for i in range(n_filters): @@ -433,12 +433,12 @@ class StatePoint(object): # Read scattering moment order strings (e.g., P3, Y-1,2, etc.) moments = [] - subbase = '"{0}""{1}"/moments/'.format(base, tally_key) + subbase = '{0}{1}/moments/'.format(base, tally_key) # Extract the moment order string for each score for k in range(len(scores)): moment = self._get_string(8, - path='"{0}"order"{1}"'.format(subbase, k+1)) + path='{0}order{1}'.format(subbase, k+1)) moment = moment.lstrip('[\'') moment = moment.rstrip('\']') @@ -500,7 +500,7 @@ class StatePoint(object): # Extract Tally data from the file if self._hdf5: - data = self._f['"{0}""{1}"/results'.format(base, tally_key)].value + data = self._f['{0}{1}/results'.format(base, tally_key)].value sum = data['sum'] sum_sq = data['sum_sq'] @@ -794,7 +794,7 @@ class StatePoint(object): self._with_summary = True def _get_data(self, n, typeCode, size): - return list(struct.unpack('="{0}""{1}"'.format(n, typeCode), + return list(struct.unpack('={0}{1}'.format(n, typeCode), self._f.read(n*size))) def _get_int(self, n=1, path=None): diff --git a/openmc/summary.py b/openmc/summary.py index 2815390d8..c0673ef23 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -18,7 +18,7 @@ class Summary(object): openmc.reset_auto_ids() if not filename.endswith(('.h5', '.hdf5')): - msg = 'Unable to open ""{0}"" which is not an HDF5 summary file' + msg = 'Unable to open "{0}" which is not an HDF5 summary file' raise ValueError(msg) self._f = h5py.File(filename, 'r') @@ -479,12 +479,12 @@ class Summary(object): for tally_key in tally_keys: tally_id = int(tally_key.strip('tally ')) - subbase = '"{0}""{1}"'.format(base, tally_id) + subbase = '{0}{1}'.format(base, tally_id) # Read Tally name metadata - name_size = self._f['"{0}"/name_size'.format(subbase)][0] + name_size = self._f['{0}/name_size'.format(subbase)][0] if (name_size > 0): - tally_name = self._f['"{0}"/name'.format(subbase)][0] + tally_name = self._f['{0}/name'.format(subbase)][0] tally_name = tally_name.lstrip('[\'') tally_name = tally_name.rstrip('\']') else: @@ -494,27 +494,27 @@ class Summary(object): tally = openmc.Tally(tally_id, tally_name) # Read score metadata - score_bins = self._f['"{0}"/score_bins'.format(subbase)][...] + score_bins = self._f['{0}/score_bins'.format(subbase)][...] for score_bin in score_bins: tally.add_score(openmc.SCORE_TYPES[score_bin]) - num_score_bins = self._f['"{0}"/n_score_bins'.format(subbase)][...] + num_score_bins = self._f['{0}/n_score_bins'.format(subbase)][...] tally.num_score_bins = num_score_bins # Read filter metadata - num_filters = self._f['"{0}"/n_filters'.format(subbase)][0] + num_filters = self._f['{0}/n_filters'.format(subbase)][0] # Initialize all Filters for j in range(1, num_filters+1): - subsubbase = '"{0}"/filter "{1}"'.format(subbase, j) + subsubbase = '{0}/filter {1}'.format(subbase, j) # Read filter type (e.g., "cell", "energy", etc.) - filter_type_code = self._f['"{0}"/type'.format(subsubbase)][0] + filter_type_code = self._f['{0}/type'.format(subsubbase)][0] filter_type = openmc.FILTER_TYPES[filter_type_code] # Read the filter bins - num_bins = self._f['"{0}"/n_bins'.format(subsubbase)][0] - bins = self._f['"{0}"/bins'.format(subsubbase)][...] + num_bins = self._f['{0}/n_bins'.format(subsubbase)][0] + bins = self._f['{0}/bins'.format(subsubbase)][...] # Create Filter object filter = openmc.Filter(filter_type, bins) diff --git a/openmc/surface.py b/openmc/surface.py index 0d2e8fb27..d5d258fa7 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -111,15 +111,15 @@ class Surface(object): def __repr__(self): string = 'Surface\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id) - string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name) - string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._type) - string += '{0: <16}"{1}""{2}"\n'.format('\tBoundary', '=\t', self._boundary_type) + string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) + string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) + string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type) + string += '{0: <16}{1}{2}\n'.format('\tBoundary', '=\t', self._boundary_type) coeffs = '{0: <16}'.format('\tCoefficients') + '\n' for coeff in self._coeffs: - coeffs += '{0: <16}"{1}""{2}"\n'.format(coeff, '=\t', self._coeffs[coeff]) + coeffs += '{0: <16}{1}{2}\n'.format(coeff, '=\t', self._coeffs[coeff]) string += coeffs diff --git a/openmc/tallies.py b/openmc/tallies.py index 9474ef8fa..b5d626722 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -298,7 +298,7 @@ class Tally(object): if not isinstance(trigger, Trigger): msg = 'Unable to add a tally trigger for Tally ID="{0}" to ' \ - 'since ""{1}"" is not a Trigger'.format(self.id, trigger) + 'since "{1}" is not a Trigger'.format(self.id, trigger) raise ValueError(msg) self._triggers.append(trigger) @@ -330,7 +330,7 @@ class Tally(object): """ if not isinstance(filter, Filter): - msg = 'Unable to add Filter ""{0}"" to Tally ID="{1}" since it is ' \ + msg = 'Unable to add Filter "{0}" to Tally ID="{1}" since it is ' \ 'not a Filter object'.format(filter, self.id) raise ValueError(msg) @@ -359,7 +359,7 @@ class Tally(object): """ if not isinstance(score, basestring): - msg = 'Unable to add score ""{0}"" to Tally ID="{1}" since it is ' \ + msg = 'Unable to add score "{0}" to Tally ID="{1}" since it is ' \ 'not a string'.format(score, self.id) raise ValueError(msg) @@ -405,7 +405,7 @@ class Tally(object): """ if score not in self.scores: - msg = 'Unable to remove score ""{0}"" from Tally ID="{1}" since the ' \ + msg = 'Unable to remove score "{0}" from Tally ID="{1}" since the ' \ 'Tally does not contain this score'.format(score, self.id) ValueError(msg) @@ -422,7 +422,7 @@ class Tally(object): """ if filter not in self.filters: - msg = 'Unable to remove filter ""{0}"" from Tally ID="{1}" since the ' \ + msg = 'Unable to remove filter "{0}" from Tally ID="{1}" since the ' \ 'Tally does not contain this filter'.format(filter, self.id) ValueError(msg) @@ -439,7 +439,7 @@ class Tally(object): """ if nuclide not in self.nuclides: - msg = 'Unable to remove nuclide ""{0}"" from Tally ID="{1}" since the ' \ + msg = 'Unable to remove nuclide "{0}" from Tally ID="{1}" since the ' \ 'Tally does not contain this nuclide'.format(nuclide, self.id) ValueError(msg) @@ -470,27 +470,27 @@ class Tally(object): def __repr__(self): string = 'Tally\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self.id) - string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self.name) + string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self.id) + string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self.name) string += '{0: <16}\n'.format('\tFilters') for filter in self.filters: - string += '{0: <16}\t\t"{1}"\t"{2}"\n'.format('', filter.type, + string += '{0: <16}\t\t{1}\t{2}\n'.format('', filter.type, filter.bins) - string += '{0: <16}"{1}"'.format('\tNuclides', '=\t') + string += '{0: <16}{1}'.format('\tNuclides', '=\t') for nuclide in self.nuclides: if isinstance(nuclide, Nuclide): - string += '"{0}" '.format(nuclide.name) + string += '{0} '.format(nuclide.name) else: - string += '"{0}" '.format(nuclide) + string += '{0} '.format(nuclide) string += '\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tScores', '=\t', self.scores) - string += '{0: <16}"{1}""{2}"\n'.format('\tEstimator', '=\t', self.estimator) + string += '{0: <16}{1}{2}\n'.format('\tScores', '=\t', self.scores) + string += '{0: <16}{1}{2}\n'.format('\tEstimator', '=\t', self.estimator) return string @@ -681,7 +681,7 @@ class Tally(object): # If we did not find the Filter, throw an Exception if filter is None: - msg = 'Unable to find filter type ""{0}"" in ' \ + msg = 'Unable to find filter type "{0}" in ' \ 'Tally ID="{1}"'.format(filter_type, self.id) raise ValueError(msg) @@ -756,7 +756,7 @@ class Tally(object): break if nuclide_index == -1: - msg = 'Unable to get the nuclide index for Tally since ""{0}"" ' \ + msg = 'Unable to get the nuclide index for Tally since "{0}" ' \ 'is not one of the nuclides'.format(nuclide) raise KeyError(msg) else: @@ -787,7 +787,7 @@ class Tally(object): score_index = self.scores.index(score) except ValueError: - msg = 'Unable to get the score index for Tally since ""{0}"" ' \ + msg = 'Unable to get the score index for Tally since "{0}" ' \ 'is not one of the scores'.format(score) raise ValueError(msg) @@ -945,7 +945,7 @@ class Tally(object): data = self.sum_sq[indices] else: msg = 'Unable to return results from Tally ID="{0}" since the ' \ - 'the requested value ""{1}"" is not \'mean\', \'std_dev\', ' \ + 'the requested value "{1}" is not \'mean\', \'std_dev\', ' \ '\rel_err\', \'sum\', or \'sum_sq\''.format(self.id, value) raise LookupError(msg) @@ -1299,19 +1299,19 @@ class Tally(object): if not isinstance(filename, basestring): msg = 'Unable to export the results for Tally ID="{0}" to ' \ - 'filename=""{1}"" since it is not a ' \ + 'filename="{1}" since it is not a ' \ 'string'.format(self.id, filename) raise ValueError(msg) elif not isinstance(directory, basestring): msg = 'Unable to export the results for Tally ID="{0}" to ' \ - 'directory=""{1}"" since it is not a ' \ + 'directory="{1}" since it is not a ' \ 'string'.format(self.id, directory) raise ValueError(msg) elif format not in ['hdf5', 'pkl', 'csv']: msg = 'Unable to export the results for Tally ID="{0}" to format ' \ - '""{1}"" since it is not supported'.format(self.id, format) + '"{1}" since it is not supported'.format(self.id, format) raise ValueError(msg) elif not isinstance(append, bool): diff --git a/openmc/trigger.py b/openmc/trigger.py index a75ce4d16..569ccf768 100644 --- a/openmc/trigger.py +++ b/openmc/trigger.py @@ -104,9 +104,9 @@ class Trigger(object): def __repr__(self): string = 'Trigger\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._trigger_type) - string += '{0: <16}"{1}""{2}"\n'.format('\tThreshold', '=\t', self._threshold) - string += '{0: <16}"{1}""{2}"\n'.format('\tScores', '=\t', self._scores) + string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._trigger_type) + string += '{0: <16}{1}{2}\n'.format('\tThreshold', '=\t', self._threshold) + string += '{0: <16}{1}{2}\n'.format('\tScores', '=\t', self._scores) return string def get_trigger_xml(self, element): diff --git a/openmc/universe.py b/openmc/universe.py index 89699f017..b7ec86937 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -289,31 +289,31 @@ class Cell(object): def __repr__(self): string = 'Cell\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id) - string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name) + string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) + string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) if isinstance(self._fill, openmc.Material): - string += '{0: <16}"{1}""{2}"\n'.format('\tMaterial', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tMaterial', '=\t', self._fill._id) elif isinstance(self._fill, (Universe, Lattice)): - string += '{0: <16}"{1}""{2}"\n'.format('\tFill', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tFill', '=\t', self._fill._id) else: - string += '{0: <16}"{1}""{2}"\n'.format('\tFill', '=\t', self._fill) + string += '{0: <16}{1}{2}\n'.format('\tFill', '=\t', self._fill) - string += '{0: <16}"{1}"\n'.format('\tSurfaces', '=\t') + string += '{0: <16}{1}\n'.format('\tSurfaces', '=\t') for surface_id in self._surfaces: halfspace = self._surfaces[surface_id][1] - string += '"{0}" '.format(halfspace * surface_id) + string += '{0} '.format(halfspace * surface_id) string = string.rstrip(' ') + '\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tRotation', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tRotation', '=\t', self._rotation) - string += '{0: <16}"{1}""{2}"\n'.format('\tTranslation', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tTranslation', '=\t', self._translation) - string += '{0: <16}"{1}""{2}"\n'.format('\tOffset', '=\t', self._offsets) + string += '{0: <16}{1}{2}\n'.format('\tOffset', '=\t', self._offsets) return string @@ -582,11 +582,11 @@ class Universe(object): def __repr__(self): string = 'Universe\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id) - string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name) - string += '{0: <16}"{1}""{2}"\n'.format('\tCells', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) + string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) + string += '{0: <16}{1}{2}\n'.format('\tCells', '=\t', list(self._cells.keys())) - string += '{0: <16}"{1}""{2}"\n'.format('\t# Regions', '=\t', + string += '{0: <16}{1}{2}\n'.format('\t# Regions', '=\t', self._num_regions) return string @@ -870,26 +870,26 @@ class RectLattice(Lattice): def __repr__(self): string = 'RectLattice\n' - string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id) - string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name) - string += '{0: <16}"{1}""{2}"\n'.format('\tDimension', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) + string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) + string += '{0: <16}{1}{2}\n'.format('\tDimension', '=\t', self._dimension) - string += '{0: <16}"{1}""{2}"\n'.format('\tLower Left', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tLower Left', '=\t', self._lower_left) - string += '{0: <16}"{1}""{2}"\n'.format('\tPitch', '=\t', self._pitch) + string += '{0: <16}{1}{2}\n'.format('\tPitch', '=\t', self._pitch) if self._outer is not None: - string += '{0: <16}"{1}""{2}"\n'.format('\tOuter', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tOuter', '=\t', self._outer._id) else: - string += '{0: <16}"{1}""{2}"\n'.format('\tOuter', '=\t', + string += '{0: <16}{1}{2}\n'.format('\tOuter', '=\t', self._outer) string += '{0: <16}\n'.format('\tUniverses') # Lattice nested Universe IDs - column major for Fortran for i, universe in enumerate(np.ravel(self._universes)): - string += '"{0}" '.format(universe._id) + string += '{0} '.format(universe._id) # Add a newline character every time we reach end of row of cells if (i+1) % self._dimension[-1] == 0: @@ -902,7 +902,7 @@ class RectLattice(Lattice): # Lattice cell offsets for i, offset in enumerate(np.ravel(self._offsets)): - string += '"{0}" '.format(offset) + string += '{0} '.format(offset) # Add a newline character when we reach end of row of cells if (i+1) % self._dimension[-1] == 0: @@ -914,7 +914,7 @@ class RectLattice(Lattice): def create_xml_subelement(self, xml_element): # Determine if XML element already contains subelement for this Lattice - path = './lattice[@id=\'"{0}"\']'.format(self._id) + path = './lattice[@id=\'{0}\']'.format(self._id) test = xml_element.find(path) # If the element does contain the Lattice subelement, then return @@ -934,7 +934,7 @@ class RectLattice(Lattice): # Export the Lattice outer Universe (if specified) if self._outer is not None: outer = ET.SubElement(lattice_subelement, "outer") - outer.text = '"{0}"'.format(self._outer._id) + outer.text = '{0}'.format(self._outer._id) self._outer.create_xml_subelement(xml_element) # Export Lattice cell dimensions @@ -956,7 +956,7 @@ class RectLattice(Lattice): universe = self._universes[x][y][z] # Append Universe ID to the Lattice XML subelement - universe_ids += '"{0}" '.format(universe._id) + universe_ids += '{0} '.format(universe._id) # Create XML subelement for this Universe universe.create_xml_subelement(xml_element) @@ -974,7 +974,7 @@ class RectLattice(Lattice): universe = self._universes[x][y] # Append Universe ID to Lattice XML subelement - universe_ids += '"{0}" '.format(universe._id) + universe_ids += '{0} '.format(universe._id) # Create XML subelement for this Universe universe.create_xml_subelement(xml_element)