def scalar_gen(lib, val):
    """
    Generates different kinds of scalar-like arrays that contain the given
    value.
    """
    # pure scalar values
    yield lib.array(val)
    # ()-shape arrays
    yield lib.full((), val)
    for ndim in range(1, LEGATE_MAX_DIM + 1):
        # singleton arrays
        yield lib.full(ndim * (1,), val)
        # singleton slices of larger arrays
        yield lib.full(ndim * (5,), val)[ndim * (slice(1, 2),)]

    Generates different kinds of scalar-like arrays that contain the given
    value.
    
tests/integration/utils/generators.py