Skip to content

MAINT: copy semantics shim #11

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

Closed
tylerjereddy opened this issue Mar 1, 2024 · 2 comments · Fixed by #12
Closed

MAINT: copy semantics shim #11

tylerjereddy opened this issue Mar 1, 2024 · 2 comments · Fixed by #12

Comments

@tylerjereddy
Copy link

Probably not surprising; in scipy/scipy#20172 I noticed what looks like a requirement for at least a small copy argument pass-through shim with NumPy main here because of (currently) a single test in SciPy. In that PR I was able to patch similar errors with fairly crude copy=None pass-through type shims, though in this library it may actually need to do something useful (the intended purpose) if the copy arg really needs to be respected I suppose.

============================================================================================ FAILURES =============================================================================================
______________________________________________________________________________ test_dispatch_to_unrecognize_library _______________________________________________________________________________
[gw22] linux -- Python 3.11.2 /home/treddy/python_venvs/py_311_scipy_dev/bin/python
scipy/special/tests/test_support_alternative_backends.py:25: in test_dispatch_to_unrecognize_library
    res = f(xp.asarray(x))
        f          = <function get_array_special_func.<locals>.f at 0x7f404756a2a0>
        x          = [1, 2, 3]
        xp         = <module 'array_api_strict' from '/home/treddy/python_venvs/py_311_scipy_dev/lib/python3.11/site-packages/array_api_strict/__init__.py'>
scipy/special/_support_alternative_backends.py:33: in f
    array_args = [np.asarray(arg) for arg in array_args]
        args       = (Array([1, 2, 3], dtype=array_api_strict.int64),)
        array_args = (Array([1, 2, 3], dtype=array_api_strict.int64),)
        f_scipy    = <ufunc 'ndtr'>
        kwargs     = {}
        n_array_args = 1
        other_args = ()
        xp         = <module 'array_api_strict' from '/home/treddy/python_venvs/py_311_scipy_dev/lib/python3.11/site-packages/array_api_strict/__init__.py'>
scipy/special/_support_alternative_backends.py:33: in <listcomp>
    array_args = [np.asarray(arg) for arg in array_args]
E   TypeError: Array.__array__() got an unexpected keyword argument 'copy'
        .0         = <tuple_iterator object at 0x7f4062090cd0>
        arg        = Array([1, 2, 3], dtype=array_api_strict.int64)
===================================================================================== short test summary info =====================================================================================
FAILED scipy/special/tests/test_support_alternative_backends.py::test_dispatch_to_unrecognize_library - TypeError: Array.__array__() got an unexpected keyword argument 'copy'

@asmeurer
Copy link
Member

asmeurer commented Mar 2, 2024

I don't think we can really emulate copy=False in NumPy 1.26, hence the NotImplementedError. If NumPy main now actually supports copy=False we should update that code to pass it through for NumPy >= 2.0.

rgommers added a commit to rgommers/array-api-strict that referenced this issue Mar 2, 2024
@rgommers
Copy link
Member

rgommers commented Mar 2, 2024

Should be fixed by gh-12. Since the NumPy change got merged in a way that wasn't backwards-compatible, this is breaking SciPy tests now (and probably tests of other users of this package). Even if that is addressed in NumPy, a missing copy keyword will still emit a warning, which is still going to break the SciPy test suite. So it'd be nice to do a release with this issue fixed very soon.

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 a pull request may close this issue.

3 participants