Skip to content

Commit

Permalink
Updating file extension for Excel files when exporting MGXS data (ope…
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise authored and church89 committed Jul 18, 2024
1 parent d9ce23b commit 0121be9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions openmc/mgxs/mdgxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,9 @@ def export_xs_data(self, filename='mgxs', directory='mgxs',
df.to_csv(filename + '.csv', index=False)
elif format == 'excel':
if self.domain_type == 'mesh':
df.to_excel(filename + '.xls')
df.to_excel(filename + '.xlsx')
else:
df.to_excel(filename + '.xls', index=False)
df.to_excel(filename + '.xlsx', index=False)
elif format == 'pickle':
df.to_pickle(filename + '.pkl')
elif format == 'latex':
Expand Down
4 changes: 2 additions & 2 deletions openmc/mgxs/mgxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2001,9 +2001,9 @@ def export_xs_data(self, filename='mgxs', directory='mgxs',
df.to_csv(filename + '.csv', index=False)
elif format == 'excel':
if self.domain_type == 'mesh':
df.to_excel(filename + '.xls')
df.to_excel(filename + '.xlsx')
else:
df.to_excel(filename + '.xls', index=False)
df.to_excel(filename + '.xlsx', index=False)
elif format == 'pickle':
df.to_pickle(filename + '.pkl')
elif format == 'latex':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
'depletion-mpi': ['mpi4py'],
'docs': ['sphinx', 'sphinxcontrib-katex', 'sphinx-numfig', 'jupyter',
'sphinxcontrib-svg2pdfconverter', 'sphinx-rtd-theme'],
'test': ['pytest', 'pytest-cov', 'colorama'],
'test': ['pytest', 'pytest-cov', 'colorama', 'openpyxl'],
'vtk': ['vtk'],
},
# Cython is used to add resonance reconstruction and fast float_endf
Expand Down
10 changes: 7 additions & 3 deletions tests/regression_tests/mgxs_library_hdf5/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def _get_results(self, hash_output=False):
# Export the MGXS Library to an HDF5 file
self.mgxs_lib.build_hdf5_store(directory='.')

# Test export of the MGXS Library to an Excel spreadsheet
for mgxs in self.mgxs_lib.all_mgxs.values():
for xs in mgxs.values():
xs.export_xs_data('mgxs', xs_type='macro', format='excel')

# Open the MGXS HDF5 file
with h5py.File('mgxs.h5', 'r') as f:

Expand All @@ -76,9 +81,8 @@ def _get_results(self, hash_output=False):

def _cleanup(self):
super()._cleanup()
f = 'mgxs.h5'
if os.path.exists(f):
os.remove(f)
files = ['mgxs.h5', 'mgxs.xlsx']
(os.remove(f) for f in files if os.path.exists(f))


def test_mgxs_library_hdf5():
Expand Down

0 comments on commit 0121be9

Please sign in to comment.