Skip to content

Commit

Permalink
Add support of NumPy 1.24 (IntelPython#1276)
Browse files Browse the repository at this point in the history
* Set minimum required versions & fix debug building

* Add support of numpy 1.24
  • Loading branch information
antonwolfy authored Jan 23, 2023
1 parent 12e7bd5 commit 9209351
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 102 deletions.
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ requirements:
host:
- python
- setuptools
- numpy >=1.19,<1.23a0
- numpy >=1.19,<1.25a0
- cython
- cmake >=3.19
- dpctl >=0.13
Expand Down
4 changes: 2 additions & 2 deletions dpnp/backend/include/dpnp_iface_fptr.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//*****************************************************************************
// Copyright (c) 2016-2022, 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 @@ -391,7 +391,7 @@ enum class DPNPFuncType : size_t
DPNP_FT_DOUBLE, /**< analog of numpy.float32 or double */
DPNP_FT_CMPLX64, /**< analog of numpy.complex64 or std::complex<float> */
DPNP_FT_CMPLX128, /**< analog of numpy.complex128 or std::complex<double> */
DPNP_FT_BOOL /**< analog of numpy.bool or numpy.bool_ or bool */
DPNP_FT_BOOL /**< analog of numpy.bool_ or bool */
};

/**
Expand Down
10 changes: 5 additions & 5 deletions dpnp/dparray.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-2022, 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 @@ -462,7 +462,7 @@ cdef class dparray:
return ( < long * > self._dparray_data)[lin_idx]
elif self.dtype == numpy.int32:
return ( < int * > self._dparray_data)[lin_idx]
elif self.dtype == numpy.bool:
elif self.dtype == numpy.bool_:
return ( < cpp_bool * > self._dparray_data)[lin_idx]
elif self.dtype == numpy.complex128:
return ( < double complex * > self._dparray_data)[lin_idx]
Expand All @@ -489,7 +489,7 @@ cdef class dparray:
( < long * > self._dparray_data)[lin_idx] = <long > value
elif self.dtype == numpy.int32:
( < int * > self._dparray_data)[lin_idx] = <int > value
elif self.dtype == numpy.bool:
elif self.dtype == numpy.bool_:
( < cpp_bool * > self._dparray_data)[lin_idx] = < cpp_bool > value
elif self.dtype == numpy.complex64:
( < float complex * > self._dparray_data)[lin_idx] = <float complex > value
Expand Down Expand Up @@ -876,7 +876,7 @@ cdef class dparray:

"""
if not numpy.issubsctype(self.dtype, numpy.complex):
if not numpy.issubsctype(self.dtype, numpy.complex_):
return self
else:
return conjugate(self)
Expand All @@ -889,7 +889,7 @@ cdef class dparray:

"""
if not numpy.issubsctype(self.dtype, numpy.complex):
if not numpy.issubsctype(self.dtype, numpy.complex_):
return self
else:
return conjugate(self)
Expand Down
2 changes: 1 addition & 1 deletion dpnp/dpnp_algo/dpnp_algo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ cdef dpnp_DPNPFuncType_to_dtype(size_t type):
elif type == <size_t > DPNP_FT_CMPLX128:
return numpy.complex128
elif type == <size_t > DPNP_FT_BOOL:
return numpy.bool
return numpy.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_arraycreation.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-2022, 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 @@ -434,7 +434,7 @@ cpdef utils.dpnp_descriptor dpnp_trace(utils.dpnp_descriptor arr, offset=0, axis
return result


cpdef utils.dpnp_descriptor dpnp_tri(N, M=None, k=0, dtype=numpy.float):
cpdef utils.dpnp_descriptor dpnp_tri(N, M=None, k=0, dtype=dpnp.float):
if M is None:
M = N

Expand Down
6 changes: 3 additions & 3 deletions dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# *****************************************************************************
# Copyright (c) 2016-2022, 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 @@ -493,7 +493,7 @@ def conj(self):
"""

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

if not numpy.issubsctype(self.dtype, numpy.complex):
if not numpy.issubsctype(self.dtype, numpy.complex_):
return self
else:
return dpnp.conjugate(self)
Expand Down
6 changes: 3 additions & 3 deletions dpnp/dpnp_iface_arraycreation.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-2022, 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 @@ -1280,7 +1280,7 @@ def trace(x1, offset=0, axis1=0, axis2=1, dtype=None, out=None):
return call_origin(numpy.trace, x1, offset, axis1, axis2, dtype, out)


def tri(N, M=None, k=0, dtype=numpy.float, **kwargs):
def tri(N, M=None, k=0, dtype=dpnp.float, **kwargs):
"""
An array with ones at and below the given diagonal and zeros elsewhere.
Expand Down Expand Up @@ -1315,7 +1315,7 @@ def tri(N, M=None, k=0, dtype=numpy.float, **kwargs):
elif not isinstance(k, int):
pass
else:
if dtype is numpy.float:
if dtype is dpnp.float:
sycl_queue = dpnp.get_normalized_queue_device(sycl_queue=None, device=None)
dtype = map_dtype_to_device(dpnp.float64, sycl_queue.sycl_device)
return dpnp_tri(N, M, k, dtype).get_pyobj()
Expand Down
6 changes: 3 additions & 3 deletions dpnp/dpnp_iface_mathematical.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-2022, 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 @@ -1545,11 +1545,11 @@ def subtract(x1, x2, dtype=None, out=None, where=True, **kwargs):
pass
elif x1_desc and x1_desc.ndim == 0:
pass
elif x1_desc and x1_desc.dtype == numpy.bool:
elif x1_desc and x1_desc.dtype == dpnp.bool:
pass
elif x2_desc and x2_desc.ndim == 0:
pass
elif x2_desc and x2_desc.dtype == numpy.bool:
elif x2_desc and x2_desc.dtype == dpnp.bool:
pass
elif dtype is not None:
pass
Expand Down
6 changes: 3 additions & 3 deletions dpnp/dpnp_iface_statistics.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 @@ -299,7 +299,7 @@ def cov(x1, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=
return call_origin(numpy.cov, x1, y, rowvar, bias, ddof, fweights, aweights)


def histogram(a, bins=10, range=None, normed=None, weights=None, density=None):
def histogram(a, bins=10, range=None, density=None, weights=None):
"""
Compute the histogram of a dataset.
For full documentation refer to :obj:`numpy.histogram`.
Expand All @@ -323,7 +323,7 @@ def histogram(a, bins=10, range=None, normed=None, weights=None, density=None):
1.0
"""

return call_origin(numpy.histogram, a=a, bins=bins, range=range, normed=normed, weights=weights, density=density)
return call_origin(numpy.histogram, a=a, bins=bins, range=range, density=density, weights=weights)


def max(x1, axis=None, out=None, keepdims=False, initial=None, where=True):
Expand Down
8 changes: 4 additions & 4 deletions dpnp/dpnp_iface_types.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 @@ -59,19 +59,19 @@
"void"
]

bool = numpy.bool
bool = numpy.bool_
bool_ = numpy.bool_
complex128 = numpy.complex128
complex64 = numpy.complex64
dtype = numpy.dtype
float16 = numpy.float16
float32 = numpy.float32
float64 = numpy.float64
float = numpy.float
float = numpy.float_
int32 = numpy.int32
int64 = numpy.int64
integer = numpy.integer
int = numpy.int
int = numpy.int_
longcomplex = numpy.longcomplex


Expand Down
4 changes: 2 additions & 2 deletions dpnp/dpnp_utils/dpnp_algo_utils.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-2022, 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 @@ -399,7 +399,7 @@ cdef tuple get_shape_dtype(object input_obj):

# shape and dtype does not match with siblings.
if ((return_shape != elem_shape) or (return_dtype != elem_dtype)):
return (elem_shape, numpy.dtype(numpy.object))
return (elem_shape, numpy.dtype(numpy.object_))

list_shape.push_back(len(input_obj))
list_shape.insert(list_shape.end(), return_shape.begin(), return_shape.end())
Expand Down
8 changes: 4 additions & 4 deletions examples/example4.py
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 @@ -40,7 +40,7 @@
"""
for function in [numpy.sqrt, numpy.fabs, numpy.reciprocal, numpy.square, numpy.cbrt, numpy.degrees, numpy.radians]:
print()
for test_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool]:
for test_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_]:
data = numpy.array([1, 2, 3, 4], dtype=test_type)
result = function(data)
print(f"input:{data.dtype.name:10}: outout:{result.dtype.name:10}: name:{function.__name__}")
Expand All @@ -50,8 +50,8 @@
"""
for function in [numpy.equal, numpy.arctan2]:
print()
for input1_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool]:
for input2_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool]:
for input1_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_]:
for input2_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_]:
data1 = numpy.array([1, 2, 3, 4], dtype=input1_type)
data2 = numpy.array([11, 21, 31, 41], dtype=input2_type)
result = function(data1, data2)
Expand Down
14 changes: 1 addition & 13 deletions tests/skipped_tests.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -35,54 +35,42 @@ tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpct

tests/test_arraymanipulation.py::TestHstack::test_generator
tests/test_arraymanipulation.py::TestVstack::test_generator

tests/test_dparray.py::test_astype[[]-float64-float64]
tests/test_dparray.py::test_astype[[]-float64-float32]
tests/test_dparray.py::test_astype[[]-float64-int64]
tests/test_dparray.py::test_astype[[]-float64-int32]
tests/test_dparray.py::test_astype[[]-float64-bool]
tests/test_dparray.py::test_astype[[]-float64-bool_]
tests/test_dparray.py::test_astype[[]-float64-complex]
tests/test_dparray.py::test_astype[[]-float32-float64]
tests/test_dparray.py::test_astype[[]-float32-float32]
tests/test_dparray.py::test_astype[[]-float32-int64]
tests/test_dparray.py::test_astype[[]-float32-int32]
tests/test_dparray.py::test_astype[[]-float32-bool]
tests/test_dparray.py::test_astype[[]-float32-bool_]
tests/test_dparray.py::test_astype[[]-float32-complex]
tests/test_dparray.py::test_astype[[]-int64-float64]
tests/test_dparray.py::test_astype[[]-int64-float32]
tests/test_dparray.py::test_astype[[]-int64-int64]
tests/test_dparray.py::test_astype[[]-int64-int32]
tests/test_dparray.py::test_astype[[]-int64-bool]
tests/test_dparray.py::test_astype[[]-int64-bool_]
tests/test_dparray.py::test_astype[[]-int64-complex]
tests/test_dparray.py::test_astype[[]-int32-float64]
tests/test_dparray.py::test_astype[[]-int32-float32]
tests/test_dparray.py::test_astype[[]-int32-int64]
tests/test_dparray.py::test_astype[[]-int32-int32]
tests/test_dparray.py::test_astype[[]-int32-bool]
tests/test_dparray.py::test_astype[[]-int32-bool_]
tests/test_dparray.py::test_astype[[]-int32-complex]
tests/test_dparray.py::test_astype[[]-bool-float64]
tests/test_dparray.py::test_astype[[]-bool-float32]
tests/test_dparray.py::test_astype[[]-bool-int64]
tests/test_dparray.py::test_astype[[]-bool-int32]
tests/test_dparray.py::test_astype[[]-bool-bool]
tests/test_dparray.py::test_astype[[]-bool-bool_]
tests/test_dparray.py::test_astype[[]-bool-complex]
tests/test_dparray.py::test_astype[[]-bool_-float64]
tests/test_dparray.py::test_astype[[]-bool_-float32]
tests/test_dparray.py::test_astype[[]-bool_-int64]
tests/test_dparray.py::test_astype[[]-bool_-int32]
tests/test_dparray.py::test_astype[[]-bool_-bool]
tests/test_dparray.py::test_astype[[]-bool_-bool_]
tests/test_dparray.py::test_astype[[]-bool_-complex]
tests/test_dparray.py::test_astype[[]-complex-float64]
tests/test_dparray.py::test_astype[[]-complex-float32]
tests/test_dparray.py::test_astype[[]-complex-int64]
tests/test_dparray.py::test_astype[[]-complex-int32]
tests/test_dparray.py::test_astype[[]-complex-bool]
tests/test_dparray.py::test_astype[[]-complex-bool_]
tests/test_dparray.py::test_astype[[]-complex-complex]

tests/test_linalg.py::test_cond[None-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
Expand Down
14 changes: 1 addition & 13 deletions tests/skipped_tests_gpu.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -301,54 +301,42 @@ tests/third_party/cupy/sorting_tests/test_sort.py::TestPartition_param_3_{extern
tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpctl_memory
tests/test_arraymanipulation.py::TestHstack::test_generator
tests/test_arraymanipulation.py::TestVstack::test_generator

tests/test_dparray.py::test_astype[[]-float64-float64]
tests/test_dparray.py::test_astype[[]-float64-float32]
tests/test_dparray.py::test_astype[[]-float64-int64]
tests/test_dparray.py::test_astype[[]-float64-int32]
tests/test_dparray.py::test_astype[[]-float64-bool]
tests/test_dparray.py::test_astype[[]-float64-bool_]
tests/test_dparray.py::test_astype[[]-float64-complex]
tests/test_dparray.py::test_astype[[]-float32-float64]
tests/test_dparray.py::test_astype[[]-float32-float32]
tests/test_dparray.py::test_astype[[]-float32-int64]
tests/test_dparray.py::test_astype[[]-float32-int32]
tests/test_dparray.py::test_astype[[]-float32-bool]
tests/test_dparray.py::test_astype[[]-float32-bool_]
tests/test_dparray.py::test_astype[[]-float32-complex]
tests/test_dparray.py::test_astype[[]-int64-float64]
tests/test_dparray.py::test_astype[[]-int64-float32]
tests/test_dparray.py::test_astype[[]-int64-int64]
tests/test_dparray.py::test_astype[[]-int64-int32]
tests/test_dparray.py::test_astype[[]-int64-bool]
tests/test_dparray.py::test_astype[[]-int64-bool_]
tests/test_dparray.py::test_astype[[]-int64-complex]
tests/test_dparray.py::test_astype[[]-int32-float64]
tests/test_dparray.py::test_astype[[]-int32-float32]
tests/test_dparray.py::test_astype[[]-int32-int64]
tests/test_dparray.py::test_astype[[]-int32-int32]
tests/test_dparray.py::test_astype[[]-int32-bool]
tests/test_dparray.py::test_astype[[]-int32-bool_]
tests/test_dparray.py::test_astype[[]-int32-complex]
tests/test_dparray.py::test_astype[[]-bool-float64]
tests/test_dparray.py::test_astype[[]-bool-float32]
tests/test_dparray.py::test_astype[[]-bool-int64]
tests/test_dparray.py::test_astype[[]-bool-int32]
tests/test_dparray.py::test_astype[[]-bool-bool]
tests/test_dparray.py::test_astype[[]-bool-bool_]
tests/test_dparray.py::test_astype[[]-bool-complex]
tests/test_dparray.py::test_astype[[]-bool_-float64]
tests/test_dparray.py::test_astype[[]-bool_-float32]
tests/test_dparray.py::test_astype[[]-bool_-int64]
tests/test_dparray.py::test_astype[[]-bool_-int32]
tests/test_dparray.py::test_astype[[]-bool_-bool]
tests/test_dparray.py::test_astype[[]-bool_-bool_]
tests/test_dparray.py::test_astype[[]-bool_-complex]
tests/test_dparray.py::test_astype[[]-complex-float64]
tests/test_dparray.py::test_astype[[]-complex-float32]
tests/test_dparray.py::test_astype[[]-complex-int64]
tests/test_dparray.py::test_astype[[]-complex-int32]
tests/test_dparray.py::test_astype[[]-complex-bool]
tests/test_dparray.py::test_astype[[]-complex-bool_]
tests/test_dparray.py::test_astype[[]-complex-complex]

tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
Expand Down
Loading

0 comments on commit 9209351

Please sign in to comment.