Skip to content

Commit f54d6f3

Browse files
committed
MAINT: drop ceil/trunc/floor from common/_aliases.py
1 parent 3bd0ec0 commit f54d6f3

File tree

5 files changed

+4
-42
lines changed

5 files changed

+4
-42
lines changed

array_api_compat/common/_aliases.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -524,33 +524,6 @@ def nonzero(x: Array, /, xp: Namespace, **kwargs: object) -> tuple[Array, ...]:
524524
return xp.nonzero(x, **kwargs)
525525

526526

527-
# ceil, floor, and trunc return integers for integer inputs
528-
529-
530-
def ceil(x: Array, /, xp: Namespace, **kwargs: object) -> Array:
531-
result = xp.ceil(x, **kwargs)
532-
if result.dtype != x.dtype:
533-
# numpy < 2: ceil(int array) is float
534-
result = xp.asarray(result, dtype=x.dtype)
535-
return result
536-
537-
538-
def floor(x: Array, /, xp: Namespace, **kwargs: object) -> Array:
539-
result = xp.floor(x, **kwargs)
540-
if result.dtype != x.dtype:
541-
# numpy < 2: floor(int array) is float
542-
result = xp.asarray(result, dtype=x.dtype)
543-
return result
544-
545-
546-
def trunc(x: Array, /, xp: Namespace, **kwargs: object) -> Array:
547-
result = xp.trunc(x, **kwargs)
548-
if result.dtype != x.dtype:
549-
# numpy < 2: trunc(int array) is float
550-
result = xp.asarray(result, dtype=x.dtype)
551-
return result
552-
553-
554527
# linear algebra functions
555528

556529

@@ -713,9 +686,6 @@ def iinfo(type_: DType | Array, /, xp: Namespace) -> Any:
713686
"argsort",
714687
"sort",
715688
"nonzero",
716-
"ceil",
717-
"floor",
718-
"trunc",
719689
"matmul",
720690
"matrix_transpose",
721691
"tensordot",

array_api_compat/cupy/_aliases.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
argsort = get_xp(cp)(_aliases.argsort)
5555
sort = get_xp(cp)(_aliases.sort)
5656
nonzero = get_xp(cp)(_aliases.nonzero)
57-
ceil = get_xp(cp)(_aliases.ceil)
58-
floor = get_xp(cp)(_aliases.floor)
59-
trunc = get_xp(cp)(_aliases.trunc)
6057
matmul = get_xp(cp)(_aliases.matmul)
6158
matrix_transpose = get_xp(cp)(_aliases.matrix_transpose)
6259
tensordot = get_xp(cp)(_aliases.tensordot)

array_api_compat/dask/array/_aliases.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ def arange(
134134
matrix_transpose = get_xp(da)(_aliases.matrix_transpose)
135135
vecdot = get_xp(da)(_aliases.vecdot)
136136
nonzero = get_xp(da)(_aliases.nonzero)
137-
ceil = get_xp(np)(_aliases.ceil)
138-
floor = get_xp(np)(_aliases.floor)
139-
trunc = get_xp(np)(_aliases.trunc)
140137
matmul = get_xp(np)(_aliases.matmul)
141138
tensordot = get_xp(np)(_aliases.tensordot)
142139
sign = get_xp(np)(_aliases.sign)

array_api_compat/numpy/_aliases.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@
6363
argsort = get_xp(np)(_aliases.argsort)
6464
sort = get_xp(np)(_aliases.sort)
6565
nonzero = get_xp(np)(_aliases.nonzero)
66-
ceil = get_xp(np)(_aliases.ceil)
67-
floor = get_xp(np)(_aliases.floor)
68-
trunc = get_xp(np)(_aliases.trunc)
6966
matmul = get_xp(np)(_aliases.matmul)
7067
matrix_transpose = get_xp(np)(_aliases.matrix_transpose)
7168
tensordot = get_xp(np)(_aliases.tensordot)

tests/test_copies_or_views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def is_view(func, a, value):
3737
"""Apply `func`, mutate the output; does the input change?"""
3838
b = func(a)
3939
b[0] = value
40-
return a[0] == value
40+
return a[0] == value, b.dtype == a.dtype
4141

4242

4343
@pytest.mark.parametrize('xp_name', LIB_NAMES)
@@ -57,10 +57,11 @@ def test_view_or_copy(inputs, xp_name):
5757

5858
# bare namespace: mutate the output, does the input change?
5959
a = bare_xp.asarray(arr_input, dtype=dtype)
60-
is_view_bare = is_view(bare_func, a, value)
60+
is_view_bare, dtype_same_bare = is_view(bare_func, a, value)
6161

6262
# wrapped namespace: mutate the output, does the input change?
6363
a1 = wrapped_xp.asarray(arr_input, dtype=dtype)
64-
is_view_wrapped = is_view(wrapped_func, a1, value)
64+
is_view_wrapped, dtype_same_wrapped = is_view(wrapped_func, a1, value)
6565

6666
assert is_view_bare == is_view_wrapped
67+
assert dtype_same_bare == dtype_same_wrapped

0 commit comments

Comments
 (0)