Skip to content

Add missing dtype aliases #1309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions dpnp/dpnp_algo/dpnp_algo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ cpdef dpnp_queue_is_cpu():
Internal functions
"""
cdef DPNPFuncType dpnp_dtype_to_DPNPFuncType(dtype):
dt_c = numpy.dtype(dtype).char
kind = numpy.dtype(dtype).kind
dt_c = dpnp.dtype(dtype).char
kind = dpnp.dtype(dtype).kind
if isinstance(kind, int):
kind = chr(kind)
itemsize = numpy.dtype(dtype).itemsize
itemsize = dpnp.dtype(dtype).itemsize

if dt_c == 'd':
return DPNP_FT_DOUBLE
Expand Down Expand Up @@ -266,19 +266,19 @@ cdef dpnp_DPNPFuncType_to_dtype(size_t type):
TODO needs to use DPNPFuncType here
"""
if type == <size_t > DPNP_FT_DOUBLE:
return numpy.float64
return dpnp.float64
elif type == <size_t > DPNP_FT_FLOAT:
return numpy.float32
return dpnp.float32
elif type == <size_t > DPNP_FT_LONG:
return numpy.int64
return dpnp.int64
elif type == <size_t > DPNP_FT_INT:
return numpy.int32
return dpnp.int32
elif type == <size_t > DPNP_FT_CMPLX64:
return numpy.complex64
return dpnp.complex64
elif type == <size_t > DPNP_FT_CMPLX128:
return numpy.complex128
return dpnp.complex128
elif type == <size_t > DPNP_FT_BOOL:
return numpy.bool_
return dpnp.bool
else:
utils.checker_throw_type_error("dpnp_DPNPFuncType_to_dtype", type)

Expand Down
4 changes: 2 additions & 2 deletions dpnp/dpnp_algo/dpnp_algo_statistics.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# cython: language_level=3
# -*- coding: utf-8 -*-
# *****************************************************************************
# Copyright (c) 2016-2020, Intel Corporation
# Copyright (c) 2016-2023, Intel Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -129,7 +129,7 @@ cpdef dpnp_average(utils.dpnp_descriptor x1):
array_sum = dpnp_sum(x1).get_pyobj()

""" Numpy interface inconsistency """
return_type = numpy.float32 if (x1.dtype == numpy.float32) else numpy.float64
return_type = dpnp.float32 if (x1.dtype == dpnp.float32) else dpnp.float64

return (return_type(array_sum / x1.size))

Expand Down
4 changes: 2 additions & 2 deletions dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def conj(self):

"""

if not numpy.issubsctype(self.dtype, numpy.complex_):
if not dpnp.issubsctype(self.dtype, dpnp.complex_):
return self
else:
return dpnp.conjugate(self)
Expand All @@ -550,7 +550,7 @@ def conjugate(self):

"""

if not numpy.issubsctype(self.dtype, numpy.complex_):
if not dpnp.issubsctype(self.dtype, dpnp.complex_):
return self
else:
return dpnp.conjugate(self)
Expand Down
4 changes: 2 additions & 2 deletions dpnp/dpnp_iface_linearalgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# distutils: language = c++
# -*- coding: utf-8 -*-
# *****************************************************************************
# Copyright (c) 2016-2020, Intel Corporation
# Copyright (c) 2016-2023, Intel Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -269,7 +269,7 @@ def matmul(x1, x2, out=None, **kwargs):
array2_size = x2_desc.size
cost_size = 4096 # 2D array shape(64, 64)

if ((x1_desc.dtype == numpy.float64) or (x1_desc.dtype == numpy.float32)):
if ((x1_desc.dtype == dpnp.float64) or (x1_desc.dtype == dpnp.float32)):
"""
Floating point types are handled via original math library better than SYCL math library
"""
Expand Down
9 changes: 3 additions & 6 deletions dpnp/dpnp_iface_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,8 @@ def isfinite(x1, out=None, **kwargs):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([-numpy.inf, 0., numpy.inf])
>>> x = np.array([-np.inf, 0., np.inf])
>>> out = np.isfinite(x)
>>> [i for i in out]
[False, True, False]
Expand Down Expand Up @@ -556,9 +555,8 @@ def isinf(x1, out=None, **kwargs):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([-numpy.inf, 0., numpy.inf])
>>> x = np.array([-np.inf, 0., np.inf])
>>> out = np.isinf(x)
>>> [i for i in out]
[True, False, True]
Expand Down Expand Up @@ -602,9 +600,8 @@ def isnan(x1, out=None, **kwargs):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([numpy.inf, 0., np.nan])
>>> x = np.array([np.inf, 0., np.nan])
>>> out = np.isnan(x)
>>> [i for i in out]
[False, False, True]
Expand Down
2 changes: 1 addition & 1 deletion dpnp/dpnp_iface_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def asfarray(x1, dtype=None):

x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
if x1_desc:
if dtype is None or not numpy.issubdtype(dtype, numpy.inexact):
if dtype is None or not numpy.issubdtype(dtype, dpnp.inexact):
dtype = dpnp.default_float_type(sycl_queue=x1.sycl_queue)

# if type is the same then same object should be returned
Expand Down
34 changes: 12 additions & 22 deletions dpnp/dpnp_iface_trigonometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# distutils: language = c++
# -*- coding: utf-8 -*-
# *****************************************************************************
# Copyright (c) 2016-2020, Intel Corporation
# Copyright (c) 2016-2023, Intel Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -136,9 +136,8 @@ def arccosh(x1):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([numpy.e, 10.0])
>>> x = np.array([np.e, 10.0])
>>> out = np.arccosh(x)
>>> [i for i in out]
[1.65745445, 2.99322285]
Expand Down Expand Up @@ -205,9 +204,8 @@ def arcsinh(x1):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([numpy.e, 10.0])
>>> x = np.array([np.e, 10.0])
>>> out = np.arcsinh(x)
>>> [i for i in out]
[1.72538256, 2.99822295]
Expand Down Expand Up @@ -384,9 +382,8 @@ def cos(x1, out=None, **kwargs):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([0, numpy.pi/2, numpy.pi])
>>> x = np.array([0, np.pi/2, np.pi])
>>> out = np.cos(x)
>>> [i for i in out]
[1.0, 6.123233995736766e-17, -1.0]
Expand Down Expand Up @@ -464,9 +461,8 @@ def degrees(x1):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> rad = np.arange(6.) * numpy.pi/6
>>> rad = np.arange(6.) * np.pi/6
>>> out = np.degrees(rad)
>>> [i for i in out]
[0.0, 30.0, 60.0, 90.0, 120.0, 150.0]
Expand Down Expand Up @@ -652,9 +648,8 @@ def log(x1, out=None, **kwargs):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([1.0, numpy.e, numpy.e**2, 0.0])
>>> x = np.array([1.0, np.e, np.e**2, 0.0])
>>> out = np.log(x)
>>> [i for i in out]
[0.0, 1.0, 2.0, -inf]
Expand Down Expand Up @@ -867,9 +862,8 @@ def sin(x1, out=None, **kwargs):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([0, numpy.pi/2, numpy.pi])
>>> x = np.array([0, np.pi/2, np.pi])
>>> out = np.sin(x)
>>> [i for i in out]
[0.0, 1.0, 1.2246467991473532e-16]
Expand Down Expand Up @@ -897,9 +891,8 @@ def sinh(x1):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([0, numpy.pi/2, numpy.pi])
>>> x = np.array([0, np.pi/2, np.pi])
>>> out = np.sinh(x)
>>> [i for i in out]
[0.0, 2.3012989, 11.548739]
Expand Down Expand Up @@ -991,9 +984,8 @@ def tan(x1, out=None, **kwargs):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([-numpy.pi, numpy.pi/2, numpy.pi])
>>> x = np.array([-np.pi, np.pi/2, np.pi])
>>> out = np.tan(x)
>>> [i for i in out]
[1.22460635e-16, 1.63317787e+16, -1.22460635e-16]
Expand Down Expand Up @@ -1021,9 +1013,8 @@ def tanh(x1):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> x = np.array([-numpy.pi, numpy.pi/2, numpy.pi])
>>> x = np.array([-np.pi, np.pi/2, np.pi])
>>> out = np.tanh(x)
>>> [i for i in out]
[-0.996272, 0.917152, 0.996272]
Expand Down Expand Up @@ -1055,11 +1046,10 @@ def unwrap(x1):

Examples
--------
>>> import numpy
>>> import dpnp as np
>>> phase = np.linspace(0, numpy.pi, num=5)
>>> phase = np.linspace(0, np.pi, num=5)
>>> for i in range(3, 5):
>>> phase[i] += numpy.pi
>>> phase[i] += np.pi
>>> out = np.unwrap(phase)
>>> [i for i in out]
[0.0, 0.78539816, 1.57079633, 5.49778714, 6.28318531]
Expand Down
Loading