ml_switcheroo.testing.fuzzer.strategies

Hypothesis Strategies for ODL Types.

This module maps Operation Definition Language (ODL) type strings (e.g., Array['N'], List[int]) into executable Hypothesis search strategies. It handles:

  1. Primitives: Constraints-aware generation for ints, floats, bools.

  2. Tensors: Numpy array generation with specific dtypes, ranks, and symbolic shapes.

  3. Containers: Recursive generation of Lists, Tuples, and Dictionaries.

  4. Symbolic Consistency: Ensuring named dimensions (e.g., ‘N’) resolve consistently across different arguments using a shared context.

Functions

strategies_from_spec(...)

Constructs a Hypothesis strategy from a type string and constraints.

Module Contents

ml_switcheroo.testing.fuzzer.strategies.strategies_from_spec(type_str: str, constraints: Dict[str, Any], shared_dims: Dict[str, Any] | None = None) hypothesis.strategies.SearchStrategy

Constructs a Hypothesis strategy from a type string and constraints.

Recursively parses complex types (e.g., List[int]) and delegates array creation to _array_strategy.

Parameters:
  • type_str – The ODL type hint (e.g. “int”, “Array[‘N’]”).

  • constraints – Dictionary of constraints (min, max, options).

  • shared_dims – Mutable dictionary mapping symbol names to shared integer strategies.

Returns:

A valid Hypothesis SearchStrategy.