Add direct CvDTree / CvDTreeTrainData unit tests#26
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 8 direct unit tests for the legacy decision-tree implementation (
CvDTree,CvDTreeTrainData) — the two largest uncovered files inTrainCascadeLib. Tests use tiny in-memorycv::Matdatasets and exercise both the high-leveltrain(cv::Mat, ...)entry point and the shared-data overloadtrain(CvDTreeTrainData*, ...)thatCvBoostTree/CvCascadeBoostTreeuse internally.Motivation
Coverage analysis identified
o_cvdtree.cpp(10%) and o_cvdtreetraindata.cpp (cold) as the largest remaining gaps. The cascade trainer drives these classes only indirectly through the boosting layer, so prior end-to-end tests left their core data-prep / split / predict paths largely untouched.Changes
New file: test_dtree.cpp
CvDTree::train(cv::Mat ...)clear()drops the trained tree; re-training on the same instance produces a fresh treeCvDTree::train(CvDTreeTrainData*)CvDTreeTrainDataCvDTreeTrainDatais_classifier/sample_count/var_count/get_num_classes()/get_var_type()afterset_data;clear()is safe on a default-constructed instanceHelpers (file-local):
makeOneDimSeparableDataset()— 10 samples, 2 classes, clean margin atx = 0.5.makeTinyParams()—max_depth = 3,min_sample_count = 1, no surrogates / CV-folds (required for tiny datasets).sample1D(value)— 1×1CV_32Frow forpredict().All tests follow the project's Arrange / Act / Assert convention with comments per step.
Updated: CMakeLists.txt — registers
test/test_dtree.cppin thetest_traincascadetarget.Verification
Test-suite runtime unchanged (~17 s).
Coverage impact
Single largest coverage uplift in the test-suite history — activates ~610 previously-uncovered lines across
o_cvdtree.cppand o_cvdtreetraindata.cpp.Risk
Test-only change. No production source modified.
Checklist