Skip to content

Commit 7dda3db

Browse files
committed
Add missing type aliases
1 parent f85a362 commit 7dda3db

11 files changed

+129
-73
lines changed

dpnp/dpnp_algo/dpnp_algo.pyx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ cpdef dpnp_queue_is_cpu():
233233
Internal functions
234234
"""
235235
cdef DPNPFuncType dpnp_dtype_to_DPNPFuncType(dtype):
236-
dt_c = numpy.dtype(dtype).char
237-
kind = numpy.dtype(dtype).kind
236+
dt_c = dpnp.dtype(dtype).char
237+
kind = dpnp.dtype(dtype).kind
238238
if isinstance(kind, int):
239239
kind = chr(kind)
240-
itemsize = numpy.dtype(dtype).itemsize
240+
itemsize = dpnp.dtype(dtype).itemsize
241241

242242
if dt_c == 'd':
243243
return DPNP_FT_DOUBLE
@@ -266,19 +266,19 @@ cdef dpnp_DPNPFuncType_to_dtype(size_t type):
266266
TODO needs to use DPNPFuncType here
267267
"""
268268
if type == <size_t > DPNP_FT_DOUBLE:
269-
return numpy.float64
269+
return dpnp.float64
270270
elif type == <size_t > DPNP_FT_FLOAT:
271-
return numpy.float32
271+
return dpnp.float32
272272
elif type == <size_t > DPNP_FT_LONG:
273-
return numpy.int64
273+
return dpnp.int64
274274
elif type == <size_t > DPNP_FT_INT:
275-
return numpy.int32
275+
return dpnp.int32
276276
elif type == <size_t > DPNP_FT_CMPLX64:
277-
return numpy.complex64
277+
return dpnp.complex64
278278
elif type == <size_t > DPNP_FT_CMPLX128:
279-
return numpy.complex128
279+
return dpnp.complex128
280280
elif type == <size_t > DPNP_FT_BOOL:
281-
return numpy.bool_
281+
return dpnp.bool
282282
else:
283283
utils.checker_throw_type_error("dpnp_DPNPFuncType_to_dtype", type)
284284

dpnp/dpnp_algo/dpnp_algo_statistics.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cython: language_level=3
22
# -*- coding: utf-8 -*-
33
# *****************************************************************************
4-
# Copyright (c) 2016-2020, Intel Corporation
4+
# Copyright (c) 2016-2023, Intel Corporation
55
# All rights reserved.
66
#
77
# Redistribution and use in source and binary forms, with or without
@@ -129,7 +129,7 @@ cpdef dpnp_average(utils.dpnp_descriptor x1):
129129
array_sum = dpnp_sum(x1).get_pyobj()
130130

131131
""" Numpy interface inconsistency """
132-
return_type = numpy.float32 if (x1.dtype == numpy.float32) else numpy.float64
132+
return_type = dpnp.float32 if (x1.dtype == dpnp.float32) else dpnp.float64
133133

134134
return (return_type(array_sum / x1.size))
135135

dpnp/dpnp_array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def conj(self):
527527
528528
"""
529529

530-
if not numpy.issubsctype(self.dtype, numpy.complex_):
530+
if not dpnp.issubsctype(self.dtype, dpnp.complex_):
531531
return self
532532
else:
533533
return dpnp.conjugate(self)
@@ -540,7 +540,7 @@ def conjugate(self):
540540
541541
"""
542542

543-
if not numpy.issubsctype(self.dtype, numpy.complex_):
543+
if not dpnp.issubsctype(self.dtype, dpnp.complex_):
544544
return self
545545
else:
546546
return dpnp.conjugate(self)

dpnp/dpnp_iface_linearalgebra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# distutils: language = c++
33
# -*- coding: utf-8 -*-
44
# *****************************************************************************
5-
# Copyright (c) 2016-2020, Intel Corporation
5+
# Copyright (c) 2016-2023, Intel Corporation
66
# All rights reserved.
77
#
88
# Redistribution and use in source and binary forms, with or without
@@ -269,7 +269,7 @@ def matmul(x1, x2, out=None, **kwargs):
269269
array2_size = x2_desc.size
270270
cost_size = 4096 # 2D array shape(64, 64)
271271

272-
if ((x1_desc.dtype == numpy.float64) or (x1_desc.dtype == numpy.float32)):
272+
if ((x1_desc.dtype == dpnp.float64) or (x1_desc.dtype == dpnp.float32)):
273273
"""
274274
Floating point types are handled via original math library better than SYCL math library
275275
"""

dpnp/dpnp_iface_manipulation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# distutils: language = c++
33
# -*- coding: utf-8 -*-
44
# *****************************************************************************
5-
# Copyright (c) 2016-2022, Intel Corporation
5+
# Copyright (c) 2016-2023, Intel Corporation
66
# All rights reserved.
77
#
88
# Redistribution and use in source and binary forms, with or without
@@ -73,7 +73,7 @@
7373
]
7474

7575

76-
def asfarray(x1, dtype=numpy.float64):
76+
def asfarray(x1, dtype=dpnp.float64):
7777
"""
7878
Return an array converted to a float type.
7979
@@ -88,8 +88,8 @@ def asfarray(x1, dtype=numpy.float64):
8888
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
8989
if x1_desc:
9090
# behavior of original function: int types replaced with float64
91-
if numpy.issubdtype(dtype, numpy.integer):
92-
dtype = numpy.float64
91+
if dpnp.issubdtype(dtype, dpnp.integer):
92+
dtype = dpnp.float64
9393

9494
# if type is the same then same object should be returned
9595
if x1_desc.dtype == dtype:

dpnp/dpnp_iface_types.py

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,73 @@
4040
__all__ = [
4141
"bool",
4242
"bool_",
43+
"cdouble",
44+
"complex_",
4345
"complex128",
4446
"complex64",
47+
"complexfloating",
48+
"cfloat",
49+
"csingle",
50+
"double",
4551
"dtype",
4652
"float",
53+
"float_",
4754
"float16",
4855
"float32",
4956
"float64",
57+
"floating",
58+
"inexact",
5059
"int",
60+
"int_",
5161
"int32",
5262
"int64",
5363
"integer",
64+
"intc",
5465
"isscalar",
66+
"issubdtype",
67+
"issubsctype",
5568
"is_type_supported",
5669
"longcomplex",
5770
"nan",
5871
"newaxis",
72+
"number",
73+
"object_",
74+
"signedinteger",
75+
"single",
76+
"singlecomplex",
5977
"void"
6078
]
6179

6280
bool = numpy.bool_
6381
bool_ = numpy.bool_
82+
cdouble = numpy.cdouble
83+
complex_ = numpy.complex_
6484
complex128 = numpy.complex128
6585
complex64 = numpy.complex64
86+
complexfloating = numpy.complexfloating
87+
cfloat = numpy.cfloat
88+
csingle = numpy.csingle
89+
double = numpy.double
6690
dtype = numpy.dtype
91+
float = numpy.float_
92+
float_ = numpy.float_
6793
float16 = numpy.float16
6894
float32 = numpy.float32
6995
float64 = numpy.float64
70-
float = numpy.float_
96+
floating = numpy.floating
97+
inexact = numpy.inexact
98+
int = numpy.int_
99+
int_ = numpy.int_
71100
int32 = numpy.int32
72101
int64 = numpy.int64
73102
integer = numpy.integer
74-
int = numpy.int_
103+
intc = numpy.intc
75104
longcomplex = numpy.longcomplex
105+
number = numpy.number
106+
object_ = numpy.object_
107+
signedinteger = numpy.signedinteger
108+
single = numpy.single
109+
singlecomplex = numpy.singlecomplex
76110

77111

78112
def isscalar(obj):
@@ -85,6 +119,28 @@ def isscalar(obj):
85119
return numpy.isscalar(obj)
86120

87121

122+
def issubdtype(arg1, arg2):
123+
"""
124+
Returns True if first argument is a typecode lower/equal in type hierarchy.
125+
126+
For full documentation refer to :obj:`numpy.issubdtype`.
127+
128+
"""
129+
130+
return numpy.issubdtype(arg1, arg2)
131+
132+
133+
def issubsctype(arg1, arg2):
134+
"""
135+
Determine if the first argument is a subclass of the second argument.
136+
137+
For full documentation refer to :obj:`numpy.issubsctype`.
138+
139+
"""
140+
141+
return numpy.issubsctype(arg1, arg2)
142+
143+
88144
nan = numpy.nan
89145
newaxis = None
90146
void = numpy.void

dpnp/dpnp_utils/dpnp_algo_utils.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,18 @@ def map_dtype_to_device(dtype, device):
268268
Map an input ``dtype`` with type ``device`` may use
269269
"""
270270

271-
dtype = numpy.dtype(dtype)
271+
dtype = dpnp.dtype(dtype)
272272
if not hasattr(dtype, 'char'):
273273
raise TypeError(f"Invalid type of input dtype={dtype}")
274274
elif not isinstance(device, dpctl.SyclDevice):
275275
raise TypeError(f"Invalid type of input device={device}")
276276

277277
dtc = dtype.char
278-
if dtc == "?" or numpy.issubdtype(dtype, numpy.integer):
278+
if dtc == "?" or dpnp.issubdtype(dtype, dpnp.integer):
279279
# bool or integer type
280280
return dtype
281281

282-
if numpy.issubdtype(dtype, numpy.floating):
282+
if dpnp.issubdtype(dtype, dpnp.floating):
283283
if dtc == "f":
284284
# float32 type
285285
return dtype
@@ -294,7 +294,7 @@ def map_dtype_to_device(dtype, device):
294294
# float32 is default floating type
295295
return dpnp.dtype("f4")
296296

297-
if numpy.issubdtype(dtype, numpy.complexfloating):
297+
if dpnp.issubdtype(dtype, dpnp.complexfloating):
298298
if dtc == "F":
299299
# complex64 type
300300
return dtype
@@ -418,14 +418,14 @@ cdef tuple get_shape_dtype(object input_obj):
418418

419419
# shape and dtype does not match with siblings.
420420
if ((return_shape != elem_shape) or (return_dtype != elem_dtype)):
421-
return (elem_shape, numpy.dtype(numpy.object_))
421+
return (elem_shape, dpnp.dtype(dpnp.object_))
422422

423423
list_shape.push_back(len(input_obj))
424424
list_shape.insert(list_shape.end(), return_shape.begin(), return_shape.end())
425425
return (list_shape, return_dtype)
426426

427427
# assume scalar or object
428-
return (return_shape, numpy.dtype(type(input_obj)))
428+
return (return_shape, dpnp.dtype(type(input_obj)))
429429

430430

431431
cpdef find_common_type(object x1_obj, object x2_obj):

dpnp/linalg/dpnp_algo_linalg.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cython: language_level=3
22
# -*- coding: utf-8 -*-
33
# *****************************************************************************
4-
# Copyright (c) 2016-2022, Intel Corporation
4+
# Copyright (c) 2016-2023, Intel Corporation
55
# All rights reserved.
66
#
77
# Redistribution and use in source and binary forms, with or without
@@ -342,13 +342,13 @@ cpdef object dpnp_norm(object input, ord=None, axis=None):
342342
cdef long size_input = input.size
343343
cdef shape_type_c shape_input = input.shape
344344

345-
if input.dtype == numpy.float32:
346-
res_type = numpy.float32
345+
if input.dtype == dpnp.float32:
346+
res_type = dpnp.float32
347347
else:
348-
res_type = numpy.float64
348+
res_type = dpnp.float64
349349

350350
if size_input == 0:
351-
return dpnp.array([numpy.nan], dtype=res_type)
351+
return dpnp.array([dpnp.nan], dtype=res_type)
352352

353353
if isinstance(axis, int):
354354
axis_ = tuple([axis])

0 commit comments

Comments
 (0)