summaryrefslogtreecommitdiff
path: root/numpy/array_api/tests
Commit message (Collapse)AuthorAgeFilesLines
* rename test functionAlex Rogozhnikov2023-02-261-1/+1
|
* add support for xp.takeAlex Rogozhnikov2023-02-261-0/+24
|
* TST: Move new `asarray` test to a more appropriate place. (#22251)M. Eric Irrgang2022-09-131-64/+0
| | | | | | | | | | | | | As noted at #21995 (comment), the new test from #21995 was placed in a directory intended for the Array API, and unrelated to the change. * Consolidate test_dtype_identity into an existing test file. Remove `test_asarray.py`. Create a new `TestAsArray` suite in `test_array_coercion.py` * Linting. Wrap some comments that got too long after function became a method (with additional indentation).
* Merge pull request #21995 from eirrgang/mei-1468Matti Picus2022-09-071-0/+64
|\ | | | | BUG: Distinguish exact vs. equivalent dtype for C type aliases.
| * Add release note and further clarify tests.M. Eric Irrgang2022-07-171-12/+31
| |
| * Lint.M. Eric Irrgang2022-07-171-3/+4
| | | | | | | | Shorten some lines.
| * Expand test_asarray.py.M. Eric Irrgang2022-07-171-13/+33
| | | | | | | | | | | | | | * Improve comments/docs. * Improve descriptiveness of variable names. * Add additional test expressions that would not pass without this patch.
| * Update comment and obey formatting requirements.M. Eric Irrgang2022-07-161-2/+2
| |
| * Add unit testing.M. Eric Irrgang2022-07-161-0/+24
| |
* | MAINT: fix typo in test_array_object test description (#22071)Ikko Ashimine2022-08-021-1/+1
|/
* API: Allow newaxis indexing for `array_api` arrays (#21377)Matthew Barber2022-05-061-6/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * TST: Add test checking if newaxis indexing works for `array_api` Also removes previous check against newaxis indexing, which is now outdated * TST, BUG: Allow `None` in `array_api` indexing Introduces test for validating flat indexing when `None` is present * MAINT,DOC,TST: Rework of `_validate_index()` in `numpy.array_api` _validate_index() is now called as self._validate_index(shape), and does not return a key. This rework removes the recursive pattern used. Tests are introduced to cover some edge cases. Additionally, its internal docstring reflects new behaviour, and extends the flat indexing note. * MAINT: `advance` -> `advanced` (integer indexing) Co-authored-by: Aaron Meurer <asmeurer@gmail.com> * BUG: array_api arrays use internal arrays from array_api array keys When an array_api array is passed as the key for get/setitem, we access the key's internal np.ndarray array to be used as the key for the internal get/setitem operation. This behaviour was initially removed when `_validate_index()` was reworked. * MAINT: Better flat indexing error message for `array_api` arrays Also better semantics for its prior ellipsis count condition Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> * MAINT: `array_api` arrays don't special case multi-ellipsis errors This gets handled by NumPy-proper. Co-authored-by: Aaron Meurer <asmeurer@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* Note `np.array_api.can_cast()` does not use `np.can_cast()`Matthew Barber2022-02-091-2/+0
|
* BUG: Fix `np.array_api.can_cast()` by not relying on `np.can_cast()`Matthew Barber2022-02-092-0/+48
|
* Regression test for inverse indices in `array_api` set functionsMatthew2022-01-131-0/+19
|
* Merge pull request #20762 from honno/xp-pow-fixesCharles Harris2022-01-122-2/+2
|\ | | | | BUG: Allow integer inputs for pow-related functions in `array_api`
| * BUG: Allow integer inputs for pow-related functions in `array_api`Matthew2022-01-072-2/+2
| | | | | | | | Updates `xp.power()`, `x.__pow__()`, `x.__ipow()__` and `x.__rpow()__`
* | BUG: `array_api.argsort(descending=True)` respects relative sort order (#20788)Matthew Barber2022-01-121-0/+23
|/ | | | | * BUG: `array_api.argsort(descending=True)` respects relative order * Regression test for stable descending `array_api.argsort()`
* ENH: Add __array__ to the array_api Array objectAaron Meurer2021-12-061-0/+7
| | | | | | | | | | | This is *NOT* part of the array API spec (so it should not be relied on for portable code). However, without this, np.asarray(np.array_api.Array) produces an object array instead of doing the conversion to a NumPy array as expected. This would work once np.asarray() implements dlpack support, but until then, it seems reasonable to make the conversion work. Note that the reverse, calling np.array_api.asarray(np.array), already works because np.array_api.asarray() is just a wrapper for np.asarray().
* Add tests for T and mT in array_apiAaron Meurer2021-12-011-0/+14
|
* Merge branch 'main' into never_copyRalf Gommers2021-11-122-6/+32
|\
| * MAINT: A few updates to the array_api (#20066)Aaron Meurer2021-11-122-8/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Allow casting in the array API asarray() * Restrict multidimensional indexing in the array API namespace The spec has recently been updated to only require multiaxis (i.e., tuple) indices in the case where every axis is indexed, meaning there are either as many indices as axes or the index has an ellipsis. * Fix type promotion for numpy.array_api.where where does value-based promotion for 0-dimensional arrays, so we use the same trick as in the Array operators to avoid this. * Print empty array_api arrays using empty() Printing behavior isn't required by the spec. This is just to make things easier to understand, especially with the array API test suite. * Fix an incorrect slice bounds guard in the array API * Disallow multiple different dtypes in the input to np.array_api.meshgrid * Remove DLPack support from numpy.array_api.asarray() from_dlpack() should be used to create arrays using DLPack. * Remove __len__ from the array API array object * Add astype() to numpy.array_api * Update the unique_* functions in numpy.array_api unique() in the array API was replaced with three separate functions, unique_all(), unique_inverse(), and unique_values(), in order to avoid polymorphic return types. Additionally, it should be noted that these functions to not currently conform to the spec with respect to NaN behavior. The spec requires multiple NaNs to be returned, but np.unique() returns a single NaN. Since this is currently an open issue in NumPy to possibly revert, I have not yet worked around this. See https://github.com/numpy/numpy/issues/20326. * Add the stream argument to the array API to_device method This does nothing in NumPy, and is just present so that the signature is valid according to the spec. * Use the NamedTuple classes for the type signatures * Add unique_counts to the array API namespace * Remove some unused imports * Update the array_api indexing restrictions The "multiaxis indexing must index every axis explicitly or use an ellipsis" was supposed to include any type of index, not just tuple indices. * Use a simpler type annotation for the array API to_device method * Fix a test failure in the array_api submodule The array_api cannot use the NumPy testing functions because array_api arrays do not mix with NumPy arrays, and also NumPy testing functions may use APIs that aren't supported in the array API. * Add dlpack support to the array_api submodule
| * TST: Add a test for device property in `array_api` namespace (#20271)Amit Kumar2021-11-031-0/+11
| |
* | resolved conflictsGagandeep Singh2021-11-022-21/+24
|\ \ | |/
| * MAINT: remove unused importsAlessia Marcolini2021-10-081-15/+0
| |
| * ENH: Updates to numpy.array_api (#19937)Aaron Meurer2021-09-251-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add __index__ to array_api and update __int__, __bool__, and __float__ The spec specifies that they should only work on arrays with corresponding dtypes. __index__ is new in the spec since the initial PR, and works identically to np.array.__index__. * Add the to_device method to the array_api This method is new since #18585. It does nothing in NumPy since NumPy does not support non-CPU devices. * Update transpose methods in the array_api transpose() was renamed to matrix_transpose() and now operates on stacks of matrices. A function to permute dimensions will be added once it is finalized in the spec. The attribute mT was added and the T attribute was updated to only operate on 2-dimensional arrays as per the spec. * Restrict input dtypes in the array API statistical functions * Add the dtype parameter to the array API sum() and prod() * Add the function permute_dims() to the array_api namespace permute_dims() is the replacement for transpose(), which was split into permute_dims() and matrix_transpose(). * Add tril and triu to the array API namespace * Fix the array_api Array.__repr__ to indent the array properly * Make the Device type in the array_api just accept the string "cpu"
* | Addressed reviewsczgdp18072021-09-041-1/+1
| |
* | fixed linting issuesczgdp18072021-09-031-2/+2
| |
* | fixed linting issuesczgdp18072021-09-031-1/+2
| |
* | CopyMode added to np.array_apiczgdp18072021-09-031-5/+10
|/
* Run (selective) black on the array_api submoduleAaron Meurer2021-08-063-144/+212
| | | | | | I've omitted a few changes from black that messed up the readability of some complicated if statements that were organized logically line-by-line, and some changes that use unnecessary operator spacing.
* Fix some dictionary key mismatches in the array API testsAaron Meurer2021-08-061-27/+27
|
* Move the array API dtype categories into the top levelAaron Meurer2021-08-041-13/+3
| | | | | They are not an official part of the spec but are useful for various parts of the implementation.
* Rename numpy._array_api to numpy.array_apiAaron Meurer2021-08-044-0/+470
Instead of the leading underscore, the experimentalness of the module will be indicated by omitting a warning on import. That we, we do not have to change the API from underscore to no underscore when the module is no longer experimental.