Skip to content

test_nan_propagation works incorrectly for cumulative_sum #263

Closed
@ndgrigorian

Description

@ndgrigorian

Per spec,

if include_initial is False, the returned array must have the same shape as x.

however, test_nan_propagation expects the result to have an empty shape (i.e., be a scalar).

func_name = 'cumulative_sum', x = usm_ndarray([nan], dtype=float32), data = data(...)

    @reproduce_failure('6.102.4', b'AXicY2BkQAcAACUAAg==')
    @pytest.mark.parametrize(
        "func_name", [f.__name__ for f in category_to_funcs["statistical"]]
    )
    @given(
        x=hh.arrays(dtype=xps.floating_dtypes(), shape=hh.shapes(min_side=1)),
        data=st.data(),
    )
    def test_nan_propagation(func_name, x, data):
        func = getattr(xp, func_name)
        set_idx = data.draw(
            xps.indices(x.shape, max_dims=0, allow_ellipsis=False), label="set idx"
        )
        x[set_idx] = float("nan")
        note(f"{x=}")

        out = func(x)

>       ph.assert_shape(func_name, out_shape=out.shape, expected=())  # sanity check
E       AssertionError: out.shape=(1,), but should be () [cumulative_sum()]

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