Skip to content

Add test for empty-trade-history edge case in the Benford engine #676

Description

@Inkman007

Description:
detection/benford_engine.py computes chi-square, per-digit Z-scores, and MAD scores from a wallet's trade amounts. It's not clear from the existing test suite (tests/test_benford.py) what happens when the input trade list is empty (a brand-new wallet with zero trades in the current rolling window). This should return a well-defined neutral result rather than raising an unhandled exception or producing NaNs that silently propagate into the feature matrix.

Acceptance Criteria:

  • A new test in tests/test_benford.py calls the chi-square/Z-score/MAD functions with an empty amounts list.
  • The test asserts either a documented sentinel value (e.g. 0.0 or None) is returned, or a specific, named exception is raised.
  • If the current behavior is undesirable (raises a generic exception, returns NaN), the function is updated to handle the empty case explicitly and the test locks in the new behavior.
  • Test passes under make test.

Relevant files:
detection/benford_engine.py, tests/test_benford.py

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions