Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating file extension for Excel files when exporting MGXS data #2852

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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