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

Correction for histogram interpolation of Tabular distributions #2981

Merged
merged 3 commits into from
May 25, 2024

Conversation

pshriwise
Copy link
Contributor

Description

The openmc.stats.Tabular class assumes that the length of the probabilities provided is equal to the length of the table values. This causes errors when one passes N -1 probabilities for N table values in histogram interpolation

image

because we index into the probabilities as [:-1]. This changes that index based on the size of the table values.

Several warnings have also been added in the Tabular.p property setter to check its length against the size of the table values (if they are set).

Checklist

  • I have performed a self-review of my own code
    - [ ] I have run clang-format (version 15) 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)

…on. Update slice index based on table values for histogram interpolation
@pshriwise pshriwise requested a review from paulromano April 26, 2024 21:34
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.

@pshriwise I've updated this branch based on our offline discussion. Namely, now the x and p attributes do not have a setter so that the object cannot be in an invalid state. The warnings were turned into exceptions. However, note that the warning for the size of p and x being the same for histogram interpolation was removed since this is used quite often throughout the nuclear data API, so I didn't want to mess around too much with that. If you're OK with the changes I made, let me know and we can merge (or simply go ahead and hit the merge button yourself).

@pshriwise
Copy link
Contributor Author

@pshriwise I've updated this branch based on our offline discussion. Namely, now the x and p attributes do not have a setter so that the object cannot be in an invalid state. The warnings were turned into exceptions. However, note that the warning for the size of p and x being the same for histogram interpolation was removed since this is used quite often throughout the nuclear data API, so I didn't want to mess around too much with that. If you're OK with the changes I made, let me know and we can merge (or simply go ahead and hit the merge button yourself).

Thanks for making those updates @paulromano! This fell off my radar after your last review.

@pshriwise pshriwise merged commit 0b686e3 into openmc-dev:develop May 25, 2024
18 checks passed
church89 pushed a commit to openmsr/openmc that referenced this pull request Jul 18, 2024
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