data-apis / array-api-compat

Compatibility layer for common array libraries to support the Array API
https://data-apis.org/array-api-compat/
MIT License
69 stars 22 forks source link

Suppress NumPy warnings for special case behaviour #1

Closed honno closed 1 year ago

honno commented 1 year ago

The initial numpy.array_api PR https://github.com/numpy/numpy/pull/18585 had folks happy with keeping NumPy-proper's warnings when spec-compliant operations were being done (usually/always special case behaviour). Giving the flexibility of a separate package, could we instead suppress these warnings? Really my one use case here is array-api-tests, where right now our "daily driver" array module is numpy.array_api which deluges us with warnings that obfuscate other things... we could suppress them on our end tbf, just ugh.

asmeurer commented 1 year ago

Most of the functions in this module are just direct copies of the NumPy versions, i.e., we just do from numpy import * and export np.sin, np.exp, etc. I'm only wrapping the functions that have changed behavior. Doing this would require wrapping every single function.

Additionally, we don't wrap or subclass the array object, so even if we fix it for functions, it wouldn't be fixed for operators.

Instead, I would just disable the warnings when testing this module. I don't know if it can be done with an environment variable.