Skip to content

Commit a048a40

Browse files
authored
MNT Remove unused utils._array_api functions (scikit-learn#31785)
1 parent 57a6704 commit a048a40

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

sklearn/utils/_array_api.py

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import itertools
77
import math
88
import os
9-
from functools import wraps
109

1110
import numpy
1211
import scipy
@@ -244,52 +243,6 @@ def _union1d(a, b, xp):
244243
return xp.unique_values(xp.concat([xp.unique_values(a), xp.unique_values(b)]))
245244

246245

247-
def isdtype(dtype, kind, *, xp):
248-
"""Returns a boolean indicating whether a provided dtype is of type "kind".
249-
250-
Included in the v2022.12 of the Array API spec.
251-
https://data-apis.org/array-api/latest/API_specification/generated/array_api.isdtype.html
252-
"""
253-
if isinstance(kind, tuple):
254-
return any(_isdtype_single(dtype, k, xp=xp) for k in kind)
255-
else:
256-
return _isdtype_single(dtype, kind, xp=xp)
257-
258-
259-
def _isdtype_single(dtype, kind, *, xp):
260-
if isinstance(kind, str):
261-
if kind == "bool":
262-
return dtype == xp.bool
263-
elif kind == "signed integer":
264-
return dtype in {xp.int8, xp.int16, xp.int32, xp.int64}
265-
elif kind == "unsigned integer":
266-
return dtype in {xp.uint8, xp.uint16, xp.uint32, xp.uint64}
267-
elif kind == "integral":
268-
return any(
269-
_isdtype_single(dtype, k, xp=xp)
270-
for k in ("signed integer", "unsigned integer")
271-
)
272-
elif kind == "real floating":
273-
return dtype in supported_float_dtypes(xp)
274-
elif kind == "complex floating":
275-
# Some name spaces might not have support for complex dtypes.
276-
complex_dtypes = set()
277-
if hasattr(xp, "complex64"):
278-
complex_dtypes.add(xp.complex64)
279-
if hasattr(xp, "complex128"):
280-
complex_dtypes.add(xp.complex128)
281-
return dtype in complex_dtypes
282-
elif kind == "numeric":
283-
return any(
284-
_isdtype_single(dtype, k, xp=xp)
285-
for k in ("integral", "real floating", "complex floating")
286-
)
287-
else:
288-
raise ValueError(f"Unrecognized data type kind: {kind!r}")
289-
else:
290-
return dtype == kind
291-
292-
293246
def supported_float_dtypes(xp, device=None):
294247
"""Supported floating point types for the namespace.
295248
@@ -342,20 +295,6 @@ def ensure_common_namespace_device(reference, *arrays):
342295
return arrays
343296

344297

345-
def _check_device_cpu(device):
346-
if device not in {"cpu", None}:
347-
raise ValueError(f"Unsupported device for NumPy: {device!r}")
348-
349-
350-
def _accept_device_cpu(func):
351-
@wraps(func)
352-
def wrapped_func(*args, **kwargs):
353-
_check_device_cpu(kwargs.pop("device", None))
354-
return func(*args, **kwargs)
355-
356-
return wrapped_func
357-
358-
359298
def _remove_non_arrays(*arrays, remove_none=True, remove_types=(str,)):
360299
"""Filter arrays to exclude None and/or specific types.
361300

0 commit comments

Comments
 (0)