ENH: Increase Common operators' code coverage#2536
Conversation
|
This PR will be accompanied by several separate PRs where I'll be adding RTTI to the operators that are missing it, using the Set/Get macros to set/get the ivar values, etc. |
|
Not sure about this compiler failure: since the method exists in https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkGaussianOperator.h#L129 |
5b3911d to
f05f4c7
Compare
Common operators' code coverage
7d63e4c to
951ec94
Compare
951ec94 to
8449d1a
Compare
This might be a minor bug, comment in itkGaussianDerivativeOperator.h mentions Get kernel max width, but there is no function, only Set. |
|
Thank you for the edits. Looks good to me, pending figuring out one way or another what is up with the GitHub actions failures. |
8449d1a to
7e379a5
Compare
|
🤦 : #2536 (comment) Thanks @issakomi !! Have not looked into it in detail, but PRs #2544 and #2545 should address the failures. Will rebase on |
7e379a5 to
d0d6804
Compare
|
d0d6804 has been rebased on |
|
Cross-referencing #2547. Also, this has uncovered the interesting: across a few lines: Many |
Yes, I think this is correct. By the way, almost each time you make "increase X coverage" PR some inconsistency in the library is discovered 😄 |
Will make a PR tonight.
👍. |
PR #2550. Finally left |
d0d6804 to
b255111
Compare
|
Not sure what to think about the failures: Detail: I'd say that since
|
| if (!op1.CheckCoefficients(expected1)) | ||
| { | ||
| std::cerr << "Test failed!" << std::endl; | ||
| std::cerr << "Error in coefficients" << std::endl; |
There was a problem hiding this comment.
Just a small comment here: std::cerr does flush automatically with each << insertion. (For details, check: https://en.cppreference.com/w/cpp/io/cerr) This means that explicit flushing of the stream by << std::endl is unnecessary. So in this case, I would suggest:
std::cerr << "Test failed!\nError in coefficients\n";
The C++ Core Guidelines also suggest to avoid std::endl: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rio-endl
There was a problem hiding this comment.
@N-Dekker thanks for the review. At some point we started preferring std::endl over \n a few years ago. Cannot remember the reasons, but it dates back to the Gerrit days, so I have been unable to find the related comments/discussion.
Also, although at times many of my own changes are not extensive throughout the whole code base, in this case I'm reluctant to change this only for this test: this looks to me like a major style change, involving the SW Guide as well, and virtually all test argument check blocks, and error blocks. Unless a sweeping change is made (and I'm well aware of the effort this involves), I'd sacrifice performance for consistency in this case.
Increase `Common` operator classes' code coverage: - Exercise the basic object methods using the `ITK_EXERCISE_BASIC_OBJECT_METHODS` macro. - Test the Set/Get methods using the `ITK_TEST_SET_GET_VALUE` macro. - Test the boolean ivars using the `ITK_TEST_SET_GET_BOOLEAN` macro. - Make the calls to the Get methods be quantitative where they were just being called without being compared to the expected value. - Remove explicit calls to the Print method and rely on the basic method exercising macro call. - Improve slightly the test style to make them more consistent (e.g. input argument checking, test finishing message, make the types and variables dwell closer to the place where they are instantiated, etc.)
b255111 to
58b39b9
Compare
|
#2556 fixes these: #2536 (comment)
Edit: Confirmed debugging and following the calls locally that the hypothesis in the comment was right: the parent's RTTI method was being called. So all is OK 👌 Also, @Leengit not sure whether there is room for improvement involving these comments: #2536 (comment) I'll push a separate PR switching to getter/setter macros, but I ignore whether the above is just the result of a poor design for the setter/getters regardless of using the macros or poor variable definition, and hence whether they should be addressed now. |
|
itkPyBufferMemoryLeakTest (Failed) is a fluke. Good to merge, I think. |
Increase
Commonoperator classes' code coverage:ITK_EXERCISE_BASIC_OBJECT_METHODSmacro.ITK_TEST_SET_GET_VALUEmacro.ITK_TEST_SET_GET_BOOLEANmacro.being called without being compared to the expected value.
method exercising macro call.
input argument checking, test finishing message, make the types and
variables dwell closer to the place where they are instantiated, etc.)
PR Checklist