Remove convert arguments from Model.plot_geometry

This commit is contained in:
Paul Romano 2021-10-05 13:42:27 -05:00
parent 75b3d18446
commit 7b070b7154
2 changed files with 8 additions and 36 deletions

View file

@ -624,15 +624,9 @@ class Model:
openmc.lib.materials[domain_id].volume = \
vol_calc.volumes[domain_id].n
def plot_geometry(self, output=True, cwd='.', openmc_exec='openmc',
convert=True, convert_exec='convert'):
def plot_geometry(self, output=True, cwd='.', openmc_exec='openmc'):
"""Creates plot images as specified by the Model.plots attribute
If convert is True, this function requires that a program is installed
to convert PPM files to PNG files. Typically, that would be
`ImageMagick <https://www.imagemagick.org>`_ which includes a
`convert` command.
.. versionadded:: 0.13.0
Parameters
@ -645,10 +639,7 @@ class Model:
openmc_exec : str, optional
Path to OpenMC executable. Defaults to 'openmc'.
This only applies to the case when not using the C API.
convert : bool, optional
Whether or not to attempt to convert from PPM to PNG
convert_exec : str, optional
Command that can convert PPM files into PNG files
"""
if len(self.plots) == 0:
@ -664,15 +655,6 @@ class Model:
self.export_to_xml()
openmc.plot_geometry(output=output, openmc_exec=openmc_exec)
if convert:
for p in self.plots:
if p.filename is not None:
ppm_file = f'{p.filename}.ppm'
else:
ppm_file = f'plot_{p.id}.ppm'
png_file = ppm_file.replace('.ppm', '.png')
subprocess.check_call([convert_exec, ppm_file, png_file])
def _change_py_lib_attribs(self, names_or_ids, value, obj_type,
attrib_name, density_units='atom/b-cm'):
# Method to do the same work whether it is a cell or material and

View file

@ -332,27 +332,17 @@ def test_plots(run_in_tmpdir, pin_model_attributes, mpi_intracomm):
# check that a plot was made and that the expected ppm and png files are
# there
# We will only test convert if it is on the system, so as not to add an
# extra dependency just for tests
convert = which('convert') is not None
if convert:
exts = ['ppm', 'png']
else:
exts = ['ppm']
# We will run the test twice, the first time without C API, the second with
for i in range(2):
if i == 1:
test_model.init_lib(output=False, intracomm=mpi_intracomm)
test_model.plot_geometry(output=False, convert=convert)
test_model.plot_geometry(output=False)
# Now look for the files, expect to find test.ppm, plot_2.ppm, and if
# convert is True, test.png, plot_2.png
for fname in ['test.', 'plot_2.']:
for ext in exts:
test_file = Path(f'./{fname}{ext}')
assert test_file.exists()
test_file.unlink()
# Now look for the files
for fname in ('test.png', 'plot_2.png'):
test_file = Path(fname)
assert test_file.exists()
test_file.unlink()
test_model.finalize_lib()