Repository navigation
fix: report refused list elements with field comparison rules #364
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
Changes from 4 commits
348dc59
7fefbbb
b147fb8
7664719
9fa562b
44f68ce
20d13e7
ddbd94b
5049709
cc2bd10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,17 @@ def confusion_matrix_builder(self): | |
| self._confusion_matrix_builder = ConfusionMatrixBuilder(self.model) | ||
| return self._confusion_matrix_builder | ||
|
|
||
| def compare_recursive(self, other: "StructuredModel") -> Dict[str, Any]: | ||
| @staticmethod | ||
| def _drop_list_matching(result: Dict[str, Any]) -> None: | ||
| """Remove scoring-only pairing details from a public result tree.""" | ||
| for field_result in result.get("fields", {}).values(): | ||
| if isinstance(field_result, dict): | ||
| field_result.pop("_list_matching", None) | ||
| ComparisonEngine._drop_list_matching(field_result) | ||
|
|
||
| def compare_recursive( | ||
| self, other: "StructuredModel", *, _include_list_matching: bool = False | ||
| ) -> Dict[str, Any]: | ||
| """The core recursive comparison function. | ||
|
|
||
| This method performs a single-traversal comparison of two StructuredModel | ||
|
|
@@ -177,6 +187,8 @@ def compare_recursive(self, other: "StructuredModel") -> Dict[str, Any]: | |
| if total_weight > 0: | ||
| result["overall"]["similarity_score"] = total_score / total_weight | ||
|
|
||
| if not _include_list_matching: | ||
| self._drop_list_matching(result) | ||
| return result | ||
|
|
||
| def compare_with( | ||
|
|
@@ -192,6 +204,7 @@ def compare_with( | |
| confidence_metrics: Optional[List["ConfidenceMetric"]] = None, | ||
| add_bbox_metrics: bool = False, | ||
| bbox_iou_thresholds: Optional[Union[float, Iterable[float]]] = None, | ||
| _retain_recursive_result: bool = False, | ||
| ) -> Dict[str, Any]: | ||
| """Compare with another instance using single traversal. | ||
|
|
||
|
|
@@ -249,7 +262,7 @@ def compare_with( | |
| >>> print(result["confusion_matrix"]["overall"]["tp"]) | ||
| """ | ||
| # SINGLE TRAVERSAL: Get everything in one pass | ||
| recursive_result = self.compare_recursive(other) | ||
| recursive_result = self.compare_recursive(other, _include_list_matching=True) | ||
|
|
||
| # Extract scoring information from recursive result | ||
| field_scores = {} | ||
|
|
@@ -441,6 +454,17 @@ def compare_with( | |
| if pred_bboxes: | ||
| result["prediction_bboxes"] = pred_bboxes | ||
|
|
||
| # The collectors have consumed the scoring-only pairings. Keep the | ||
| # public recursive/confusion-matrix result shape unchanged. | ||
| if _retain_recursive_result: | ||
| # Internal structured-list scoring passes this same traversal to | ||
| # the report collectors instead of comparing a child again. | ||
| result["_recursive_result"] = recursive_result | ||
| else: | ||
| self._drop_list_matching(recursive_result) | ||
| if "confusion_matrix" in result: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking. Each public |
||
| self._drop_list_matching(result["confusion_matrix"]) | ||
|
|
||
| # If evaluator_format is requested, transform the result | ||
| if evaluator_format: | ||
| return self.model._format_for_evaluator(result, other, recall_with_fd) | ||
|
|
||
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.
Blocker (root cause of the comment above). Pairing data travels inside the public result tree and is stripped at several separate exits (
compare_recursive, thecompare_withrecursive result, thecompare_withconfusion matrix), so any exit without a strip leaks it._dispatch_field_comparisonis one already; a new public helper or collector would be the next.Suggested fix: keep the pairings in a side map owned by the engine and keyed by field path, which the collectors read. Public dicts then never hold private keys and need no strip-on-exit. That also removes the extra tree walks noted at line 465.