Skip to content

Commit ef21e49

Browse files
Remove dpnp.asfarray()
1 parent 574e1ca commit ef21e49

File tree

6 files changed

+1
-112
lines changed

6 files changed

+1
-112
lines changed

doc/reference/array-manipulation.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ Changing kind of array
7272
dpnp.asarray
7373
dpnp.asanyarray
7474
dpnp.asnumpy
75-
dpnp.asfarray
7675
dpnp.asfortranarray
7776
dpnp.ascontiguousarray
7877
dpnp.asarray_chkfinite

dpnp/dpnp_iface_arraycreation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,7 @@ def asanyarray(
510510
See Also
511511
--------
512512
:obj:`dpnp.asarray` : Similar function which always returns ndarrays.
513-
:obj:`dpnp.ascontiguousarray` : Convert input to a contiguous array.
514-
:obj:`dpnp.asfarray` : Convert input to a floating point ndarray.
513+
:obj:`dpnp.ascontiguousarray` : Convert input to a contiguous array.ы
515514
:obj:`dpnp.asfortranarray` : Convert input to an ndarray with column-major
516515
memory order.
517516
:obj:`dpnp.asarray_chkfinite` : Similar function which checks input
@@ -624,7 +623,6 @@ def asarray(
624623
--------
625624
:obj:`dpnp.asanyarray` : Similar function which passes through subclasses.
626625
:obj:`dpnp.ascontiguousarray` : Convert input to a contiguous array.
627-
:obj:`dpnp.asfarray` : Convert input to a floating point ndarray.
628626
:obj:`dpnp.asfortranarray` : Convert input to an ndarray with column-major
629627
memory order.
630628
:obj:`dpnp.asarray_chkfinite` : Similar function which checks input

dpnp/dpnp_iface_manipulation.py

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class UniqueInverseResult(NamedTuple):
102102
"append",
103103
"array_split",
104104
"asarray_chkfinite",
105-
"asfarray",
106105
"atleast_1d",
107106
"atleast_2d",
108107
"atleast_3d",
@@ -845,79 +844,6 @@ def asarray_chkfinite(
845844
return a
846845

847846

848-
def asfarray(a, dtype=None, *, device=None, usm_type=None, sycl_queue=None):
849-
"""
850-
Return an array converted to a float type.
851-
852-
For full documentation refer to :obj:`numpy.asfarray`.
853-
854-
Parameters
855-
----------
856-
a : array_like
857-
Input data, in any form that can be converted to an array.
858-
This includes an instance of :class:`dpnp.ndarray` or
859-
:class:`dpctl.tensor.usm_ndarray`, an object representing
860-
SYCL USM allocation and implementing `__sycl_usm_array_interface__`
861-
protocol, an instance of :class:`numpy.ndarray`, an object supporting
862-
Python buffer protocol, a Python scalar, or a (possibly nested)
863-
sequence of Python scalars.
864-
dtype : {None, str, dtype object}, optional
865-
Float type code to coerce input array `a`. If `dtype` is ``None``,
866-
:obj:`dpnp.bool` or one of the `int` dtypes, it is replaced with
867-
the default floating type (:obj:`dpnp.float64` if a device supports it,
868-
or :obj:`dpnp.float32` type otherwise).
869-
870-
Default: ``None``.
871-
device : {None, string, SyclDevice, SyclQueue, Device}, optional
872-
An array API concept of device where the output array is created.
873-
`device` can be ``None``, a oneAPI filter selector string, an instance
874-
of :class:`dpctl.SyclDevice` corresponding to a non-partitioned SYCL
875-
device, an instance of :class:`dpctl.SyclQueue`, or a
876-
:class:`dpctl.tensor.Device` object returned by
877-
:attr:`dpnp.ndarray.device`.
878-
879-
Default: ``None``.
880-
usm_type : {None, "device", "shared", "host"}, optional
881-
The type of SYCL USM allocation for the output array.
882-
883-
Default: ``None``.
884-
sycl_queue : {None, SyclQueue}, optional
885-
A SYCL queue to use for output array allocation and copying. The
886-
`sycl_queue` can be passed as ``None`` (the default), which means
887-
to get the SYCL queue from `device` keyword if present or to use
888-
a default queue.
889-
890-
Default: ``None``.
891-
892-
Returns
893-
-------
894-
out : dpnp.ndarray
895-
The input `a` as a float ndarray.
896-
897-
Examples
898-
--------
899-
>>> import dpnp as np
900-
>>> np.asfarray([2, 3])
901-
array([2., 3.])
902-
>>> np.asfarray([2, 3], dtype=dpnp.float32)
903-
array([2., 3.], dtype=float32)
904-
>>> np.asfarray([2, 3], dtype=dpnp.int32)
905-
array([2., 3.])
906-
907-
"""
908-
909-
_sycl_queue = dpnp.get_normalized_queue_device(
910-
a, sycl_queue=sycl_queue, device=device
911-
)
912-
913-
if dtype is None or not dpnp.issubdtype(dtype, dpnp.inexact):
914-
dtype = dpnp.default_float_type(sycl_queue=_sycl_queue)
915-
916-
return dpnp.asarray(
917-
a, dtype=dtype, usm_type=usm_type, sycl_queue=_sycl_queue
918-
)
919-
920-
921847
def atleast_1d(*arys):
922848
"""
923849
Convert inputs to arrays with at least one dimension.

dpnp/tests/test_arraymanipulation.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,6 @@
1010
from .third_party.cupy import testing
1111

1212

13-
class TestAsfarray:
14-
@testing.with_requires("numpy<2.0")
15-
@pytest.mark.parametrize("dtype", get_all_dtypes())
16-
@pytest.mark.parametrize(
17-
"data", [[1, 2, 3], [1.0, 2.0, 3.0]], ids=["[1, 2, 3]", "[1., 2., 3.]"]
18-
)
19-
def test_asfarray1(self, dtype, data):
20-
expected = numpy.asfarray(data, dtype)
21-
result = dpnp.asfarray(data, dtype)
22-
assert_array_equal(result, expected)
23-
24-
@testing.with_requires("numpy<2.0")
25-
@pytest.mark.usefixtures("suppress_complex_warning")
26-
@pytest.mark.parametrize("dtype", get_all_dtypes())
27-
@pytest.mark.parametrize("data", [[1.0, 2.0, 3.0]], ids=["[1., 2., 3.]"])
28-
@pytest.mark.parametrize("data_dtype", get_all_dtypes(no_none=True))
29-
def test_asfarray2(self, dtype, data, data_dtype):
30-
expected = numpy.asfarray(numpy.array(data, dtype=data_dtype), dtype)
31-
result = dpnp.asfarray(dpnp.array(data, dtype=data_dtype), dtype)
32-
assert_array_equal(result, expected)
33-
34-
# This is only for coverage with NumPy 2.0 and above
35-
def test_asfarray_coverage(self):
36-
expected = dpnp.array([1.0, 2.0, 3.0])
37-
result = dpnp.asfarray([1, 2, 3])
38-
assert_array_equal(result, expected)
39-
40-
expected = dpnp.array([1.0, 2.0, 3.0], dtype=dpnp.float32)
41-
result = dpnp.asfarray([1, 2, 3], dtype=dpnp.float32)
42-
assert_array_equal(result, expected)
43-
44-
4513
class TestAtleast1d:
4614
def test_0D_array(self):
4715
a = dpnp.array(1)

dpnp/tests/test_sycl_queue.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,6 @@ def test_invalid_stream(self, stream):
10011001
"asarray_chkfinite",
10021002
"asanyarray",
10031003
"ascontiguousarray",
1004-
"asfarray",
10051004
"asfortranarray",
10061005
],
10071006
)

dpnp/tests/test_usm_type.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ def test_copy_operation(usm_type):
286286
"asarray_chkfinite",
287287
"asanyarray",
288288
"ascontiguousarray",
289-
"asfarray",
290289
"asfortranarray",
291290
],
292291
)

0 commit comments

Comments
 (0)