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

Plot xs has TypeError with ostensibly allowable argument #3177

Open
MicahGale opened this issue Oct 23, 2024 · 2 comments · May be fixed by #3178
Open

Plot xs has TypeError with ostensibly allowable argument #3177

MicahGale opened this issue Oct 23, 2024 · 2 comments · May be fixed by #3178
Labels

Comments

@MicahGale
Copy link
Contributor

Bug Description

An unclear TypeError is raised by plot_xs when given the improper arguments.

Steps to Reproduce

import openmc
openmc.plot_xs({"U-238": "capture"})
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[3], line 1
----> 1 openmc.plot_xs({"U-238": "capture"})

File ~/mambaforge/envs/openmc/lib/python3.12/site-packages/openmc/plotter.py:200, in plot_xs(reactions, divisor_types, temperature, axis, sab_name, ce_cross_sections, mg_cross_sections, enrichment, plot_CE, orders, divisor_orders, energy_axis_units, **kwargs)
    197 all_types = []
    199 for this, types in reactions.items():
--> 200     all_types = all_types + types
    202     if plot_CE:
    203         cv.check_type("this", this, (str, openmc.Material))

TypeError: can only concatenate list (not "str") to list

In my first reading the documentation {"U-238": "capture"} seemed completely valid:

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.

Environment

  • openmc: 0.15.0
  • python: 3.12
@MicahGale MicahGale added the Bugs label Oct 23, 2024
@shimwell shimwell linked a pull request Oct 23, 2024 that will close this issue
3 tasks
@shimwell
Copy link
Member

shimwell commented Oct 23, 2024

might need to be something like this,

openmc.plot_xs({"U238": ["capture"]})

Would a change to the doc string like this PR help @MicahGale

@MicahGale
Copy link
Contributor Author

Yes that is the correct way.

The docs should be clarified, but also the type enforcement should be stricter, and clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants