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

This commit is contained in:
Patrick Shriwise 2024-01-19 15:32:43 -06:00 committed by GitHub
parent 187160d082
commit 0785500bc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 8 deletions

View file

@ -743,9 +743,9 @@ class MDGXS(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':

View file

@ -2001,9 +2001,9 @@ class 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':

View file

@ -71,7 +71,7 @@ kwargs = {
'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

View file

@ -54,6 +54,11 @@ class MGXSTestHarness(PyAPITestHarness):
# 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:
@ -76,9 +81,8 @@ class MGXSTestHarness(PyAPITestHarness):
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():