Skip to content

signature tests for floor_divide and remainder divide by 0 #170

Open
@asmeurer

Description

@asmeurer

This is a problem for torch, which raises ZeroDivisionError in this case (note that the spec leaves integer division by 0 unspecified).

For example:

x1 = tensor(0, dtype=torch.uint8), x2 = tensor(0, dtype=torch.uint8), kwargs = {}

    @wraps(f)
    def _f(x1, x2, /, **kwargs):
        x1, x2 = _fix_promotion(x1, x2)
>       return f(x1, x2, **kwargs)
E       RuntimeError: ZeroDivisionError
E       Falsifying example: _test_uninspectable_func(
E           data=data(...),
E           func_name='remainder',
E           func=remainder,
E           stub_sig=<Signature (x1: ~array, x2: ~array, /) -> ~array>,
E           array=None,
E       )
E       Draw 1 (x1): tensor(0, dtype=torch.uint8)
E       Draw 2 (x2): tensor(0, dtype=torch.uint8)
E       trying remainder(tensor(0, dtype=torch.uint8), tensor(0, dtype=torch.uint8))

../array-api-compat/array_api_compat/torch/_aliases.py:75: RuntimeError

And similarly for floor_divide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions