Skip to content

Commit 6733ecf

Browse files
Fix or skip "object has no attribute 'astype'" (#952)
Co-authored-by: Alexander-Makaryev <[email protected]>
1 parent 43966e1 commit 6733ecf

File tree

7 files changed

+324
-6
lines changed

7 files changed

+324
-6
lines changed

dpnp/dpnp_algo/dpnp_algo_arraycreation.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ cpdef tuple dpnp_linspace(start, stop, num, endpoint, retstep, dtype, axis):
214214

215215
cpdef object dpnp_logspace(start, stop, num, endpoint, base, dtype, axis):
216216
temp = dpnp.linspace(start, stop, num=num, endpoint=endpoint)
217-
return dpnp.power(base, temp).astype(dtype)
217+
return dpnp_astype(dpnp.get_dpnp_descriptor(dpnp.power(base, temp)), dtype)
218218

219219

220220
cpdef list dpnp_meshgrid(xi, copy, sparse, indexing):

dpnp/dpnp_iface_arraycreation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ def logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0):
869869
if axis != 0:
870870
checker_throw_value_error("linspace", "axis", axis, 0)
871871

872-
return dpnp_logspace(start, stop, num, endpoint, base, dtype, axis)
872+
return dpnp_logspace(start, stop, num, endpoint, base, dtype, axis).get_pyobj()
873873

874874
return call_origin(numpy.logspace, start, stop, num, endpoint, base, dtype, axis)
875875

dpnp/dpnp_iface_statistics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ def cov(x1, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=
292292
pass
293293
else:
294294
if x1_desc.dtype != dpnp.float64:
295-
x1_double_container = x1.astype(dpnp.float64)
296-
x1_desc = dpnp.get_dpnp_descriptor(x1_double_container)
295+
x1_desc = dpnp_astype(x1_desc, dpnp.float64)
297296

298297
return dpnp_cov(x1_desc).get_pyobj()
299298

dpnp/linalg/dpnp_iface_linalg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import numpy
4545

4646
from dpnp.dpnp_utils import *
47+
from dpnp.dpnp_algo import *
4748
from dpnp.linalg.dpnp_algo_linalg import *
4849

4950

@@ -93,8 +94,7 @@ def cholesky(input):
9394
pass
9495
else:
9596
if input.dtype == dpnp.int32 or input.dtype == dpnp.int64:
96-
# TODO memory copy. needs to move into DPNPC
97-
input_ = dpnp.get_dpnp_descriptor(input.astype(dpnp.float64))
97+
input_ = dpnp_astype(x1_desc, dpnp.float64)
9898
else:
9999
input_ = x1_desc
100100
return dpnp_cholesky(input_).get_pyobj()

tests/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@
1111
# patch for shaped_arange func to exclude calls of astype and reshape
1212
# necessary because new data container does not support these functions yet
1313
from tests.third_party.cupy import testing as cupy_testing
14+
1415
orig_shaped_arange = cupy_testing.shaped_arange
16+
orig_shaped_reverse_arange = cupy_testing.shaped_reverse_arange
17+
1518
def _shaped_arange(shape, xp=dpnp, dtype=dpnp.float64, order='C'):
1619
res = xp.array(orig_shaped_arange(shape, xp=numpy, dtype=dtype, order=order), dtype=dtype)
1720
return res
21+
22+
def _shaped_reverse_arange(shape, xp=dpnp, dtype=dpnp.float32):
23+
res = xp.array(orig_shaped_reverse_arange(shape, xp=numpy, dtype=dtype), dtype=dtype)
24+
return res
25+
1826
cupy_testing.shaped_arange = _shaped_arange
27+
cupy_testing.shaped_reverse_arange = _shaped_reverse_arange

tests/skipped_tests.tbl

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,153 @@
11
tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpctl_memory
22
tests/test_arraymanipulation.py::TestHstack::test_generator
33
tests/test_arraymanipulation.py::TestVstack::test_generator
4+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float64-float64]
5+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float64-float32]
6+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float64-int64]
7+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float64-int32]
8+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float64-bool]
9+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float64-bool_]
10+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float64-complex]
11+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float32-float64]
12+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float32-float32]
13+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float32-int64]
14+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float32-int32]
15+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float32-bool]
16+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float32-bool_]
17+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-float32-complex]
18+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int64-float64]
19+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int64-float32]
20+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int64-int64]
21+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int64-int32]
22+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int64-bool]
23+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int64-bool_]
24+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int64-complex]
25+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int32-float64]
26+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int32-float32]
27+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int32-int64]
28+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int32-int32]
29+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int32-bool]
30+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int32-bool_]
31+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-int32-complex]
32+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool-float64]
33+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool-float32]
34+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool-int64]
35+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool-int32]
36+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool-bool]
37+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool-bool_]
38+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool-complex]
39+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool_-float64]
40+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool_-float32]
41+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool_-int64]
42+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool_-int32]
43+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool_-bool]
44+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool_-bool_]
45+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-bool_-complex]
46+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-float64]
47+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-float32]
48+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-int64]
49+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-int32]
50+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-bool]
51+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-bool_]
52+
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-complex]
53+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float64-float64]
54+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float64-float32]
55+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float64-int64]
56+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float64-int32]
57+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float64-bool]
58+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float64-bool_]
59+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float64-complex]
60+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float32-float64]
61+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float32-float32]
62+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float32-int64]
63+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float32-int32]
64+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float32-bool]
65+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float32-bool_]
66+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-float32-complex]
67+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int64-float64]
68+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int64-float32]
69+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int64-int64]
70+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int64-int32]
71+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int64-bool]
72+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int64-bool_]
73+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int64-complex]
74+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int32-float64]
75+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int32-float32]
76+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int32-int64]
77+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int32-int32]
78+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int32-bool]
79+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int32-bool_]
80+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-int32-complex]
81+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool-float64]
82+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool-float32]
83+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool-int64]
84+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool-int32]
85+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool-bool]
86+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool-bool_]
87+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool-complex]
88+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool_-float64]
89+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool_-float32]
90+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool_-int64]
91+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool_-int32]
92+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool_-bool]
93+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool_-bool_]
94+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-bool_-complex]
95+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-float64]
96+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-float32]
97+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-int64]
98+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-int32]
99+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-bool]
100+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-bool_]
101+
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-complex]
102+
tests/test_dparray.py::test_astype[[]-float64-float64]
103+
tests/test_dparray.py::test_astype[[]-float64-float32]
104+
tests/test_dparray.py::test_astype[[]-float64-int64]
105+
tests/test_dparray.py::test_astype[[]-float64-int32]
106+
tests/test_dparray.py::test_astype[[]-float64-bool]
107+
tests/test_dparray.py::test_astype[[]-float64-bool_]
108+
tests/test_dparray.py::test_astype[[]-float64-complex]
109+
tests/test_dparray.py::test_astype[[]-float32-float64]
110+
tests/test_dparray.py::test_astype[[]-float32-float32]
111+
tests/test_dparray.py::test_astype[[]-float32-int64]
112+
tests/test_dparray.py::test_astype[[]-float32-int32]
113+
tests/test_dparray.py::test_astype[[]-float32-bool]
114+
tests/test_dparray.py::test_astype[[]-float32-bool_]
115+
tests/test_dparray.py::test_astype[[]-float32-complex]
116+
tests/test_dparray.py::test_astype[[]-int64-float64]
117+
tests/test_dparray.py::test_astype[[]-int64-float32]
118+
tests/test_dparray.py::test_astype[[]-int64-int64]
119+
tests/test_dparray.py::test_astype[[]-int64-int32]
120+
tests/test_dparray.py::test_astype[[]-int64-bool]
121+
tests/test_dparray.py::test_astype[[]-int64-bool_]
122+
tests/test_dparray.py::test_astype[[]-int64-complex]
123+
tests/test_dparray.py::test_astype[[]-int32-float64]
124+
tests/test_dparray.py::test_astype[[]-int32-float32]
125+
tests/test_dparray.py::test_astype[[]-int32-int64]
126+
tests/test_dparray.py::test_astype[[]-int32-int32]
127+
tests/test_dparray.py::test_astype[[]-int32-bool]
128+
tests/test_dparray.py::test_astype[[]-int32-bool_]
129+
tests/test_dparray.py::test_astype[[]-int32-complex]
130+
tests/test_dparray.py::test_astype[[]-bool-float64]
131+
tests/test_dparray.py::test_astype[[]-bool-float32]
132+
tests/test_dparray.py::test_astype[[]-bool-int64]
133+
tests/test_dparray.py::test_astype[[]-bool-int32]
134+
tests/test_dparray.py::test_astype[[]-bool-bool]
135+
tests/test_dparray.py::test_astype[[]-bool-bool_]
136+
tests/test_dparray.py::test_astype[[]-bool-complex]
137+
tests/test_dparray.py::test_astype[[]-bool_-float64]
138+
tests/test_dparray.py::test_astype[[]-bool_-float32]
139+
tests/test_dparray.py::test_astype[[]-bool_-int64]
140+
tests/test_dparray.py::test_astype[[]-bool_-int32]
141+
tests/test_dparray.py::test_astype[[]-bool_-bool]
142+
tests/test_dparray.py::test_astype[[]-bool_-bool_]
143+
tests/test_dparray.py::test_astype[[]-bool_-complex]
144+
tests/test_dparray.py::test_astype[[]-complex-float64]
145+
tests/test_dparray.py::test_astype[[]-complex-float32]
146+
tests/test_dparray.py::test_astype[[]-complex-int64]
147+
tests/test_dparray.py::test_astype[[]-complex-int32]
148+
tests/test_dparray.py::test_astype[[]-complex-bool]
149+
tests/test_dparray.py::test_astype[[]-complex-bool_]
150+
tests/test_dparray.py::test_astype[[]-complex-complex]
4151
tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
5152
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
6153
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
@@ -44,6 +191,8 @@ tests/third_party/cupy/core_tests/test_ndarray_complex_ops.py::TestRealImag::tes
44191
tests/third_party/cupy/core_tests/test_ndarray_complex_ops.py::TestRealImag::test_real_setter_zero_dim
45192
tests/third_party/cupy/core_tests/test_ndarray_complex_ops.py::TestRealImag::test_real_zero_dim
46193
tests/third_party/cupy/core_tests/test_ndarray_complex_ops.py::TestScalarConversion::test_scalar_conversion
194+
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_astype
195+
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_astype_type
47196
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_astype_strides
48197
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_astype_strides_broadcast
49198
tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py::TestArrayCopyAndView::test_astype_strides_negative
@@ -229,10 +378,16 @@ tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_3_{copy
229378
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_3_{copy=False, indexing='ij', sparse=True}::test_meshgrid1
230379
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_3_{copy=False, indexing='ij', sparse=True}::test_meshgrid2
231380
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_3_{copy=False, indexing='ij', sparse=True}::test_meshgrid3
381+
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_4_{copy=True, indexing='xy', sparse=False}::test_meshgrid1
382+
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_4_{copy=True, indexing='xy', sparse=False}::test_meshgrid2
383+
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_4_{copy=True, indexing='xy', sparse=False}::test_meshgrid3
232384
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_5_{copy=True, indexing='xy', sparse=True}::test_meshgrid0
233385
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_5_{copy=True, indexing='xy', sparse=True}::test_meshgrid1
234386
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_5_{copy=True, indexing='xy', sparse=True}::test_meshgrid2
235387
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_5_{copy=True, indexing='xy', sparse=True}::test_meshgrid3
388+
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_6_{copy=True, indexing='ij', sparse=False}::test_meshgrid1
389+
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_6_{copy=True, indexing='ij', sparse=False}::test_meshgrid2
390+
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_6_{copy=True, indexing='ij', sparse=False}::test_meshgrid3
236391
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_7_{copy=True, indexing='ij', sparse=True}::test_meshgrid0
237392
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_7_{copy=True, indexing='ij', sparse=True}::test_meshgrid1
238393
tests/third_party/cupy/creation_tests/test_ranges.py::TestMeshgrid_param_7_{copy=True, indexing='ij', sparse=True}::test_meshgrid2

0 commit comments

Comments
 (0)