array-api-tests icon indicating copy to clipboard operation
array-api-tests copied to clipboard

2023.12 support

Open asmeurer opened this issue 1 year ago • 6 comments

We need a tracking issue for 2023.12 support in the test suite.

Here is the list of changes https://data-apis.org/array-api/latest/changelog.html#v2023-12

New Functions

  • [x] __array_namespace_info__ (i.e., the inspection API)
  • [x] clip
  • [x] copysign
  • [x] cumulative_sum
  • [x] hypot
  • [x] maximum
  • [x] minimum
  • [x] moveaxis
  • [x] repeat
  • [x] searchsorted
  • [x] signbit
  • [x] tile
  • [x] unstack

API Changes

  • [ ] device keyword added to astype
  • [ ] from_dlpack requires exceptions in some cases
  • [ ] copy and device keywords to from_dlpack
  • [ ] sum, prod, trace output dtype change (https://github.com/data-apis/array-api-tests/issues/234)

Other Changes (not sure if these need tests)

  • [ ] Support for lazy functions in various APIs. Will probably need a real world lazy implementation to support this.
  • [ ] Order of signed zeros unspecified for max and min. Just need to make sure we aren't testing this.
  • [ ] Out of bounds unspecified for take.
  • [ ] tensordot should support negative axes (not sure if this is already tested)

I think that's everything but you might want to read through the changes too to check if I missed something.

asmeurer avatar Mar 28 '24 21:03 asmeurer

Note: clip is tricky, especially given the divergences between the standard and the NumPy implementation. We should be especially sure to that the test can catch possible issues with incorrect promotion behavior (clip should not promote but return the same dtype as x) so we can catch potential issues with integer overflow like described at https://github.com/numpy/numpy/issues/24976

asmeurer avatar Apr 19 '24 22:04 asmeurer

Notes for copysign special cases: One can construct a nan with a negative sign bit using -float('nan'). To test the sign bit of a nan you'd either have to use signbit or use math.copysign.

asmeurer avatar Apr 19 '24 22:04 asmeurer

I edited the above list to add a couple of things I missed.

asmeurer avatar Apr 29 '24 21:04 asmeurer

Should this have been closed?

asmeurer avatar May 06 '24 19:05 asmeurer

Should this have been closed?

Good catch!

honno avatar May 07 '24 09:05 honno

I noticed the searchsorted test is broken because it uses __array_namespace_info__, which isn't listed correctly in the array-api stubs (it's also broken because it uses float instead of int for the sorter array, but that's an easy fix). I tried fixing this in the submodule:

diff --git a/src/array_api_stubs/_2023_12/__init__.py b/src/array_api_stubs/_2023_12/__init__.py
index 8415f276..537ea8f8 100644
--- a/src/array_api_stubs/_2023_12/__init__.py
+++ b/src/array_api_stubs/_2023_12/__init__.py
@@ -16,7 +16,7 @@ from .statistical_functions import *
 from .utility_functions import *
 from . import linalg
 from . import fft
-from . import info
+from .info import __array_namespace_info__


 __array_api_version__: str = "YYYY.MM"

but the fix doesn't seem to work.

asmeurer avatar May 07 '24 16:05 asmeurer