Skip to content

Commit

Permalink
Merge pull request #575 from wbinventor/mgxs-better-comparisons
Browse files Browse the repository at this point in the history
Remove NumPy Elementwise Comparison Warnings from openmc.mgxs
  • Loading branch information
paulromano committed Jan 28, 2016
2 parents c4e5f43 + e570f53 commit 2760551
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions openmc/mgxs/mgxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,14 @@ def get_xs(self, groups='all', subdomains='all', nuclides='all',
filter_bins = []

# Construct a collection of the domain filter bins
if subdomains != 'all':
if not isinstance(subdomains, basestring):
cv.check_iterable_type('subdomains', subdomains, Integral)
for subdomain in subdomains:
filters.append(self.domain_type)
filter_bins.append((subdomain,))

# Construct list of energy group bounds tuples for all requested groups
if groups != 'all':
if not isinstance(groups, basestring):
cv.check_iterable_type('groups', groups, Integral)
for group in groups:
filters.append('energy')
Expand Down Expand Up @@ -838,7 +838,7 @@ def get_subdomain_avg_xs(self, subdomains='all'):
"""

# Construct a collection of the subdomain filter bins to average across
if subdomains != 'all':
if not isinstance(subdomains, basestring):
cv.check_iterable_type('subdomains', subdomains, Integral)
elif self.domain_type == 'distribcell':
subdomains = np.arange(self.num_subdomains)
Expand Down Expand Up @@ -881,7 +881,7 @@ def print_xs(self, subdomains='all', nuclides='all', xs_type='macro'):
"""

# Construct a collection of the subdomains to report
if subdomains != 'all':
if not isinstance(subdomains, basestring):
cv.check_iterable_type('subdomains', subdomains, Integral)
elif self.domain_type == 'distribcell':
subdomains = np.arange(self.num_subdomains, dtype=np.int)
Expand Down Expand Up @@ -1010,7 +1010,7 @@ def build_hdf5_store(self, filename='mgxs.h5', directory='mgxs',
xs_results = h5py.File(filename, 'w')

# Construct a collection of the subdomains to report
if subdomains != 'all':
if not isinstance(subdomains, basestring):
cv.check_iterable_type('subdomains', subdomains, Integral)
elif self.domain_type == 'distribcell':
subdomains = np.arange(self.num_subdomains, dtype=np.int)
Expand Down Expand Up @@ -1192,7 +1192,7 @@ def get_pandas_dataframe(self, groups='all', nuclides='all',
"""

if groups != 'all':
if not isinstance(groups, basestring):
cv.check_iterable_type('groups', groups, Integral)
if nuclides != 'all' and nuclides != 'sum':
cv.check_iterable_type('nuclides', nuclides, basestring)
Expand Down Expand Up @@ -1252,7 +1252,7 @@ def get_pandas_dataframe(self, groups='all', nuclides='all',
columns = ['group in']

# Select out those groups the user requested
if groups != 'all':
if not isinstance(groups, basestring):
if 'group in' in df:
df = df[df['group in'].isin(groups)]
if 'group out' in df:
Expand Down Expand Up @@ -1789,21 +1789,21 @@ def get_xs(self, in_groups='all', out_groups='all',
filter_bins = []

# Construct a collection of the domain filter bins
if subdomains != 'all':
if not isinstance(subdomains, basestring):
cv.check_iterable_type('subdomains', subdomains, Integral)
for subdomain in subdomains:
filters.append(self.domain_type)
filter_bins.append((subdomain,))

# Construct list of energy group bounds tuples for all requested groups
if in_groups != 'all':
if not isinstance(in_groups, basestring):
cv.check_iterable_type('groups', in_groups, Integral)
for group in in_groups:
filters.append('energy')
filter_bins.append((self.energy_groups.get_group_bounds(group),))

# Construct list of energy group bounds tuples for all requested groups
if out_groups != 'all':
if not isinstance(out_groups, basestring):
cv.check_iterable_type('groups', out_groups, Integral)
for group in out_groups:
filters.append('energyout')
Expand Down Expand Up @@ -1887,7 +1887,7 @@ def print_xs(self, subdomains='all', nuclides='all', xs_type='macro'):
"""

# Construct a collection of the subdomains to report
if subdomains != 'all':
if not isinstance(subdomains, basestring):
cv.check_iterable_type('subdomains', subdomains, Integral)
elif self.domain_type == 'distribcell':
subdomains = np.arange(self.num_subdomains, dtype=np.int)
Expand Down Expand Up @@ -1926,12 +1926,6 @@ def print_xs(self, subdomains='all', nuclides='all', xs_type='macro'):
bounds = self.energy_groups.get_group_bounds(group)
string += template.format('', group, bounds[0], bounds[1])

if subdomains == 'all':
if self.domain_type == 'distribcell':
subdomains = np.arange(self.num_subdomains, dtype=np.int)
else:
subdomains = [self.domain.id]

# Loop over all subdomains
for subdomain in subdomains:

Expand Down Expand Up @@ -2135,14 +2129,14 @@ def get_xs(self, groups='all', subdomains='all', nuclides='all',
filter_bins = []

# Construct a collection of the domain filter bins
if subdomains != 'all':
if not isinstance(subdomains, basestring):
cv.check_iterable_type('subdomains', subdomains, Integral)
for subdomain in subdomains:
filters.append(self.domain_type)
filter_bins.append((subdomain,))

# Construct list of energy group bounds tuples for all requested groups
if groups != 'all':
if not isinstance(groups, basestring):
cv.check_iterable_type('groups', groups, Integral)
for group in groups:
filters.append('energyout')
Expand Down

0 comments on commit 2760551

Please sign in to comment.