ml_switcheroo.testing.fuzzer.generators ======================================= .. py:module:: ml_switcheroo.testing.fuzzer.generators .. autoapi-nested-parse:: Primitive Generation Logic for the Fuzzer. This module contains functions to generate random scalars, NumPy arrays, and dummy callables respecting specified constraints (min, max, dtype). Feature Update: Added broadcasting logic generator. Functions --------- .. autoapisummary:: ml_switcheroo.testing.fuzzer.generators.generate_scalar_int ml_switcheroo.testing.fuzzer.generators.generate_scalar_float ml_switcheroo.testing.fuzzer.generators.generate_array ml_switcheroo.testing.fuzzer.generators.get_random_shape ml_switcheroo.testing.fuzzer.generators.make_broadcastable_shape ml_switcheroo.testing.fuzzer.generators.generate_fake_callable Module Contents --------------- .. py:function:: generate_scalar_int(constraints: Dict[str, Any]) -> int Generates a random integer within constrained bounds. :param constraints: Dictionary containing optional 'min' and 'max'. :type constraints: Dict[str, Any] :returns: A random integer. :rtype: int .. py:function:: generate_scalar_float(constraints: Dict[str, Any]) -> float Generates a random float within constrained bounds. :param constraints: Dictionary containing optional 'min' and 'max'. :type constraints: Dict[str, Any] :returns: A random float. :rtype: float .. py:function:: generate_array(type_lbl: str, shape: Tuple[int, Ellipsis], constraints: Dict[str, Any]) -> numpy.ndarray Generates a random NumPy array bounded by constraints. :param type_lbl: General type category ('float', 'int', 'bool'). :type type_lbl: str :param shape: The shape of the array. :type shape: Tuple[int, ...] :param constraints: Constraints like 'min', 'max', 'dtype'. :type constraints: Dict[str, Any] :returns: The generated array. :rtype: np.ndarray .. py:function:: get_random_shape(seed_shape: Optional[Tuple[int, Ellipsis]] = None) -> Tuple[int, Ellipsis] Selects a random rank (1-4) and random dimensions (2-5). :param seed_shape: Optional fixed shape to return. :type seed_shape: Optional[Tuple] :returns: The random or seeded shape. :rtype: Tuple[int, ...] .. py:function:: make_broadcastable_shape(base_shape: Tuple[int, Ellipsis], salt: int = 0) -> Tuple[int, Ellipsis] Derives a shape that is broadcast-compatible with the base_shape. For each dimension, there is a probability it becomes 1 (broadcasting dimension). The 'salt' ensures arguments don't all degenerate to 1s in the same way, creating varied valid broadcasting patterns (e.g. (A, 1, C) vs (1, B, C)). :param base_shape: The target accumulated shape. :param salt: Integer to vary the random choice (arg index). :returns: A new shape tuple. .. py:function:: generate_fake_callable(constraints: Dict[str, Any] = None) -> Any Generates a dummy function (identity) for functional ops.