Skip to content

Fix compare intersection bug and add exclude_attrs support#151

Merged
villelaitila merged 1 commit intosoftagram:mainfrom
villelaitila:fix/compare-intersection-and-exclude-attrs
Apr 1, 2026
Merged

Fix compare intersection bug and add exclude_attrs support#151
villelaitila merged 1 commit intosoftagram:mainfrom
villelaitila:fix/compare-intersection-and-exclude-attrs

Conversation

@villelaitila
Copy link
Copy Markdown
Contributor

Summary

  • Bug fix: compare_attrs() in attributecomparison.py computed intersection incorrectly — set.intersection() returns a new set but the result was never assigned, so intersection was always equal to keys1. This caused "only in A" attributes to never be reported and incorrect handling of shared attributes. Fixed with & operator.
  • Bug fix: Keys-only-in-A/B filtering now properly excludes ignoredAttrs, preventing ignored attributes from appearing in change output.
  • New feature: exclude_attrs parameter on compare() and compareModels() allows callers to suppress noisy attributes (e.g. time-windowed metrics) during comparison.
  • New preset: SLIDING_WINDOW_ATTRS constant in compareutils.py for common time-windowed metric attributes.

Test plan

  • test_compare_attrs_intersection_correctness — regression test for the intersection bug
  • test_compare_attrs_ignored_attrs_excluded_from_only_in — ignored attrs filtering
  • test_exclude_attrs_in_compareModels — exclude_attrs suppresses specified attributes
  • test_exclude_attrs_restores_ignoredAttrs — global state is restored after comparison
  • test_sliding_window_attrs_preset — SLIDING_WINDOW_ATTRS content validation
  • Full test suite passes (61/63, 2 pre-existing failures in release automation)

- Fix attributecomparison.py: set.intersection() was called without
  assignment, so intersection was always equal to keys1. Use & operator.
- Fix keys-only-in-A/B filtering to properly exclude ignoredAttrs.
- Add exclude_attrs parameter to compare() and compareModels() for
  suppressing noisy time-windowed metrics during comparison.
- Add SLIDING_WINDOW_ATTRS preset in compareutils.py.
- Improve docstrings for SElement, SElementAssociation, and ModelCompare.
- Add comprehensive tests for the new functionality.
- Document model comparison workflow in CLAUDE.md.
@softagram-bot
Copy link
Copy Markdown

Looking good 🎉

See the full Softagram report

@villelaitila villelaitila merged commit 640d907 into softagram:main Apr 1, 2026
1 check passed
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.

2 participants