Skip to content

Commit a0a91bd

Browse files
committed
Merge branch 'div_by_scalar' of https://github.com/antonwolfy/dpnp into div_by_scalar
2 parents 1c6517a + b0e4366 commit a0a91bd

File tree

4 files changed

+136
-4
lines changed

4 files changed

+136
-4
lines changed

dpnp/dpnp_array.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ def __radd__(self, other):
253253
# '__rdivmod__',
254254
# '__reduce__',
255255
# '__reduce_ex__',
256-
# '__repr__',
256+
257+
def __repr__(self):
258+
return dpt.usm_ndarray_repr(self._array_obj, prefix="array")
259+
257260
# '__rfloordiv__',
258261
# '__rlshift__',
259262

@@ -300,8 +303,7 @@ def __str__(self):
300303
301304
"""
302305

303-
return str(self.asnumpy())
304-
306+
return self._array_obj.__str__()
305307

306308
def __sub__(self, other):
307309
return dpnp.subtract(self, other)

tests/skipped_tests_gpu.tbl

+25
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ tests/third_party/cupy/indexing_tests/test_insert.py::TestDiagIndicesFrom_param_
8989
tests/third_party/cupy/indexing_tests/test_insert.py::TestDiagIndicesFrom_param_1_{shape=(0, 0)}::test_diag_indices_from
9090
tests/third_party/cupy/indexing_tests/test_insert.py::TestDiagIndicesFrom_param_2_{shape=(2, 2, 2)}::test_diag_indices_from
9191

92+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_295_{arg1=array([[1., 2., 3.], [4., 5., 6.]], dtype=float32), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
93+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_303_{arg1=array([[1., 2., 3.], [4., 5., 6.]], dtype=float32), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int64), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
94+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_375_{arg1=array([[1., 2., 3.], [4., 5., 6.]]), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
95+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_383_{arg1=array([[1., 2., 3.], [4., 5., 6.]]), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int64), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
96+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_439_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0., 1., 2.], [3., 4., 5.]], dtype=float32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
97+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_447_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0., 1., 2.], [3., 4., 5.]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
98+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_455_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
99+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_463_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int64), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
100+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_519_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int64), arg2=array([[0., 1., 2.], [3., 4., 5.]], dtype=float32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
101+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_527_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int64), arg2=array([[0., 1., 2.], [3., 4., 5.]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
102+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_535_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int64), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
103+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_543_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int64), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int64), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
104+
92105
tests/third_party/cupy/math_tests/test_sumprod.py::TestSumprod::test_external_prod_all
93106
tests/third_party/cupy/math_tests/test_sumprod.py::TestSumprod::test_external_prod_axis
94107
tests/third_party/cupy/math_tests/test_sumprod.py::TestSumprod::test_external_sum_all
@@ -955,10 +968,22 @@ tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_5_{reps
955968
tests/third_party/cupy/manipulation_tests/test_transpose.py::TestTranspose::test_moveaxis_invalid5_2
956969
tests/third_party/cupy/manipulation_tests/test_transpose.py::TestTranspose::test_moveaxis_invalid5_3
957970

971+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_279_{arg1=array([[1., 2., 3.], [4., 5., 6.]], dtype=float32), arg2=array([[0., 1., 2.], [3., 4., 5.]], dtype=float32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
972+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_287_{arg1=array([[1., 2., 3.], [4., 5., 6.]], dtype=float32), arg2=array([[0., 1., 2.], [3., 4., 5.]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
973+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_295_{arg1=array([[1., 2., 3.], [4., 5., 6.]], dtype=float32), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
974+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_303_{arg1=array([[1., 2., 3.], [4., 5., 6.]], dtype=float32), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
975+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_359_{arg1=array([[1., 2., 3.], [4., 5., 6.]]), arg2=array([[0., 1., 2.], [3., 4., 5.]], dtype=float32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
976+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_367_{arg1=array([[1., 2., 3.], [4., 5., 6.]]), arg2=array([[0., 1., 2.], [3., 4., 5.]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
977+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_375_{arg1=array([[1., 2., 3.], [4., 5., 6.]]), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
978+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_383_{arg1=array([[1., 2., 3.], [4., 5., 6.]]), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
979+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_439_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0., 1., 2.], [3., 4., 5.]], dtype=float32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
980+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_447_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0., 1., 2.], [3., 4., 5.]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
958981
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_455_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
959982
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_463_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
960983
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_535_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
961984
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_543_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
985+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_519_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0., 1., 2.], [3., 4., 5.]], dtype=float32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
986+
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_527_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0., 1., 2.], [3., 4., 5.]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
962987

963988
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticRaisesWithNumpyInput_param_10_{name='remainder', nargs=2}::test_raises_with_numpy_input
964989
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticRaisesWithNumpyInput_param_11_{name='mod', nargs=2}::test_raises_with_numpy_input

tests/test_dparray.py

+105
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,111 @@ def test_flags_strides(dtype, order, strides):
6969
assert numpy_array.flags.c_contiguous == dpnp_array.flags.c_contiguous
7070
assert numpy_array.flags.f_contiguous == dpnp_array.flags.f_contiguous
7171

72+
def test_print_dpnp_int():
73+
result = repr(dpnp.array([1, 0, 2, -3, -1, 2, 21, -9], dtype='i4'))
74+
expected = "array([ 1, 0, 2, -3, -1, 2, 21, -9], dtype=int32)"
75+
assert(result==expected)
76+
77+
result = str(dpnp.array([1, 0, 2, -3, -1, 2, 21, -9], dtype='i4'))
78+
expected = "[ 1 0 2 -3 -1 2 21 -9]"
79+
assert(result==expected)
80+
# int32
81+
result = repr(dpnp.array([1, -1, 21], dtype=dpnp.int32))
82+
expected = "array([ 1, -1, 21], dtype=int32)"
83+
assert(result==expected)
84+
85+
result = str(dpnp.array([1, -1, 21], dtype=dpnp.int32))
86+
expected = "[ 1 -1 21]"
87+
assert(result==expected)
88+
# uint8
89+
result = repr(dpnp.array([1, 0, 3], dtype=numpy.uint8))
90+
expected = "array([1, 0, 3], dtype=uint8)"
91+
assert(result==expected)
92+
93+
result = str(dpnp.array([1, 0, 3], dtype=numpy.uint8))
94+
expected = "[1 0 3]"
95+
assert(result==expected)
96+
97+
def test_print_dpnp_float():
98+
result = repr(dpnp.array([1, -1, 21], dtype=float))
99+
expected = "array([ 1., -1., 21.])"
100+
assert(result==expected)
101+
102+
result = str(dpnp.array([1, -1, 21], dtype=float))
103+
expected = "[ 1. -1. 21.]"
104+
assert(result==expected)
105+
# float32
106+
result = repr(dpnp.array([1, -1, 21], dtype=dpnp.float32))
107+
expected = "array([ 1., -1., 21.], dtype=float32)"
108+
assert(result==expected)
109+
110+
result = str(dpnp.array([1, -1, 21], dtype=dpnp.float32))
111+
expected = "[ 1. -1. 21.]"
112+
assert(result==expected)
113+
114+
def test_print_dpnp_complex():
115+
result = repr(dpnp.array([1, -1, 21], dtype=complex))
116+
expected = "array([ 1.+0.j, -1.+0.j, 21.+0.j])"
117+
assert(result==expected)
118+
119+
result = str(dpnp.array([1, -1, 21], dtype=complex))
120+
expected = "[ 1.+0.j -1.+0.j 21.+0.j]"
121+
assert(result==expected)
122+
123+
def test_print_dpnp_boolean():
124+
result = repr(dpnp.array([1, 0, 3], dtype=bool))
125+
expected = "array([ True, False, True])"
126+
assert(result==expected)
127+
128+
result = str(dpnp.array([1, 0, 3], dtype=bool))
129+
expected = "[ True False True]"
130+
assert(result==expected)
131+
132+
def test_print_dpnp_special_character():
133+
# NaN
134+
result = repr(dpnp.array([1., 0., dpnp.nan, 3.]))
135+
expected = "array([ 1., 0., nan, 3.])"
136+
assert(result==expected)
137+
138+
result = str(dpnp.array([1., 0., dpnp.nan, 3.]))
139+
expected = "[ 1. 0. nan 3.]"
140+
assert(result==expected)
141+
# inf
142+
result = repr(dpnp.array([1., 0., numpy.inf, 3.]))
143+
expected = "array([ 1., 0., inf, 3.])"
144+
assert(result==expected)
145+
146+
result = str(dpnp.array([1., 0., numpy.inf, 3.]))
147+
expected = "[ 1. 0. inf 3.]"
148+
assert(result==expected)
149+
150+
def test_print_dpnp_nd():
151+
# 1D
152+
result = repr(dpnp.arange(10000, dtype='float32'))
153+
expected = "array([0.000e+00, 1.000e+00, 2.000e+00, ..., 9.997e+03, 9.998e+03,\n 9.999e+03], dtype=float32)"
154+
assert(result==expected)
155+
156+
result = str(dpnp.arange(10000, dtype='float32'))
157+
expected = "[0.000e+00 1.000e+00 2.000e+00 ... 9.997e+03 9.998e+03 9.999e+03]"
158+
assert(result==expected)
159+
160+
# 2D
161+
result = repr(dpnp.array([[1, 2], [3, 4]], dtype=float))
162+
expected = "array([[1., 2.],\n [3., 4.]])"
163+
assert(result==expected)
164+
165+
result = str(dpnp.array([[1, 2], [3, 4]]))
166+
expected = "[[1 2]\n [3 4]]"
167+
assert(result==expected)
168+
169+
# 0 shape
170+
result = repr(dpnp.empty( shape=(0, 0) ))
171+
expected = "array([])"
172+
assert(result==expected)
173+
174+
result = str(dpnp.empty( shape=(0, 0) ))
175+
expected = "[]"
176+
assert(result==expected)
72177

73178
@pytest.mark.parametrize("func", [bool, float, int, complex])
74179
@pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)])

utils/command_build_clib.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
# default variables (for Linux)
6464
_project_compiler = "icpx"
6565
_project_linker = "icpx"
66-
_project_cmplr_flag_sycl_devel = ["-fsycl-device-code-split=per_kernel", "-fno-approx-func", "-fno-approx-func"]
66+
_project_cmplr_flag_sycl_devel = ["-fsycl-device-code-split=per_kernel", "-fno-approx-func", "-fno-finite-math-only"]
6767
_project_cmplr_flag_sycl = ["-fsycl"]
6868
_project_cmplr_flag_stdcpp_static = [] # This brakes TBB ["-static-libstdc++", "-static-libgcc"]
6969
_project_cmplr_flag_compatibility = ["-Wl,--enable-new-dtags"]

0 commit comments

Comments
 (0)