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

Fix a bug in database compare. #1258

Merged
merged 6 commits into from
May 5, 2023
Merged

Fix a bug in database compare. #1258

merged 6 commits into from
May 5, 2023

Conversation

mgjarrett
Copy link
Contributor

@mgjarrett mgjarrett commented May 4, 2023

Description


There's a line in compareDB3.py that tries to call a method that doesn't exist, DiffResults.add()

This has been around for a long time, but we have somehow just coincidentally not been hitting it.

Also, another call to addDiff needed to be updated to pass numpy.inf as a scalar instead of a list.

Checklist

  • This PR has only one purpose or idea.
  • Tests have been added/updated to verify that the new/changed code works.
  • The release notes (location doc/release/0.X.rst) are up-to-date with any bug fixes or new features.
  • The documentation is still up-to-date in the doc folder.
  • The dependencies are still up-to-date in setup.py.

@@ -329,7 +329,7 @@ def _diffSpecialData(
diffResults.addStructureDiffs(nDiffs)

if not keysMatch:
diffResults.addDiff(name, name, [numpy.inf], [numpy.inf], [numpy.inf])
Copy link
Member

Choose a reason for hiding this comment

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

can you describe in the PR why the brackets were removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, addDiff expects three floats based on the type hints:

def addDiff(
self, compType: str, paramName: str, absMean: float, mean: float, absMax: float
) -> None:

And it compares these three parameters with >, which doesn't work on a list.

@mgjarrett
Copy link
Contributor Author

I was able to add a unit test for one of the bad function calls.

For the second one, where the name of the function was wrong (add() instead of addDiff()), I have not been able to get the unit test to hit the line. To get here, we have to read some data src from an HDF5 dataset, iterate throught src.tolist() which ostensibly creates regular python lists, and then check if any of the items created by tolist() are numpy.ndarray instead of a regular list. I don't know how to make this happen, and I'm not sure how I happened upon it yesterday. For now I'll settle for leaving the line uncovered; I know the fix works because I tried it on my in-use case that was failing.

@mgjarrett mgjarrett marked this pull request as ready for review May 5, 2023 23:20
@mgjarrett mgjarrett merged commit 8456de6 into main May 5, 2023
@mgjarrett mgjarrett deleted the dbCompareBug branch May 30, 2023 18:45
drewj-usnctech added a commit to drewj-usnctech/armi that referenced this pull request Jun 1, 2023
* main: (23 commits)
  block converters preserve flags (terrapower#1271)
  Fixed float decimals v3 (terrapower#1283)
  Fixed string format error for snapshots (terrapower#1277)
  Pinning the versions of yamlize and ruamel (terrapower#1281)
  Releasing v0.2.7 (terrapower#1276)
  Creating verisons setting section (terrapower#1274)
  Adding to GlobalFluxOptions docstring (terrapower#1273)
  Harmonize material names and class names (terrapower#1270)
  Removing Component.getMassDensity (terrapower#1266)
  Cleaning up language for our versioning rules (terrapower#1175)
  Fixing the Settings Report in the Docs (terrapower#1264)
  Fixing getTemperatureAtDensity to use non-pseduo density (terrapower#1262)
  Fixing settings report docs from terrapower#1207 (terrapower#1263)
  Update test_components.py (terrapower#1261)
  Update gamma Uniform Mesh Converter (terrapower#1213)
  Updating way that settings report defaults are printed (terrapower#1207)
  Fixing UserPlugins.defineFlag (terrapower#1241)
  quick bug fix for PR 1239 (terrapower#1260)
  New Option to Control Lattice Physics Update Frequency (terrapower#1239)
  Fix a bug in database compare. (terrapower#1258)
  ...
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