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

Feature/112 reconfigure the detectors to use global code for the binary serializers 2 #129

Conversation

hayakawa16
Copy link
Member

Creating a draft PR so it goes through all of the checks. Will add reviewers next week.

Lisa Malenfant and others added 30 commits October 31, 2023 14:44
…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.
…BinarySerializationTests that included all of the tests. Now I need to make sure the tests cleanup all generated test files properly.
@lmalenfant
Copy link
Member

@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.

@hayakawa16 hayakawa16 marked this pull request as ready for review November 27, 2023 21:08
Copy link
Member

@lmalenfant lmalenfant left a 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.

Copy link
Member Author

@hayakawa16 hayakawa16 left a 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.
Copy link
Member

@lmalenfant lmalenfant left a 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.

Copy link
Member

@lmalenfant lmalenfant left a 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.

@hayakawa16
Copy link
Member Author

Thanks Lisa! I will await dcuccia's review before proceeding.

@hayakawa16
Copy link
Member Author

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.

Copy link
Contributor

@dcuccia dcuccia left a 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 thanValidate_deserialized_binary_arrays_are_correct_when_using_GetBinarySerializers`.

My comments regarding things we might consider for the future are:

  1. 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).
  2. 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.
  3. 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).
  4. 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?

@hayakawa16
Copy link
Member Author

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?

Copy link

sonarcloud bot commented Dec 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

100.0% 100.0% Coverage
8.9% 8.9% Duplication

@hayakawa16 hayakawa16 merged commit 631fdda into master Dec 1, 2023
2 checks passed
@hayakawa16 hayakawa16 deleted the feature/112-reconfigure-the-detectors-to-use-global-code-for-the-binary-serializers_2 branch December 1, 2023 23:06
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.

Reconfigure the detectors to use global code for the Binary Serializers
3 participants