From 7552123c762a13be49269bf3c5bf393635109766 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 29 Oct 2024 18:05:40 +0100 Subject: [PATCH] added list to doc string arg for plot_xs (#3178) --- openmc/plotter.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/openmc/plotter.py b/openmc/plotter.py index 8b205b79d8b..c3b951ad893 100644 --- a/openmc/plotter.py +++ b/openmc/plotter.py @@ -1,5 +1,10 @@ +# annotations package is required to enable postponed evaluation of type +# hints in conjugation with the | operator. This avoids TypeError: +# unsupported operand type(s) for |: 'str' and 'NoneType' error +from __future__ import annotations from itertools import chain from numbers import Integral, Real +from typing import Dict, Iterable, List import numpy as np @@ -120,18 +125,29 @@ def _get_title(reactions): return 'Cross Section Plot' -def plot_xs(reactions, divisor_types=None, temperature=294., axis=None, - sab_name=None, ce_cross_sections=None, mg_cross_sections=None, - enrichment=None, plot_CE=True, orders=None, divisor_orders=None, - energy_axis_units="eV", **kwargs): +def plot_xs( + reactions: Dict[str, openmc.Material | List[str]], + divisor_types: Iterable[str] | None = None, + temperature: float = 294.0, + axis: "plt.Axes" | None = None, + sab_name: str | None = None, + ce_cross_sections: str | None = None, + mg_cross_sections: str | None = None, + enrichment: float | None = None, + plot_CE: bool = True, + orders: Iterable[int] | None = None, + divisor_orders: Iterable[int] | None = None, + energy_axis_units: str = "eV", + **kwargs, +) -> "plt.Figure": """Creates a figure of continuous-energy cross sections for this item. Parameters ---------- reactions : dict keys can be either a nuclide or element in string form or an - openmc.Material object. Values are the type of cross sections to - include in the plot. + openmc.Material object. Values are a list of the types of + cross sections to include in the plot. divisor_types : Iterable of values of PLOT_TYPES, optional Cross section types which will divide those produced by types before plotting. A type of 'unity' can be used to effectively not