Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a wrapper for sign for NumPy-likes #190

Merged
merged 4 commits into from
Oct 29, 2024
Merged

Conversation

asmeurer
Copy link
Member

Fixes #183

Ensure nan propagation is still handled correctly for CuPy sign().
@asmeurer
Copy link
Member Author

I'm getting this failure with dask locally:

________________________________________________________________________________ test_sign ________________________________________________________________________________

    @given(hh.arrays(dtype=hh.numeric_dtypes, shape=hh.shapes(), elements=finite_kw))
>   def test_sign(x):

array_api_tests/test_operators_and_elementwise_functions.py:1615:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

x = dask.array<reshape, shape=(), dtype=complex64, chunksize=(), chunktype=numpy.ndarray>

    @given(hh.arrays(dtype=hh.numeric_dtypes, shape=hh.shapes(), elements=finite_kw))
    def test_sign(x):
        out = xp.sign(x)
>       ph.assert_dtype("sign", in_dtype=x.dtype, out_dtype=out.dtype)
E       AssertionError: out.dtype=complex128, but should be complex64 [sign(complex64)]
E       Falsifying example: test_sign(
E           x=dask.array<reshape, shape=(), dtype=complex64, chunksize=(), chunktype=numpy.ndarray>,
E       )
E       Explanation:
E           These lines were always and only run by failing examples:
E               /Users/aaronmeurer/Documents/array-api-compat/array_api_compat/common/_aliases.py:537
E               /Users/aaronmeurer/Documents/array-api-compat/array_api_compat/common/_aliases.py:539
E               /Users/aaronmeurer/Documents/array-api-tests/array_api_tests/hypothesis_helpers.py:41
E               /Users/aaronmeurer/Documents/array-api-tests/array_api_tests/hypothesis_helpers.py:51
E               /Users/aaronmeurer/Documents/array-api-tests/array_api_tests/hypothesis_helpers.py:62
E               (and 28 more with settings.verbosity >= verbose)

array_api_tests/test_operators_and_elementwise_functions.py:1617: AssertionError

However, I cannot reproduce it:

>>> import array_api_compat.dask.array as xp
>>> x = xp.asarray(1+2j, dtype=xp.complex64)
>>> xp.sign(x)
dask.array<where, shape=(), dtype=complex64, chunksize=(), chunktype=numpy.ndarray>

@asmeurer asmeurer merged commit 522a608 into data-apis:main Oct 29, 2024
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sign complex case implementations
1 participant