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

Adding helpful info to keyerror for StepResults.get_material #2674

Conversation

shimwell
Copy link
Member

Description

Inspired by this user story

This PR proposes adding to the error message that a user gets when trying to access a material id in the StepResult.get_material() that is not present.

import openmc
import openmc.deplete
results = openmc.deplete.Results.from_hdf5('depletion_results.h5')
step=results[0]
step.get_material('42')

current behaviour

>>> KeyError: '42'

proposed behaviour

KeyError: "mat_id '42' not found in StepResult. Available mat_id values are ['1', '2', '3']"

Checklist

  • I have performed a self-review of my own code
    - [ ] I have run clang-format on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
    - [ ] I have added tests that prove my fix is effective or that my feature works (if applicable)<\s>

Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @shimwell!

@paulromano paulromano enabled auto-merge (squash) September 1, 2023 13:49
@paulromano paulromano merged commit 20877c6 into openmc-dev:develop Sep 1, 2023
16 checks passed
stchaker pushed a commit to stchaker/openmc that referenced this pull request Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants