From 09b1df18ffb75100c64f837422b045401d8e046a Mon Sep 17 00:00:00 2001 From: Jim Pivarski Date: Thu, 28 Dec 2023 19:22:12 +0530 Subject: [PATCH] refactor: organize submodules and tests by spec. (#4) * refactor: organize submodules and tests by spec. * Rename submodules to match test file names. * Adjust for new names. --- src/ragged/common/__init__.py | 63 ++++++++++------- .../common/{_obj.py => _spec_array_object.py} | 0 .../common/{_const.py => _spec_constants.py} | 0 ...reation.py => _spec_creation_functions.py} | 2 +- ...tatype.py => _spec_data_type_functions.py} | 2 +- ...wise.py => _spec_elementwise_functions.py} | 2 +- ...ndexing.py => _spec_indexing_functions.py} | 2 +- ...g.py => _spec_linear_algebra_functions.py} | 2 +- ...ion.py => _spec_manipulation_functions.py} | 2 +- ...search.py => _spec_searching_functions.py} | 2 +- .../{_set.py => _spec_set_functions.py} | 2 +- ..._sorting.py => _spec_sorting_functions.py} | 2 +- ...ical.py => _spec_statistical_functions.py} | 2 +- ..._utility.py => _spec_utility_functions.py} | 2 +- src/ragged/v202212/__init__.py | 63 ++++++++++------- .../{_obj.py => _spec_array_object.py} | 2 +- .../v202212/{_const.py => _spec_constants.py} | 2 +- ...reation.py => _spec_creation_functions.py} | 2 +- ...tatype.py => _spec_data_type_functions.py} | 2 +- ...wise.py => _spec_elementwise_functions.py} | 2 +- ...ndexing.py => _spec_indexing_functions.py} | 2 +- ...g.py => _spec_linear_algebra_functions.py} | 7 +- ...ion.py => _spec_manipulation_functions.py} | 2 +- ...search.py => _spec_searching_functions.py} | 2 +- .../{_set.py => _spec_set_functions.py} | 7 +- ..._sorting.py => _spec_sorting_functions.py} | 2 +- ...ical.py => _spec_statistical_functions.py} | 2 +- ..._utility.py => _spec_utility_functions.py} | 2 +- tests/test_spec_array_object.py | 13 ++++ tests/test_spec_broadcasting.py | 11 +++ tests/test_spec_constants.py | 20 ++++++ tests/test_spec_creation_functions.py | 28 ++++++++ tests/test_spec_data_type_functions.py | 18 +++++ ....py => test_spec_elementwise_functions.py} | 67 ++----------------- tests/test_spec_indexing.py | 11 +++ tests/test_spec_indexing_functions.py | 13 ++++ tests/test_spec_linear_algebra_functions.py | 16 +++++ tests/test_spec_manipulation_functions.py | 22 ++++++ tests/test_spec_searching_functions.py | 16 +++++ tests/test_spec_set_functions.py | 16 +++++ tests/test_spec_sorting_functions.py | 14 ++++ tests/test_spec_statistical_functions.py | 19 ++++++ tests/test_spec_utility_functions.py | 14 ++++ tests/test_spec_version.py | 15 +++++ tests/test_type_promotion.py | 11 +++ 45 files changed, 372 insertions(+), 136 deletions(-) rename src/ragged/common/{_obj.py => _spec_array_object.py} (100%) rename src/ragged/common/{_const.py => _spec_constants.py} (100%) rename src/ragged/common/{_creation.py => _spec_creation_functions.py} (99%) rename src/ragged/common/{_datatype.py => _spec_data_type_functions.py} (99%) rename src/ragged/common/{_elementwise.py => _spec_elementwise_functions.py} (99%) rename src/ragged/common/{_indexing.py => _spec_indexing_functions.py} (97%) rename src/ragged/common/{_linalg.py => _spec_linear_algebra_functions.py} (99%) rename src/ragged/common/{_manipulation.py => _spec_manipulation_functions.py} (99%) rename src/ragged/common/{_search.py => _spec_searching_functions.py} (99%) rename src/ragged/common/{_set.py => _spec_set_functions.py} (99%) rename src/ragged/common/{_sorting.py => _spec_sorting_functions.py} (98%) rename src/ragged/common/{_statistical.py => _spec_statistical_functions.py} (99%) rename src/ragged/common/{_utility.py => _spec_utility_functions.py} (99%) rename src/ragged/v202212/{_obj.py => _spec_array_object.py} (85%) rename src/ragged/v202212/{_const.py => _spec_constants.py} (80%) rename src/ragged/v202212/{_creation.py => _spec_creation_functions.py} (93%) rename src/ragged/v202212/{_datatype.py => _spec_data_type_functions.py} (89%) rename src/ragged/v202212/{_elementwise.py => _spec_elementwise_functions.py} (96%) rename src/ragged/v202212/{_indexing.py => _spec_indexing_functions.py} (81%) rename src/ragged/v202212/{_linalg.py => _spec_linear_algebra_functions.py} (70%) rename src/ragged/v202212/{_manipulation.py => _spec_manipulation_functions.py} (91%) rename src/ragged/v202212/{_search.py => _spec_searching_functions.py} (78%) rename src/ragged/v202212/{_set.py => _spec_set_functions.py} (70%) rename src/ragged/v202212/{_sorting.py => _spec_sorting_functions.py} (80%) rename src/ragged/v202212/{_statistical.py => _spec_statistical_functions.py} (81%) rename src/ragged/v202212/{_utility.py => _spec_utility_functions.py} (74%) create mode 100644 tests/test_spec_array_object.py create mode 100644 tests/test_spec_broadcasting.py create mode 100644 tests/test_spec_constants.py create mode 100644 tests/test_spec_creation_functions.py create mode 100644 tests/test_spec_data_type_functions.py rename tests/{test_0001_initial_array_object.py => test_spec_elementwise_functions.py} (51%) create mode 100644 tests/test_spec_indexing.py create mode 100644 tests/test_spec_indexing_functions.py create mode 100644 tests/test_spec_linear_algebra_functions.py create mode 100644 tests/test_spec_manipulation_functions.py create mode 100644 tests/test_spec_searching_functions.py create mode 100644 tests/test_spec_set_functions.py create mode 100644 tests/test_spec_sorting_functions.py create mode 100644 tests/test_spec_statistical_functions.py create mode 100644 tests/test_spec_utility_functions.py create mode 100644 tests/test_spec_version.py create mode 100644 tests/test_type_promotion.py diff --git a/src/ragged/common/__init__.py b/src/ragged/common/__init__.py index c1990ac..076de36 100644 --- a/src/ragged/common/__init__.py +++ b/src/ragged/common/__init__.py @@ -9,7 +9,15 @@ from __future__ import annotations -from ._creation import ( +from ._spec_array_object import array +from ._spec_constants import ( + e, + inf, + nan, + newaxis, + pi, +) +from ._spec_creation_functions import ( arange, asarray, empty, @@ -27,7 +35,7 @@ zeros, zeros_like, ) -from ._datatype import ( +from ._spec_data_type_functions import ( astype, can_cast, finfo, @@ -35,7 +43,7 @@ isdtype, result_type, ) -from ._elementwise import ( # pylint: disable=W0622 +from ._spec_elementwise_functions import ( # pylint: disable=W0622 abs, acos, acosh, @@ -96,16 +104,16 @@ tanh, trunc, ) -from ._indexing import ( +from ._spec_indexing_functions import ( take, ) -from ._linalg import ( +from ._spec_linear_algebra_functions import ( matmul, matrix_transpose, tensordot, vecdot, ) -from ._manipulation import ( +from ._spec_manipulation_functions import ( broadcast_arrays, broadcast_to, concat, @@ -117,24 +125,23 @@ squeeze, stack, ) -from ._obj import array -from ._search import ( +from ._spec_searching_functions import ( argmax, argmin, nonzero, where, ) -from ._set import ( +from ._spec_set_functions import ( unique_all, unique_counts, unique_inverse, unique_values, ) -from ._sorting import ( +from ._spec_sorting_functions import ( argsort, sort, ) -from ._statistical import ( # pylint: disable=W0622 +from ._spec_statistical_functions import ( # pylint: disable=W0622 max, mean, min, @@ -143,13 +150,21 @@ sum, var, ) -from ._utility import ( # pylint: disable=W0622 +from ._spec_utility_functions import ( # pylint: disable=W0622 all, any, ) __all__ = [ - # _creation + # _spec_array_object + "array", + # _spec_constants + "e", + "inf", + "nan", + "newaxis", + "pi", + # _spec_creation_functions "arange", "asarray", "empty", @@ -166,14 +181,14 @@ "triu", "zeros", "zeros_like", - # _datatype + # _spec_data_type_functions "astype", "can_cast", "finfo", "iinfo", "isdtype", "result_type", - # _elementwise + # _spec_elementwise_functions "abs", "acos", "acosh", @@ -233,14 +248,14 @@ "tan", "tanh", "trunc", - # _indexing + # _spec_indexing_functions "take", - # _linalg + # _spec_linear_algebra_functions "matmul", "matrix_transpose", "tensordot", "vecdot", - # _manipulation + # _spec_manipulation_functions "broadcast_arrays", "broadcast_to", "concat", @@ -251,22 +266,20 @@ "roll", "squeeze", "stack", - # _obj - "array", - # _search + # _spec_searching_functions "argmax", "argmin", "nonzero", "where", - # _set + # _spec_set_functions "unique_all", "unique_counts", "unique_inverse", "unique_values", - # _sorting + # _spec_sorting_functions "argsort", "sort", - # _statistical + # _spec_statistical_functions "max", "mean", "min", @@ -274,7 +287,7 @@ "std", "sum", "var", - # _utility + # _spec_utility_functions "all", "any", ] diff --git a/src/ragged/common/_obj.py b/src/ragged/common/_spec_array_object.py similarity index 100% rename from src/ragged/common/_obj.py rename to src/ragged/common/_spec_array_object.py diff --git a/src/ragged/common/_const.py b/src/ragged/common/_spec_constants.py similarity index 100% rename from src/ragged/common/_const.py rename to src/ragged/common/_spec_constants.py diff --git a/src/ragged/common/_creation.py b/src/ragged/common/_spec_creation_functions.py similarity index 99% rename from src/ragged/common/_creation.py rename to src/ragged/common/_spec_creation_functions.py index 1be7fd8..0e64ca7 100644 --- a/src/ragged/common/_creation.py +++ b/src/ragged/common/_spec_creation_functions.py @@ -8,7 +8,7 @@ import awkward as ak -from ._obj import array +from ._spec_array_object import array from ._typing import ( Device, Dtype, diff --git a/src/ragged/common/_datatype.py b/src/ragged/common/_spec_data_type_functions.py similarity index 99% rename from src/ragged/common/_datatype.py rename to src/ragged/common/_spec_data_type_functions.py index 2c7a2be..5c0df34 100644 --- a/src/ragged/common/_datatype.py +++ b/src/ragged/common/_spec_data_type_functions.py @@ -10,7 +10,7 @@ import numpy as np -from ._obj import array +from ._spec_array_object import array from ._typing import Dtype diff --git a/src/ragged/common/_elementwise.py b/src/ragged/common/_spec_elementwise_functions.py similarity index 99% rename from src/ragged/common/_elementwise.py rename to src/ragged/common/_spec_elementwise_functions.py index 12b100d..3e8e218 100644 --- a/src/ragged/common/_elementwise.py +++ b/src/ragged/common/_spec_elementwise_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ._obj import array +from ._spec_array_object import array def abs(x: array, /) -> array: # pylint: disable=W0622 diff --git a/src/ragged/common/_indexing.py b/src/ragged/common/_spec_indexing_functions.py similarity index 97% rename from src/ragged/common/_indexing.py rename to src/ragged/common/_spec_indexing_functions.py index 27d546b..6c82f19 100644 --- a/src/ragged/common/_indexing.py +++ b/src/ragged/common/_spec_indexing_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ._obj import array +from ._spec_array_object import array def take(x: array, indices: array, /, *, axis: None | int = None) -> array: diff --git a/src/ragged/common/_linalg.py b/src/ragged/common/_spec_linear_algebra_functions.py similarity index 99% rename from src/ragged/common/_linalg.py rename to src/ragged/common/_spec_linear_algebra_functions.py index 7c08a86..5690296 100644 --- a/src/ragged/common/_linalg.py +++ b/src/ragged/common/_spec_linear_algebra_functions.py @@ -8,7 +8,7 @@ from collections.abc import Sequence -from ._obj import array +from ._spec_array_object import array def matmul(x1: array, x2: array, /) -> array: diff --git a/src/ragged/common/_manipulation.py b/src/ragged/common/_spec_manipulation_functions.py similarity index 99% rename from src/ragged/common/_manipulation.py rename to src/ragged/common/_spec_manipulation_functions.py index b287e38..84c4000 100644 --- a/src/ragged/common/_manipulation.py +++ b/src/ragged/common/_spec_manipulation_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ._obj import array +from ._spec_array_object import array def broadcast_arrays(*arrays: array) -> list[array]: diff --git a/src/ragged/common/_search.py b/src/ragged/common/_spec_searching_functions.py similarity index 99% rename from src/ragged/common/_search.py rename to src/ragged/common/_spec_searching_functions.py index 41e7a90..fd587b5 100644 --- a/src/ragged/common/_search.py +++ b/src/ragged/common/_spec_searching_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ._obj import array +from ._spec_array_object import array def argmax(x: array, /, *, axis: None | int = None, keepdims: bool = False) -> array: diff --git a/src/ragged/common/_set.py b/src/ragged/common/_spec_set_functions.py similarity index 99% rename from src/ragged/common/_set.py rename to src/ragged/common/_spec_set_functions.py index a2039f5..2dd96f4 100644 --- a/src/ragged/common/_set.py +++ b/src/ragged/common/_spec_set_functions.py @@ -8,7 +8,7 @@ from collections import namedtuple -from ._obj import array +from ._spec_array_object import array unique_all_result = namedtuple( # pylint: disable=C0103 "unique_all_result", ["values", "indices", "inverse_indices", "counts"] diff --git a/src/ragged/common/_sorting.py b/src/ragged/common/_spec_sorting_functions.py similarity index 98% rename from src/ragged/common/_sorting.py rename to src/ragged/common/_spec_sorting_functions.py index ba7eeec..d448333 100644 --- a/src/ragged/common/_sorting.py +++ b/src/ragged/common/_spec_sorting_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ._obj import array +from ._spec_array_object import array def argsort( diff --git a/src/ragged/common/_statistical.py b/src/ragged/common/_spec_statistical_functions.py similarity index 99% rename from src/ragged/common/_statistical.py rename to src/ragged/common/_spec_statistical_functions.py index 410b955..eaf55c9 100644 --- a/src/ragged/common/_statistical.py +++ b/src/ragged/common/_spec_statistical_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ._obj import array +from ._spec_array_object import array from ._typing import Dtype diff --git a/src/ragged/common/_utility.py b/src/ragged/common/_spec_utility_functions.py similarity index 99% rename from src/ragged/common/_utility.py rename to src/ragged/common/_spec_utility_functions.py index 0e74e1c..5184afa 100644 --- a/src/ragged/common/_utility.py +++ b/src/ragged/common/_spec_utility_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ._obj import array +from ._spec_array_object import array def all( # pylint: disable=W0622 diff --git a/src/ragged/v202212/__init__.py b/src/ragged/v202212/__init__.py index b193f44..8b9ac6f 100644 --- a/src/ragged/v202212/__init__.py +++ b/src/ragged/v202212/__init__.py @@ -13,7 +13,15 @@ __array_api_version__ = "2022.12" -from ._creation import ( +from ._spec_array_object import array +from ._spec_constants import ( + e, + inf, + nan, + newaxis, + pi, +) +from ._spec_creation_functions import ( arange, asarray, empty, @@ -31,7 +39,7 @@ zeros, zeros_like, ) -from ._datatype import ( +from ._spec_data_type_functions import ( astype, can_cast, finfo, @@ -39,7 +47,7 @@ isdtype, result_type, ) -from ._elementwise import ( # pylint: disable=W0622 +from ._spec_elementwise_functions import ( # pylint: disable=W0622 abs, acos, acosh, @@ -100,16 +108,16 @@ tanh, trunc, ) -from ._indexing import ( +from ._spec_indexing_functions import ( take, ) -from ._linalg import ( +from ._spec_linear_algebra_functions import ( matmul, matrix_transpose, tensordot, vecdot, ) -from ._manipulation import ( +from ._spec_manipulation_functions import ( broadcast_arrays, broadcast_to, concat, @@ -121,24 +129,23 @@ squeeze, stack, ) -from ._obj import array -from ._search import ( +from ._spec_searching_functions import ( argmax, argmin, nonzero, where, ) -from ._set import ( +from ._spec_set_functions import ( unique_all, unique_counts, unique_inverse, unique_values, ) -from ._sorting import ( +from ._spec_sorting_functions import ( argsort, sort, ) -from ._statistical import ( # pylint: disable=W0622 +from ._spec_statistical_functions import ( # pylint: disable=W0622 max, mean, min, @@ -147,14 +154,22 @@ sum, var, ) -from ._utility import ( # pylint: disable=W0622 +from ._spec_utility_functions import ( # pylint: disable=W0622 all, any, ) __all__ = [ "__array_api_version__", - # _creation + # _spec_array_object + "array", + # _spec_constants + "e", + "inf", + "nan", + "newaxis", + "pi", + # _spec_creation_functions "arange", "asarray", "empty", @@ -171,14 +186,14 @@ "triu", "zeros", "zeros_like", - # _datatype + # _spec_data_type_functions "astype", "can_cast", "finfo", "iinfo", "isdtype", "result_type", - # _elementwise + # _spec_elementwise_functions "abs", "acos", "acosh", @@ -238,14 +253,14 @@ "tan", "tanh", "trunc", - # _indexing + # _spec_indexing_functions "take", - # _linalg + # _spec_linear_algebra_functions "matmul", "matrix_transpose", "tensordot", "vecdot", - # _manipulation + # _spec_manipulation_functions "broadcast_arrays", "broadcast_to", "concat", @@ -256,22 +271,20 @@ "roll", "squeeze", "stack", - # _obj - "array", - # _search + # _spec_searching_functions "argmax", "argmin", "nonzero", "where", - # _set + # _spec_set_functions "unique_all", "unique_counts", "unique_inverse", "unique_values", - # _sorting + # _spec_sorting_functions "argsort", "sort", - # _statistical + # _spec_statistical_functions "max", "mean", "min", @@ -279,7 +292,7 @@ "std", "sum", "var", - # _utility + # _spec_utility_functions "all", "any", ] diff --git a/src/ragged/v202212/_obj.py b/src/ragged/v202212/_spec_array_object.py similarity index 85% rename from src/ragged/v202212/_obj.py rename to src/ragged/v202212/_spec_array_object.py index 3a4e2b2..b02a87a 100644 --- a/src/ragged/v202212/_obj.py +++ b/src/ragged/v202212/_spec_array_object.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ..common._obj import array as common_array +from ..common._spec_array_object import array as common_array class array(common_array): # pylint: disable=C0103 diff --git a/src/ragged/v202212/_const.py b/src/ragged/v202212/_spec_constants.py similarity index 80% rename from src/ragged/v202212/_const.py rename to src/ragged/v202212/_spec_constants.py index d55ef49..d2a410d 100644 --- a/src/ragged/v202212/_const.py +++ b/src/ragged/v202212/_spec_constants.py @@ -6,6 +6,6 @@ from __future__ import annotations -from ..common._const import e, inf, nan, newaxis, pi +from ..common._spec_constants import e, inf, nan, newaxis, pi __all__ = ["e", "inf", "nan", "newaxis", "pi"] diff --git a/src/ragged/v202212/_creation.py b/src/ragged/v202212/_spec_creation_functions.py similarity index 93% rename from src/ragged/v202212/_creation.py rename to src/ragged/v202212/_spec_creation_functions.py index 2148440..5a15f63 100644 --- a/src/ragged/v202212/_creation.py +++ b/src/ragged/v202212/_spec_creation_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ..common._creation import ( +from ..common._spec_creation_functions import ( arange, asarray, empty, diff --git a/src/ragged/v202212/_datatype.py b/src/ragged/v202212/_spec_data_type_functions.py similarity index 89% rename from src/ragged/v202212/_datatype.py rename to src/ragged/v202212/_spec_data_type_functions.py index 35d9923..5e4a54a 100644 --- a/src/ragged/v202212/_datatype.py +++ b/src/ragged/v202212/_spec_data_type_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ..common._datatype import ( +from ..common._spec_data_type_functions import ( astype, can_cast, finfo, diff --git a/src/ragged/v202212/_elementwise.py b/src/ragged/v202212/_spec_elementwise_functions.py similarity index 96% rename from src/ragged/v202212/_elementwise.py rename to src/ragged/v202212/_spec_elementwise_functions.py index 6960051..c2d670d 100644 --- a/src/ragged/v202212/_elementwise.py +++ b/src/ragged/v202212/_spec_elementwise_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ..common._elementwise import ( # pylint: disable=W0622 +from ..common._spec_elementwise_functions import ( # pylint: disable=W0622 abs, acos, acosh, diff --git a/src/ragged/v202212/_indexing.py b/src/ragged/v202212/_spec_indexing_functions.py similarity index 81% rename from src/ragged/v202212/_indexing.py rename to src/ragged/v202212/_spec_indexing_functions.py index f1553c2..87952c1 100644 --- a/src/ragged/v202212/_indexing.py +++ b/src/ragged/v202212/_spec_indexing_functions.py @@ -6,6 +6,6 @@ from __future__ import annotations -from ..common._indexing import take +from ..common._spec_indexing_functions import take __all__ = ["take"] diff --git a/src/ragged/v202212/_linalg.py b/src/ragged/v202212/_spec_linear_algebra_functions.py similarity index 70% rename from src/ragged/v202212/_linalg.py rename to src/ragged/v202212/_spec_linear_algebra_functions.py index 5dbe366..9840905 100644 --- a/src/ragged/v202212/_linalg.py +++ b/src/ragged/v202212/_spec_linear_algebra_functions.py @@ -6,6 +6,11 @@ from __future__ import annotations -from ..common._linalg import matmul, matrix_transpose, tensordot, vecdot +from ..common._spec_linear_algebra_functions import ( + matmul, + matrix_transpose, + tensordot, + vecdot, +) __all__ = ["matmul", "matrix_transpose", "tensordot", "vecdot"] diff --git a/src/ragged/v202212/_manipulation.py b/src/ragged/v202212/_spec_manipulation_functions.py similarity index 91% rename from src/ragged/v202212/_manipulation.py rename to src/ragged/v202212/_spec_manipulation_functions.py index 17caf9a..520185b 100644 --- a/src/ragged/v202212/_manipulation.py +++ b/src/ragged/v202212/_spec_manipulation_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ..common._manipulation import ( +from ..common._spec_manipulation_functions import ( broadcast_arrays, broadcast_to, concat, diff --git a/src/ragged/v202212/_search.py b/src/ragged/v202212/_spec_searching_functions.py similarity index 78% rename from src/ragged/v202212/_search.py rename to src/ragged/v202212/_spec_searching_functions.py index 3d2d700..1c9d607 100644 --- a/src/ragged/v202212/_search.py +++ b/src/ragged/v202212/_spec_searching_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ..common._search import argmax, argmin, nonzero, where +from ..common._spec_searching_functions import argmax, argmin, nonzero, where __all__ = [ "argmax", diff --git a/src/ragged/v202212/_set.py b/src/ragged/v202212/_spec_set_functions.py similarity index 70% rename from src/ragged/v202212/_set.py rename to src/ragged/v202212/_spec_set_functions.py index bb1ea0b..7b53eb4 100644 --- a/src/ragged/v202212/_set.py +++ b/src/ragged/v202212/_spec_set_functions.py @@ -6,6 +6,11 @@ from __future__ import annotations -from ..common._set import unique_all, unique_counts, unique_inverse, unique_values +from ..common._spec_set_functions import ( + unique_all, + unique_counts, + unique_inverse, + unique_values, +) __all__ = ["unique_all", "unique_counts", "unique_inverse", "unique_values"] diff --git a/src/ragged/v202212/_sorting.py b/src/ragged/v202212/_spec_sorting_functions.py similarity index 80% rename from src/ragged/v202212/_sorting.py rename to src/ragged/v202212/_spec_sorting_functions.py index b6702d5..e2dfbf4 100644 --- a/src/ragged/v202212/_sorting.py +++ b/src/ragged/v202212/_spec_sorting_functions.py @@ -6,6 +6,6 @@ from __future__ import annotations -from ..common._sorting import argsort, sort +from ..common._spec_sorting_functions import argsort, sort __all__ = ["argsort", "sort"] diff --git a/src/ragged/v202212/_statistical.py b/src/ragged/v202212/_spec_statistical_functions.py similarity index 81% rename from src/ragged/v202212/_statistical.py rename to src/ragged/v202212/_spec_statistical_functions.py index 1c2a625..c072ef5 100644 --- a/src/ragged/v202212/_statistical.py +++ b/src/ragged/v202212/_spec_statistical_functions.py @@ -6,7 +6,7 @@ from __future__ import annotations -from ..common._statistical import ( # pylint: disable=W0622 +from ..common._spec_statistical_functions import ( # pylint: disable=W0622 max, mean, min, diff --git a/src/ragged/v202212/_utility.py b/src/ragged/v202212/_spec_utility_functions.py similarity index 74% rename from src/ragged/v202212/_utility.py rename to src/ragged/v202212/_spec_utility_functions.py index 1a120cb..1e60440 100644 --- a/src/ragged/v202212/_utility.py +++ b/src/ragged/v202212/_spec_utility_functions.py @@ -6,6 +6,6 @@ from __future__ import annotations -from ..common._utility import all, any # pylint: disable=W0622 +from ..common._spec_utility_functions import all, any # pylint: disable=W0622 __all__ = ["all", "any"] diff --git a/tests/test_spec_array_object.py b/tests/test_spec_array_object.py new file mode 100644 index 0000000..0af1ab1 --- /dev/null +++ b/tests/test_spec_array_object.py @@ -0,0 +1,13 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/array_object.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.array is not None diff --git a/tests/test_spec_broadcasting.py b/tests/test_spec_broadcasting.py new file mode 100644 index 0000000..afc9dce --- /dev/null +++ b/tests/test_spec_broadcasting.py @@ -0,0 +1,11 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/broadcasting.html +""" + +from __future__ import annotations + + +def test(): + pass diff --git a/tests/test_spec_constants.py b/tests/test_spec_constants.py new file mode 100644 index 0000000..f8343c6 --- /dev/null +++ b/tests/test_spec_constants.py @@ -0,0 +1,20 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/constants.html +""" + +from __future__ import annotations + +import math + +import ragged + + +def test_values(): + assert ragged.e == math.e + assert not math.isfinite(ragged.inf) + assert ragged.inf > 0 + assert math.isnan(ragged.nan) + assert ragged.newaxis is None + assert ragged.pi == math.pi diff --git a/tests/test_spec_creation_functions.py b/tests/test_spec_creation_functions.py new file mode 100644 index 0000000..45c1b57 --- /dev/null +++ b/tests/test_spec_creation_functions.py @@ -0,0 +1,28 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/creation_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.arange is not None + assert ragged.asarray is not None + assert ragged.empty is not None + assert ragged.empty_like is not None + assert ragged.eye is not None + assert ragged.from_dlpack is not None + assert ragged.full is not None + assert ragged.full_like is not None + assert ragged.linspace is not None + assert ragged.meshgrid is not None + assert ragged.ones is not None + assert ragged.ones_like is not None + assert ragged.tril is not None + assert ragged.triu is not None + assert ragged.zeros is not None + assert ragged.zeros_like is not None diff --git a/tests/test_spec_data_type_functions.py b/tests/test_spec_data_type_functions.py new file mode 100644 index 0000000..b31bc52 --- /dev/null +++ b/tests/test_spec_data_type_functions.py @@ -0,0 +1,18 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/data_type_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.astype is not None + assert ragged.can_cast is not None + assert ragged.finfo is not None + assert ragged.iinfo is not None + assert ragged.isdtype is not None + assert ragged.result_type is not None diff --git a/tests/test_0001_initial_array_object.py b/tests/test_spec_elementwise_functions.py similarity index 51% rename from tests/test_0001_initial_array_object.py rename to tests/test_spec_elementwise_functions.py index 2cdd1ef..c8ebc66 100644 --- a/tests/test_0001_initial_array_object.py +++ b/tests/test_spec_elementwise_functions.py @@ -1,38 +1,15 @@ # BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE +""" +https://data-apis.org/array-api/latest/API_specification/elementwise_functions.html +""" + from __future__ import annotations import ragged -def test(): - assert ragged.__array_api_version__ == "2022.12" - - a = ragged.array([[1, 2], [3]]) - assert a is not None - - assert ragged.arange is not None - assert ragged.asarray is not None - assert ragged.empty is not None - assert ragged.empty_like is not None - assert ragged.eye is not None - assert ragged.from_dlpack is not None - assert ragged.full is not None - assert ragged.full_like is not None - assert ragged.linspace is not None - assert ragged.meshgrid is not None - assert ragged.ones is not None - assert ragged.ones_like is not None - assert ragged.tril is not None - assert ragged.triu is not None - assert ragged.zeros is not None - assert ragged.zeros_like is not None - assert ragged.astype is not None - assert ragged.can_cast is not None - assert ragged.finfo is not None - assert ragged.iinfo is not None - assert ragged.isdtype is not None - assert ragged.result_type is not None +def test_existence(): assert ragged.abs is not None assert ragged.acos is not None assert ragged.acosh is not None @@ -92,37 +69,3 @@ def test(): assert ragged.tan is not None assert ragged.tanh is not None assert ragged.trunc is not None - assert ragged.take is not None - assert ragged.matmul is not None - assert ragged.matrix_transpose is not None - assert ragged.tensordot is not None - assert ragged.vecdot is not None - assert ragged.broadcast_arrays is not None - assert ragged.broadcast_to is not None - assert ragged.concat is not None - assert ragged.expand_dims is not None - assert ragged.flip is not None - assert ragged.permute_dims is not None - assert ragged.reshape is not None - assert ragged.roll is not None - assert ragged.squeeze is not None - assert ragged.stack is not None - assert ragged.argmax is not None - assert ragged.argmin is not None - assert ragged.nonzero is not None - assert ragged.where is not None - assert ragged.unique_all is not None - assert ragged.unique_counts is not None - assert ragged.unique_inverse is not None - assert ragged.unique_values is not None - assert ragged.argsort is not None - assert ragged.sort is not None - assert ragged.max is not None - assert ragged.mean is not None - assert ragged.min is not None - assert ragged.prod is not None - assert ragged.std is not None - assert ragged.sum is not None - assert ragged.var is not None - assert ragged.all is not None - assert ragged.any is not None diff --git a/tests/test_spec_indexing.py b/tests/test_spec_indexing.py new file mode 100644 index 0000000..1776afa --- /dev/null +++ b/tests/test_spec_indexing.py @@ -0,0 +1,11 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/indexing.html +""" + +from __future__ import annotations + + +def test(): + pass diff --git a/tests/test_spec_indexing_functions.py b/tests/test_spec_indexing_functions.py new file mode 100644 index 0000000..89dda12 --- /dev/null +++ b/tests/test_spec_indexing_functions.py @@ -0,0 +1,13 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/indexing_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.take is not None diff --git a/tests/test_spec_linear_algebra_functions.py b/tests/test_spec_linear_algebra_functions.py new file mode 100644 index 0000000..7191323 --- /dev/null +++ b/tests/test_spec_linear_algebra_functions.py @@ -0,0 +1,16 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/linear_algebra_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.matmul is not None + assert ragged.matrix_transpose is not None + assert ragged.tensordot is not None + assert ragged.vecdot is not None diff --git a/tests/test_spec_manipulation_functions.py b/tests/test_spec_manipulation_functions.py new file mode 100644 index 0000000..20b5ff2 --- /dev/null +++ b/tests/test_spec_manipulation_functions.py @@ -0,0 +1,22 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/manipulation_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.broadcast_arrays is not None + assert ragged.broadcast_to is not None + assert ragged.concat is not None + assert ragged.expand_dims is not None + assert ragged.flip is not None + assert ragged.permute_dims is not None + assert ragged.reshape is not None + assert ragged.roll is not None + assert ragged.squeeze is not None + assert ragged.stack is not None diff --git a/tests/test_spec_searching_functions.py b/tests/test_spec_searching_functions.py new file mode 100644 index 0000000..4410eb6 --- /dev/null +++ b/tests/test_spec_searching_functions.py @@ -0,0 +1,16 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/searching_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.argmax is not None + assert ragged.argmin is not None + assert ragged.nonzero is not None + assert ragged.where is not None diff --git a/tests/test_spec_set_functions.py b/tests/test_spec_set_functions.py new file mode 100644 index 0000000..3c06863 --- /dev/null +++ b/tests/test_spec_set_functions.py @@ -0,0 +1,16 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/set_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.unique_all is not None + assert ragged.unique_counts is not None + assert ragged.unique_inverse is not None + assert ragged.unique_values is not None diff --git a/tests/test_spec_sorting_functions.py b/tests/test_spec_sorting_functions.py new file mode 100644 index 0000000..ebf82f7 --- /dev/null +++ b/tests/test_spec_sorting_functions.py @@ -0,0 +1,14 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/sorting_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.argsort is not None + assert ragged.sort is not None diff --git a/tests/test_spec_statistical_functions.py b/tests/test_spec_statistical_functions.py new file mode 100644 index 0000000..252a5f3 --- /dev/null +++ b/tests/test_spec_statistical_functions.py @@ -0,0 +1,19 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/statistical_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.max is not None + assert ragged.mean is not None + assert ragged.min is not None + assert ragged.prod is not None + assert ragged.std is not None + assert ragged.sum is not None + assert ragged.var is not None diff --git a/tests/test_spec_utility_functions.py b/tests/test_spec_utility_functions.py new file mode 100644 index 0000000..cae087a --- /dev/null +++ b/tests/test_spec_utility_functions.py @@ -0,0 +1,14 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/utility_functions.html +""" + +from __future__ import annotations + +import ragged + + +def test_existence(): + assert ragged.all is not None + assert ragged.any is not None diff --git a/tests/test_spec_version.py b/tests/test_spec_version.py new file mode 100644 index 0000000..12ff9b7 --- /dev/null +++ b/tests/test_spec_version.py @@ -0,0 +1,15 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/version.html +""" + +from __future__ import annotations + +import ragged + + +def test_values(): + assert ragged.v202212.__array_api_version__ == "2022.12" + + assert ragged.__array_api_version__ == "2022.12" diff --git a/tests/test_type_promotion.py b/tests/test_type_promotion.py new file mode 100644 index 0000000..938a856 --- /dev/null +++ b/tests/test_type_promotion.py @@ -0,0 +1,11 @@ +# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE + +""" +https://data-apis.org/array-api/latest/API_specification/type_promotion.html +""" + +from __future__ import annotations + + +def test(): + pass