-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feature/112 reconfigure the detectors to use global code for the binary serializers 2 #129
Feature/112 reconfigure the detectors to use global code for the binary serializers 2 #129
Conversation
…alizer code in more detectors. All unit tests pass.
…ary files (other than Mean and SecondMoment) and file tag.
…binary serialization, rather than testing other code like CreateDetector and DetectorIO.WriteDetectorToFile, etc. Also needed to modify the code in the MT detectors to not check for TallySecondMoment to define SecondMoment array. Otherwise SecondMoment array was not in the serlalizers list in WriteClearAndReReadArrays in DetectorBinarySerializerHelper. Only 18 detectors currently in DetectorIOTests, need to add 54 more tests.
…) is true before allocation of SecondMoment arrays.
…nit tests. List of cleanup files is not complete yet.
…get separated into separate detector test classes) and brought back original DetectorIOTests. Attempted modifying ATotalDetector to return an empy array rather than null.
… alphabetical within a dimension. Made an attempt at ATotalDetector test, but need to ask the senior coders.
…null and updated unit tests in DetectorBinarySerializationTests. Added new tests. Updated the independent variable Counts to be consistent with array Mean specification (it doesn't matter regarding the test, the counts could be anything) but just to not add confusion. So if Mean[2,3] then initialized using {{ 1, 2, 3}, { 4, 5, 6}}.
…econfigure-the-detectors-to-use-global-code-for-the-binary-serializers_2 Added unit tests for BinaryArraySerializerFactory
…ons the arrays would be if the user instantiated them with the specified independent variables.
…k for TallySecondMoment before allocating SecondMoment array. Fixed those. First 5D array test complete and outed this error.
… Need to try toggling TallySecondMoment and test that.
…false. Tried to consolodate common code more, but don't think I can.
….Unit.MonteCarlo.Detectors folder and namespace. All unit tests pass.
…ethod so that it runs at Setup and TestDown.
… is the biggest group. I'm over the hump!
…BinarySerializationTests that included all of the tests. Now I need to make sure the tests cleanup all generated test files properly.
…se-global-code-for-the-binary-serializers_2
@hayakawa16 The quality gate passed! There are 11 new code smells, we can't fix them all (some are cognitive complexity with the factory code) but some of them can be fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In every detector unit test file except one (ReflectedDynamicMTOfXAndYAndSubregionHistDetectorTests) there was an extra line between the comment and the test method. This visually disconnects the comment from the method. I commented on the first few files but to avoid duplicate comments, added it here.
src/Vts.Test/Unit/MonteCarlo/Detectors/AOfRhoAndZDetectorTests.cs
Outdated
Show resolved
Hide resolved
src/Vts.Test/Unit/MonteCarlo/Detectors/AOfXAndYAndZDetectorTests.cs
Outdated
Show resolved
Hide resolved
src/Vts.Test/Unit/MonteCarlo/Detectors/FluenceOfXAndYAndZAndStartingXAndYDetectorTests.cs
Show resolved
Hide resolved
src/Vts.Test/Unit/MonteCarlo/Detectors/ROfFxAndAngleDetectorTests.cs
Outdated
Show resolved
Hide resolved
src/Vts.Test/Unit/MonteCarlo/Detectors/ROfRhoAndMaxDepthRecessedDetectorTests.cs
Outdated
Show resolved
Hide resolved
src/Vts/MonteCarlo/Detectors/pMCROfXAndYAndTimeAndSubregionDetector.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your very detailed review! I made code changes for all suggestions, retested and pushed.
… in test. I could tell this by the lack of code-coverage shown for GetBinarySerializers in this detector. Rest indentation fixes or consolidation of array specifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a few more comments where there is a line feed before the end of an object definition, it is not intentional whitespace and I think it could result in a developer putting future code in the wrong place.
src/Vts.Test/Unit/MonteCarlo/Detectors/ReflectedDynamicMTOfFxAndSubregionHistDetectorTests.cs
Outdated
Show resolved
Hide resolved
...Vts.Test/Unit/MonteCarlo/Detectors/ReflectedDynamicMTOfXAndYAndSubregionHistDetectorTests.cs
Outdated
Show resolved
Hide resolved
...s.Test/Unit/MonteCarlo/Detectors/TransmittedDynamicMTOfXAndYAndSubregionHistDetectorTests.cs
Outdated
Show resolved
Hide resolved
src/Vts/MonteCarlo/Detectors/ReflectedDynamicMTOfFxAndSubregionHistDetector.cs
Outdated
Show resolved
Hide resolved
src/Vts/MonteCarlo/Detectors/ReflectedMTOfXAndYAndSubregionHistDetector.cs
Outdated
Show resolved
Hide resolved
src/Vts/MonteCarlo/Detectors/TransmittedDynamicMTOfFxAndSubregionHistDetector.cs
Outdated
Show resolved
Hide resolved
src/Vts/MonteCarlo/Detectors/TransmittedMTOfRhoAndSubregionHistDetector.cs
Outdated
Show resolved
Hide resolved
src/Vts/MonteCarlo/Detectors/TransmittedMTOfXAndYAndSubregionHistDetector.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I marked all change requests as resolved.
Thanks Lisa! I will await dcuccia's review before proceeding. |
Just wanted to post that I took an infile that I ran with master on 10/12/23 and reran it using this branch. The results are identical! It was a sanity check suggested by lmalenfant and gives us more confidence in our code modifications. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - thanks for all the hard work that went into this. My one comment that we should consider changing before merging is that we update the names of the test methods. 'Validate_deserialized_class_is_correct_when_using_GetBinarySerializersis less accurate than
Validate_deserialized_binary_arrays_are_correct_when_using_GetBinarySerializers`.
My comments regarding things we might consider for the future are:
- That we refactor the test projects into separate Integration and Unit projects (and as part of that, generally better align test names to the classes/class members they're testing).
- That we pare down
Vts.Test.MonteCarlo.DetectorIOTests
significantly, now that all detectors' serializers' behavior/correctness are already covered by these new unit tests (don't need duplicate checks - wastes time and increases software maintenance load). Remaining work would probably be to refactor what remains to unit tests that test the detector-specific JSON serialization/deserialization for the non-array properties. - Similarly, to refactor test classes in the
Vts.Test.MonteCarlo.Detectors
into their Unit counterparts, if feasible - that way we can declare + test the intended behavior of the specific detector without relying on executing a Monte Carlo simulation (i.e. correct tally accumulation and normalization, e.g. focus on correctness of code, not accuracy of MC). - Once 1 & 2 are done, we would be left with tests that test the accuracy of the Monte Carlo for those detectors, which would be probably best labeled as integration tests. (An implementation detail, but a potential way to do that rapidly be to use an in-memory post-processor database, so you don't have to "run" an MC for each detector, just walk through the photon data points).
Perhaps we could create a couple follow-on placeholder tickets (to work on when appropriate) that documents our desire to do the above?
dcuccia, thank you for your review! I can easily modify the unit test names. I like your ideas for future work. It always bothered me how many times a MC simulation is executed during the course of running the unit tests. If this could be optimized somehow, that would be great! In addition to your list, in our discussion on this issue we uncovered the need to analyze PopulateFromEnumerable and possibly update application to be column-major. Creating place holder issues for these features sounds good. Would you like to create them? |
Kudos, SonarCloud Quality Gate passed! |
Creating a draft PR so it goes through all of the checks. Will add reviewers next week.