Adding energy axis units to plot xs (#2876)

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
Jonathan Shimwell 2024-02-29 01:31:54 +00:00 committed by GitHub
parent 02c0a09281
commit b75ccd598e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 4 deletions

View file

@ -77,10 +77,19 @@ def test_plot_xs(this):
from matplotlib.figure import Figure
assert isinstance(openmc.plot_xs({this: ['total', 'elastic']}), Figure)
def test_plot_xs_mat(test_mat):
from matplotlib.figure import Figure
assert isinstance(openmc.plot_xs({test_mat: ['total']}), Figure)
@pytest.mark.parametrize("units", ["eV", "keV", "MeV"])
def test_plot_xs_energy_axis(units):
plot = openmc.plot_xs({'Be9': ['(n,2n)']}, energy_axis_units=units)
axis_text = plot.get_axes()[0].get_xaxis().get_label().get_text()
assert axis_text == f'Energy [{units}]'
def test_plot_axes_labels():
# just nuclides
axis_label = openmc.plotter._get_yaxis_label(
@ -156,4 +165,4 @@ def test_get_title():
mat1.set_density('g/cm3', 1)
mat1.name = 'my_mat'
title = openmc.plotter._get_title(reactions={mat1: [205]})
assert title == 'Cross Section Plot For my_mat'
assert title == 'Cross Section Plot For my_mat'