Skip to content
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

Add non-strict mode to AnomalibMetric #2508

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

djdameln
Copy link
Contributor

📝 Description

This PR adds a non-strict mode to AnomalibMetric class, which reduces boilerplate code in applications where the batches passed to update may or may not contain the required fields.

  • Add strict keyword argument to AnomalibMetric class that defines the behaviour when the batch passed to update has missing fields.
  • When strict==True (default), the behaviour will be the same as it was previously. The metric will raise an error if the field is not present in the passed instance, or if the value of the field is None.
  • When strict==False, the metric will skip the update call of the internal metric, but not raise an error. When compute is called, the metric will return None if all calls to update were unsuccessful.
  • The changes in OneClassPostProcessor are an example how the non-strict mode can reduce boilerplate code.

Other changes:

  • Add unit tests for AnomalibMetric.
  • Some styling changes to OneClassPostProcessor
  • Remove persistent states in MinMax metric. This is no longer needed in v2.

✨ Changes

Select what type of change your PR is:

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🔨 Refactor (non-breaking change which refactors the code base)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔒 Security update

✅ Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • 📋 I have summarized my changes in the CHANGELOG and followed the guidelines for my type of change (skip for minor changes, documentation updates, and test enhancements).
  • 📚 I have made the necessary updates to the documentation (if applicable).
  • 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).

For more information about code review checklists, see the Code Review Checklist.

@djdameln djdameln marked this pull request as draft January 15, 2025 07:42
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.

1 participant