Skip to content

ENH: Improve coverage for itk::FastMarchingImageFilterBase.#114

Merged
thewtex merged 2 commits intoInsightSoftwareConsortium:masterfrom
hjmjohnson:ImproveFastMarchingImageFilterBaseCoverage
Mar 17, 2019
Merged

ENH: Improve coverage for itk::FastMarchingImageFilterBase.#114
thewtex merged 2 commits intoInsightSoftwareConsortium:masterfrom
hjmjohnson:ImproveFastMarchingImageFilterBaseCoverage

Conversation

@hjmjohnson
Copy link
Member

Exercise basic object methods.

Test all Set/Get methods using the TEST_SET_GET_VALUE macro, and all
On/Off methods corresponding to boolean members usign the
TEST_SET_GET_BOOLEAN macro.

Use the TRY_EXPECT_NO_EXCEPTION macro to update the filter and save
tryping the try/catch blocks.

Prefer initialization over assignment in variables.

Use the itkNotUsed macro for test input arguments and hence avoid
casting argc and argv to void to avoid compiler warnings.

Remove printing the input (speed) image.

Remove the calls to the Get* methods corresponding to base class
members (specifically: m_SpeedConstant, m_TargetReachedValue, and
m_NormalizationFactor should be tested for itk::FastMarchingBase in
itkFastMarchingBaseTest.cxx; and m_StoppingValue and GetCollectPoints
should be tested for itk::FastMarchingImageFilter in
itkFastMarchingTest.cxx).

Start comments with capital letters.

Minor style changes (such as white spaces between operators and
arguments, improvement of type names and error messages).

@hjmjohnson hjmjohnson self-assigned this Nov 6, 2018
@hjmjohnson
Copy link
Member Author

@jhlegarreta This was almost 2 years old. I hope I rebased properly.

@hjmjohnson
Copy link
Member Author

Jon Hait... Gorroño
Uploaded patch set 1.Apr 25, 2017

Jon Haitz Legarreta Gorroño
Apr 25, 2017

Patch Set 1:

(3 comments)

Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx
Line 72:
I guess we could get away if we removed this. I fear that an input image of all zeros is not the most appropriate to test this class.

Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest1.cxx
Line 172:
Anybodody knows why "1.42"?

Looks like expected value is about/almost zero:
itk::Math::abs( outputValue ) > itk::NumericTraits< double >::epsilon() * 1.42

Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest2.cxx
Line 190:
Again, same comment as for itkFastMarchingImageFilterRealTest1.cxx

Kitware Build Robot
Apr 25, 2017

Patch Set 1: Verified-1

Build Failed: CDash filtered results: https://open.cdash.org/index.php?&project=Insight&filtercount=3&field1=buildname/string&compare1=63&value1=22311-1&field2=buildstarttime/date&compare2=83&value2=2015-03-01&field3=buildstarttime/date&compare3=84&value3=2029-01-01

Jon Haitz Legarreta Gorroño
Apr 25, 2017

Patch Set 1:

On the other hand, I'm well aware that setting the output image properties in itkFastMarchingImageFilterBase.cxx is not really meaningful since no real computation/check is performed. Setting them in *RealTest1.cxx or *RealTest2.cxx seemed not be very cautious to me given that my understanding of such implications is limited/was confused about the funny way (the "1.42") the output values were being checked.

Otherwise, we could write the output image in itkFastMarchingImageFilterBase.cxx and check the MD5 hash, using and w/o using the output image properties (i.e. two tests). That may require some a deeper understanding concerning the trial points, etc. which I may not have.

An alternative would be setting such properties in *RealTest1.cxx or *RealTest2.cxx, and checking that the test still passes. If it passes, it would be a little bit hard to understand why such a change does not affect the result/may indicate a bug (?); if not, I ignore how hard it'd be adapting it to check the right values.

Matt McCormick
Apr 27, 2017

Patch Set 1:

(3 comments)

Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx
Line 53:
Non-identity (default) spacing is nice to test.

Line 63:
A non-null origin (the default) is nice to check.

Line 72:
If we set some TrialPoints, run the filter, and get the output, it may be not the most interesting, but we could have something to check?

@hjmjohnson hjmjohnson closed this Nov 6, 2018
@hjmjohnson hjmjohnson deleted the ImproveFastMarchingImageFilterBaseCoverage branch November 6, 2018 14:49
@hjmjohnson hjmjohnson restored the ImproveFastMarchingImageFilterBaseCoverage branch November 6, 2018 19:23
@hjmjohnson
Copy link
Member Author

Accidently deleted/closed branch when the script for moving from Gerrit went haywire.

@hjmjohnson hjmjohnson reopened this Nov 6, 2018
@hjmjohnson hjmjohnson force-pushed the ImproveFastMarchingImageFilterBaseCoverage branch from 5763a17 to e6c7d94 Compare February 9, 2019 19:55
@hjmjohnson hjmjohnson force-pushed the ImproveFastMarchingImageFilterBaseCoverage branch from e6c7d94 to 2b5b291 Compare March 7, 2019 17:45
@hjmjohnson hjmjohnson force-pushed the ImproveFastMarchingImageFilterBaseCoverage branch from 2b5b291 to d8fd156 Compare March 9, 2019 19:23
@hjmjohnson hjmjohnson added status:Confirmed Confirmed/reproduced issue on a different machine with same or similar settings to those reported type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Filtering Issues affecting the Filtering module type:Style Style changes: no logic impact (indentation, comments, naming) type:Coverage Code coverage impacts labels Mar 9, 2019
@hjmjohnson hjmjohnson requested a review from thewtex March 10, 2019 00:17
@hjmjohnson
Copy link
Member Author

@thewtex @jhlegarreta This issue is almost 2 years old. I spent some time today making this PR pass regression tests. While I am certain that more work could be done, I would like to move this incremental better solution forward to remove it from the 2-year-old backlog. I don't think there is much interest in pursuing this more aggressively at the moment.

@jhlegarreta
Copy link
Member

@hjmjohnson thanks for caring about this. I'll have a look at the comments/what was left undone it during the next few days, do the appropriate changes if any, and give some feedback.

Exercise basic object methods.

Test all Set/Get methods using the TEST_SET_GET_VALUE macro, and all
On/Off methods corresponding to boolean members usign the
TEST_SET_GET_BOOLEAN macro.

Use the TRY_EXPECT_NO_EXCEPTION macro to update the filter and save
tryping the try/catch blocks.

Prefer initialization over assignment in variables.

Use the itkNotUsed macro for test input arguments and hence avoid
casting argc and argv to void to avoid compiler warnings.

Remove printing the input (speed) image.

Remove the calls to the Get* methods corresponding to base class
members (specifically: m_SpeedConstant, m_TargetReachedValue, and
m_NormalizationFactor should be tested for itk::FastMarchingBase in
itkFastMarchingBaseTest.cxx; and m_StoppingValue and GetCollectPoints
should be tested for itk::FastMarchingImageFilter in
itkFastMarchingTest.cxx).

Start comments with capital letters.

Minor style changes (such as white spaces between operators and
arguments, improvement of type names and error messages).

-- COMP: Fix missing typename in templated functions
  ITK/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx:40:3:
  ITK/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx:45:3:
  ITK/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx:50:3:
  ITK/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx:55:3:
  ITK/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx:60:3:
   error: missing 'typename' prior to dependent type name 'FastMarchingImageFilterType::OutputSizeType'
    FastMarchingImageFilterType::OutputSizeType outputSize;
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- BUG: Fix incorrect superclass naming
Missing itkTypeMacro, and incorrect superclass designations
found with EXERCISE_BASIC_OBJECT_METHODS.

-- STYLE: Create unique local function name
Create a test function name that is distinctly different
from the name of the class being tested.

Document explicitly the intent of the testing function.

This testing function is not instrumented to actually
test the filter (too few inputs provided), but rather
tests the basic getters/setters for the base class.

The actuall testing of the algorithms is performed
in other tests.

Co-authored by: Jon Haitz Legarreta Gorroño <jon.haitz.legarreta@gmail.com>
@jhlegarreta jhlegarreta force-pushed the ImproveFastMarchingImageFilterBaseCoverage branch from d8fd156 to e025dd5 Compare March 10, 2019 01:38
@jhlegarreta
Copy link
Member

Rebased on master for now. Revision to come later next week.

@hjmjohnson
Copy link
Member Author

@jhlegarreta Can this be pushed as is, and then your additions added once you find the time? I'd hate for this 2-year-old PR to become stale again.

@jhlegarreta
Copy link
Member

@hjmjohnson @thewtex Thanks for your patience. I went through the comments. It does not look complicated what is left to improve the robustness of the tests, but it requires some time. As Hans told me a few weeks ago, "Don't let perfection be the enemy of the good", so for the time being, I think it is reasonable to merge it as it is, given that checks are passing, and it is already an improvement and a step towards the right direction.

I've opened an issue (#599) to keep track of the pending tasks. As said, affordable to anyone in the community, useful for all.

Sorry for taking so long to review it.

@hjmjohnson
Copy link
Member Author

@thewtex Now we just need someone to approve, and it can be merged! Let's try to get this in before 2 years have passed 👍 .

Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and persistence!

@thewtex thewtex merged commit bb03398 into InsightSoftwareConsortium:master Mar 17, 2019
@hjmjohnson hjmjohnson deleted the ImproveFastMarchingImageFilterBaseCoverage branch April 17, 2019 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Filtering Issues affecting the Filtering module status:Confirmed Confirmed/reproduced issue on a different machine with same or similar settings to those reported type:Coverage Code coverage impacts type:Style Style changes: no logic impact (indentation, comments, naming) type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants