From a7783d28747d8d6324404f8c2523979c39a555d8 Mon Sep 17 00:00:00 2001 From: robinw Date: Fri, 5 Aug 2022 16:21:03 +0800 Subject: [PATCH 1/8] Enhance two integration tests Enhance test_append and test_array_creation 1. add negative tests 2. add more test cases 3. refactor test code --- tests/integration/test_append.py | 83 +++++---- tests/integration/test_array_creation.py | 212 +++++++++++++++-------- tests/integration/utils/utils.py | 60 +++++++ 3 files changed, 245 insertions(+), 110 deletions(-) create mode 100644 tests/integration/utils/utils.py diff --git a/tests/integration/test_append.py b/tests/integration/test_append.py index 09c3d73c3b..5a6c8381e7 100644 --- a/tests/integration/test_append.py +++ b/tests/integration/test_append.py @@ -18,38 +18,7 @@ import cunumeric as num - -def _run_test(arr, values, test_args): - for axis in test_args: - b = np.append(arr, values, axis) - c = num.append(arr, values, axis) - is_equal = True - err_arr = [b, c] - - if len(b) != len(c): - is_equal = False - err_arr = [b, c] - else: - for each in zip(b, c): - if not np.array_equal(*each): - err_arr = each - is_equal = False - break - print_msg = ( - f"np.append(array({arr.shape}), array({values.shape}), {axis})" - ) - assert is_equal, ( - f"Failed, {print_msg}\n" - f"numpy result: {err_arr[0]}, {b.shape}\n" - f"cunumeric_result: {err_arr[1]}, {c.shape}\n" - f"cunumeric and numpy shows" - f" different result\n" - ) - print( - f"Passed, {print_msg}, np: ({b.shape}, {b.dtype})" - f", cunumeric: ({c.shape}, {c.dtype}" - ) - +from utils.utils import run_test DIM = 10 @@ -61,24 +30,54 @@ def _run_test(arr, values, test_args): (1, 1), (1, 1, 1), (1, DIM), + (1, DIM, 1), (DIM, DIM), (DIM, DIM, DIM), ] - @pytest.mark.parametrize("size", SIZES, ids=str) def test_append(size): a = np.random.randint(low=0, high=100, size=size) + test_args = list(range(a.ndim)) - test_args = list(range(a.ndim)) + [None] - - # test the exception for 1D array on append - _run_test(a, a, test_args) - - if a.ndim > 1: - # 1D array - b = np.random.randint(low=0, high=100, size=(DIM,)) - _run_test(a, b, [None]) + for axis in test_args: + size_b = list(size) + size_b[axis] = size[axis] + 10 + b = np.random.randint(low=0, high=100, size=size_b) + print_msg = ( + f"np.append(array({a.shape}), array({b.shape}), {axis})" + ) + run_test("append", [a, b], {'axis':axis}, print_msg) + + +def test_append_axis_none(): + axis = None + for size_a in SIZES: + a = np.random.randint(low=0, high=100, size=size_a) + for size_b in SIZES: + b = np.random.randint(low=0, high=100, size=size_b) + print_msg = ( + f"np.append(array({a.shape}), array({b.shape}), {axis})" + ) + run_test("append", [a, b], {'axis': axis}, print_msg) + + +def test_append_negative(): + size_a = (1, DIM) + size_b = (1, DIM, 1) + a = np.random.randint(low=0, high=100, size=size_a) + b = np.random.randint(low=0, high=100, size=size_b) + with pytest.raises(ValueError, + match='All arguments to concatenate must have the same number of dimensions'): + num.append(a, b, axis=1) + + size_c = (10, DIM) + c = np.random.randint(low=0, high=100, size=size_c) + with pytest.raises(AssertionError): + num.append(a, c, axis=1) + + with pytest.raises(IndexError): + num.append(a, a, axis=5) if __name__ == "__main__": diff --git a/tests/integration/test_array_creation.py b/tests/integration/test_array_creation.py index 821944c101..379b2f28fb 100644 --- a/tests/integration/test_array_creation.py +++ b/tests/integration/test_array_creation.py @@ -17,7 +17,7 @@ import pytest import cunumeric as num - +from itertools import product def test_array(): x = num.array([1, 2, 3]) @@ -32,83 +32,135 @@ def test_array(): assert x.dtype == y.dtype -def test_empty(): - xe = num.empty((2, 3)) - ye = np.empty((2, 3)) - assert xe.shape == ye.shape - assert xe.dtype == ye.dtype - - -def test_zeros(): - xz = num.zeros((2, 3)) - yz = np.zeros((2, 3)) - assert np.array_equal(xz, yz) - assert xz.dtype == yz.dtype - - -def test_ones(): - xo = num.ones((2, 3)) - yo = np.ones((2, 3)) - assert np.array_equal(xo, yo) - assert xo.dtype == yo.dtype - - -def test_full(): - xf = num.full((2, 3), 3) - yf = np.full((2, 3), 3) - assert np.array_equal(xf, yf) - assert xf.dtype == yf.dtype - - -def test_empty_like(): - x = num.array([1, 2, 3]) - y = num.array(x) - xel = num.empty_like(x) - yel = np.empty_like(y) - assert xel.shape == yel.shape - assert xel.dtype == yel.dtype - - -def test_zeros_like(): - x = num.array([1, 2, 3]) - y = num.array(x) - xzl = num.zeros_like(x) - yzl = np.zeros_like(y) - assert np.array_equal(xzl, yzl) - assert xzl.dtype == yzl.dtype +CREATION_FUNCTIONS = ("empty", "zeros", "ones") +FILLED_VALUES = [0, 1, 1000, 123.456] +SIZES = (0, 1, 2) +NDIMS = 5 +DTYPES = (np.uint32, np.int32, np.float64, np.complex128) + +@pytest.mark.parametrize("fn", CREATION_FUNCTIONS) +def test_creation_func(fn): + num_f = getattr(num, fn) + np_f = getattr(np, fn) + + par = (SIZES, + range(NDIMS), + DTYPES) + for size, ndims, dtype in product(*par): + shape = ndims * [size] + + xf = num_f(shape, dtype=dtype) + yf = np_f(shape, dtype=dtype) + + if fn == "empty": + assert xf.shape == yf.shape + else: + assert np.array_equal(xf, yf) + assert xf.dtype == yf.dtype + +@pytest.mark.parametrize('value', FILLED_VALUES) +def test_full(value): + par = (SIZES, + range(NDIMS), + DTYPES) + for size, ndims, dtype in product(*par): + shape = ndims * [size] + + xf = num.full(shape, value, dtype=dtype) + yf = np.full(shape, value, dtype=dtype) + + assert np.array_equal(xf, yf) + assert xf.dtype == yf.dtype + + +SHAPES_NEGATIVE = [ + -1, + (-1,2,3), + #num.array([2, -3, 4]), ## it would raise RuntimeError("Unable to find attachment to remove") when num.array + # is removed at the end as global variable + np.array([2, -3, 4]), +] +def test_creation_func_negative(): + for shape in SHAPES_NEGATIVE + [num.array([2, -3, 4])]: + with pytest.raises(ValueError): + num.empty(shape) + with pytest.raises(ValueError): + num.zeros(shape) + with pytest.raises(ValueError): + num.ones(shape) + with pytest.raises(ValueError): + num.full(shape, 10) + + num.full((2,3), [1]) + with pytest.raises(AssertionError): + num.full((2,3), [10, 20, 30]) + + +DATA_ARGS = [ + # Array scalars + (np.array(3.), None), + (np.array(3), 'f8'), + # 1D arrays + (np.array([]), None), + (np.arange(6, dtype='f4'), None), + (np.arange(6), 'c16'), + # 2D arrays + (np.array([[]]), None), + (np.arange(6).reshape(2, 3), None), + (np.arange(6).reshape(3, 2), 'i1'), + # 3D arrays + (np.arange(24).reshape(2, 3, 4), None), + (np.arange(24).reshape(4, 3, 2), 'f4'), +] +LIKE_FUNCTIONS = ("empty_like", "zeros_like", "ones_like") + +@pytest.mark.parametrize('x_np,dtype', DATA_ARGS) +@pytest.mark.parametrize("fn", LIKE_FUNCTIONS) +def test_func_like(fn, x_np, dtype): + num_f = getattr(num, fn) + np_f = getattr(np, fn) + + x = num.array(x_np) + xfl = num_f(x, dtype=dtype) + yfl = np_f(x_np, dtype=dtype) + + if fn == "empty_like": + assert xfl.shape == yfl.shape + else: + assert np.array_equal(xfl, yfl) + assert xfl.dtype == yfl.dtype -def test_ones_like(): - x = num.array([1, 2, 3]) - y = num.array(x) - xol = num.ones_like(x) - yol = np.ones_like(y) - assert np.array_equal(xol, yol) - assert xol.dtype == yol.dtype +@pytest.mark.parametrize('value', FILLED_VALUES) +@pytest.mark.parametrize('x_np, dtype', DATA_ARGS) +def test_full_like(x_np, dtype, value): + x = num.array(x_np) -def test_full_like(): - x = num.array([1, 2, 3]) - y = num.array(x) - xfl = num.full_like(x, 3) - yfl = np.full_like(y, 3) + xfl = num.full_like(x, value, dtype=dtype) + yfl = np.full_like(x_np, value, dtype=dtype) assert np.array_equal(xfl, yfl) assert xfl.dtype == yfl.dtype - # xfls = num.full_like(x, '3', dtype=np.str_) - # yfls = np.full_like(y, '3', dtype=np.str_) - # assert(num.array_equal(xfls, yfls)) - # assert(xfls.dtype == yfls.dtype) + +def test_full_like_negative(): + x = num.array([[1,2,3],[4,5,6]]) + num.full_like(x,[1]) + with pytest.raises(AssertionError): + num.full_like(x, [10,20,30]) ARANGE_ARGS = [ - (1,), + (0,), (10,), - (2.0, 10.0), - (2, 30, 3), + (3.5,), + (2, 10), + (-2.5, 10.0), + # (1, -10, -2.5), ### output: num: array([ 1, -1, -3, -5, -7]), np: array([ 1. , -1.5, -4. , -6.5, -9. ] + (1.0, -10.0, -2.5), + (-10, 10, 10) ] - @pytest.mark.parametrize("args", ARANGE_ARGS, ids=str) def test_arange(args): x = num.arange(*args) @@ -117,13 +169,36 @@ def test_arange(args): assert x.dtype == y.dtype -def test_arange_with_dtype(): - x = num.arange(10, dtype=np.int32) - y = np.arange(10, dtype=np.int32) +@pytest.mark.parametrize("dtype", [np.int32, np.float64], ids=str) +@pytest.mark.parametrize("args", ARANGE_ARGS, ids=str) +def test_arange_with_dtype(args, dtype): + x = num.arange(*args, dtype=dtype) + y = np.arange(*args, dtype=dtype) assert np.array_equal(x, y) assert x.dtype == y.dtype +def test_arange_negative(): + with pytest.raises(ValueError): + num.arange(-10) ###np.arange(-10) returns [] successfully + with pytest.raises(ValueError): + num.arange(2, -10) ###np.arange(2, -10) returns [] successfully + + with pytest.raises(OverflowError): + num.arange(0, num.inf) + with pytest.raises(ValueError): + num.arange(0, 1, num.nan) + + with pytest.raises(ZeroDivisionError): + num.arange(0, 10, 0) + with pytest.raises(ZeroDivisionError): + num.arange(0.0, 10.0, 0.0) + with pytest.raises(ZeroDivisionError): + num.arange(0, 0, 0) + with pytest.raises(ZeroDivisionError): + num.arange(0.0, 0.0, 0.0) + + def test_zero_with_nd_ndarray_shape(): shape = num.array([2, 3, 4]) x = num.zeros(shape) @@ -148,6 +223,7 @@ def test_zero_with_0d_ndarray_shape(): assert np.array_equal(x, y) + if __name__ == "__main__": import sys diff --git a/tests/integration/utils/utils.py b/tests/integration/utils/utils.py new file mode 100644 index 0000000000..d9576a62fa --- /dev/null +++ b/tests/integration/utils/utils.py @@ -0,0 +1,60 @@ +# Copyright 2021-2022 NVIDIA Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import numpy as np +import cunumeric as num + + +def compare_array(b,c): + """ + Compare two array using zip method. + """ + + is_equal = True + err_arr = [b, c] + + if len(b) != len(c): + is_equal = False + err_arr = [b, c] + else: + for each in zip(b, c): + if not np.array_equal(*each): + err_arr = each + is_equal = False + break + return is_equal, err_arr + + +def run_test(fn, args, kwargs, print_msg): + """ + Run np.func and num.func respectively and compare resutls + """ + + b = getattr(num, fn)(*args, **kwargs) + c = getattr(np, fn)(*args, **kwargs) + + is_equal, err_arr = compare_array(b, c) + + assert is_equal, ( + f"Failed, {print_msg}\n" + f"numpy result: {err_arr[0]}, {b.shape}\n" + f"cunumeric_result: {err_arr[1]}, {c.shape}\n" + f"cunumeric and numpy shows" + f" different result\n" + ) + print( + f"Passed, {print_msg}, np: ({b.shape}, {b.dtype})" + f", cunumeric: ({c.shape}, {c.dtype})" + ) From 7d99fb3e393a580c6fc3a0ea83c6ecfdbf6ab77c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Aug 2022 08:30:57 +0000 Subject: [PATCH 2/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/integration/test_append.py | 18 ++++---- tests/integration/test_array_creation.py | 56 ++++++++++++------------ tests/integration/utils/utils.py | 7 +-- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/tests/integration/test_append.py b/tests/integration/test_append.py index 5a6c8381e7..156b6b58b0 100644 --- a/tests/integration/test_append.py +++ b/tests/integration/test_append.py @@ -15,11 +15,10 @@ import numpy as np import pytest +from utils.utils import run_test import cunumeric as num -from utils.utils import run_test - DIM = 10 # test append w/ 1D, 2D and 3D arrays @@ -35,6 +34,7 @@ (DIM, DIM, DIM), ] + @pytest.mark.parametrize("size", SIZES, ids=str) def test_append(size): a = np.random.randint(low=0, high=100, size=size) @@ -44,10 +44,8 @@ def test_append(size): size_b = list(size) size_b[axis] = size[axis] + 10 b = np.random.randint(low=0, high=100, size=size_b) - print_msg = ( - f"np.append(array({a.shape}), array({b.shape}), {axis})" - ) - run_test("append", [a, b], {'axis':axis}, print_msg) + print_msg = f"np.append(array({a.shape}), array({b.shape}), {axis})" + run_test("append", [a, b], {"axis": axis}, print_msg) def test_append_axis_none(): @@ -59,7 +57,7 @@ def test_append_axis_none(): print_msg = ( f"np.append(array({a.shape}), array({b.shape}), {axis})" ) - run_test("append", [a, b], {'axis': axis}, print_msg) + run_test("append", [a, b], {"axis": axis}, print_msg) def test_append_negative(): @@ -67,8 +65,10 @@ def test_append_negative(): size_b = (1, DIM, 1) a = np.random.randint(low=0, high=100, size=size_a) b = np.random.randint(low=0, high=100, size=size_b) - with pytest.raises(ValueError, - match='All arguments to concatenate must have the same number of dimensions'): + with pytest.raises( + ValueError, + match="All arguments to concatenate must have the same number of dimensions", + ): num.append(a, b, axis=1) size_c = (10, DIM) diff --git a/tests/integration/test_array_creation.py b/tests/integration/test_array_creation.py index 379b2f28fb..6b01906612 100644 --- a/tests/integration/test_array_creation.py +++ b/tests/integration/test_array_creation.py @@ -13,11 +13,13 @@ # limitations under the License. # +from itertools import product + import numpy as np import pytest import cunumeric as num -from itertools import product + def test_array(): x = num.array([1, 2, 3]) @@ -38,14 +40,13 @@ def test_array(): NDIMS = 5 DTYPES = (np.uint32, np.int32, np.float64, np.complex128) + @pytest.mark.parametrize("fn", CREATION_FUNCTIONS) def test_creation_func(fn): num_f = getattr(num, fn) np_f = getattr(np, fn) - par = (SIZES, - range(NDIMS), - DTYPES) + par = (SIZES, range(NDIMS), DTYPES) for size, ndims, dtype in product(*par): shape = ndims * [size] @@ -58,11 +59,10 @@ def test_creation_func(fn): assert np.array_equal(xf, yf) assert xf.dtype == yf.dtype -@pytest.mark.parametrize('value', FILLED_VALUES) + +@pytest.mark.parametrize("value", FILLED_VALUES) def test_full(value): - par = (SIZES, - range(NDIMS), - DTYPES) + par = (SIZES, range(NDIMS), DTYPES) for size, ndims, dtype in product(*par): shape = ndims * [size] @@ -75,12 +75,13 @@ def test_full(value): SHAPES_NEGATIVE = [ -1, - (-1,2,3), - #num.array([2, -3, 4]), ## it would raise RuntimeError("Unable to find attachment to remove") when num.array + (-1, 2, 3), + # num.array([2, -3, 4]), ## it would raise RuntimeError("Unable to find attachment to remove") when num.array # is removed at the end as global variable np.array([2, -3, 4]), ] + def test_creation_func_negative(): for shape in SHAPES_NEGATIVE + [num.array([2, -3, 4])]: with pytest.raises(ValueError): @@ -92,30 +93,31 @@ def test_creation_func_negative(): with pytest.raises(ValueError): num.full(shape, 10) - num.full((2,3), [1]) + num.full((2, 3), [1]) with pytest.raises(AssertionError): - num.full((2,3), [10, 20, 30]) + num.full((2, 3), [10, 20, 30]) DATA_ARGS = [ # Array scalars - (np.array(3.), None), - (np.array(3), 'f8'), + (np.array(3.0), None), + (np.array(3), "f8"), # 1D arrays (np.array([]), None), - (np.arange(6, dtype='f4'), None), - (np.arange(6), 'c16'), + (np.arange(6, dtype="f4"), None), + (np.arange(6), "c16"), # 2D arrays (np.array([[]]), None), (np.arange(6).reshape(2, 3), None), - (np.arange(6).reshape(3, 2), 'i1'), + (np.arange(6).reshape(3, 2), "i1"), # 3D arrays (np.arange(24).reshape(2, 3, 4), None), - (np.arange(24).reshape(4, 3, 2), 'f4'), + (np.arange(24).reshape(4, 3, 2), "f4"), ] LIKE_FUNCTIONS = ("empty_like", "zeros_like", "ones_like") -@pytest.mark.parametrize('x_np,dtype', DATA_ARGS) + +@pytest.mark.parametrize("x_np,dtype", DATA_ARGS) @pytest.mark.parametrize("fn", LIKE_FUNCTIONS) def test_func_like(fn, x_np, dtype): num_f = getattr(num, fn) @@ -132,8 +134,8 @@ def test_func_like(fn, x_np, dtype): assert xfl.dtype == yfl.dtype -@pytest.mark.parametrize('value', FILLED_VALUES) -@pytest.mark.parametrize('x_np, dtype', DATA_ARGS) +@pytest.mark.parametrize("value", FILLED_VALUES) +@pytest.mark.parametrize("x_np, dtype", DATA_ARGS) def test_full_like(x_np, dtype, value): x = num.array(x_np) @@ -144,10 +146,10 @@ def test_full_like(x_np, dtype, value): def test_full_like_negative(): - x = num.array([[1,2,3],[4,5,6]]) - num.full_like(x,[1]) + x = num.array([[1, 2, 3], [4, 5, 6]]) + num.full_like(x, [1]) with pytest.raises(AssertionError): - num.full_like(x, [10,20,30]) + num.full_like(x, [10, 20, 30]) ARANGE_ARGS = [ @@ -158,9 +160,10 @@ def test_full_like_negative(): (-2.5, 10.0), # (1, -10, -2.5), ### output: num: array([ 1, -1, -3, -5, -7]), np: array([ 1. , -1.5, -4. , -6.5, -9. ] (1.0, -10.0, -2.5), - (-10, 10, 10) + (-10, 10, 10), ] + @pytest.mark.parametrize("args", ARANGE_ARGS, ids=str) def test_arange(args): x = num.arange(*args) @@ -182,7 +185,7 @@ def test_arange_negative(): with pytest.raises(ValueError): num.arange(-10) ###np.arange(-10) returns [] successfully with pytest.raises(ValueError): - num.arange(2, -10) ###np.arange(2, -10) returns [] successfully + num.arange(2, -10) ###np.arange(2, -10) returns [] successfully with pytest.raises(OverflowError): num.arange(0, num.inf) @@ -223,7 +226,6 @@ def test_zero_with_0d_ndarray_shape(): assert np.array_equal(x, y) - if __name__ == "__main__": import sys diff --git a/tests/integration/utils/utils.py b/tests/integration/utils/utils.py index d9576a62fa..1a74a8a47e 100644 --- a/tests/integration/utils/utils.py +++ b/tests/integration/utils/utils.py @@ -14,12 +14,13 @@ # import numpy as np + import cunumeric as num -def compare_array(b,c): +def compare_array(b, c): """ - Compare two array using zip method. + Compare two array using zip method. """ is_equal = True @@ -39,7 +40,7 @@ def compare_array(b,c): def run_test(fn, args, kwargs, print_msg): """ - Run np.func and num.func respectively and compare resutls + Run np.func and num.func respectively and compare resutls """ b = getattr(num, fn)(*args, **kwargs) From 8470c4033436a97dc55fc176c89896d34f2dca6e Mon Sep 17 00:00:00 2001 From: robinw Date: Tue, 9 Aug 2022 16:44:54 +0800 Subject: [PATCH 3/8] Address comments 1. Create test class for negative testing 2. Refactor out test functions 3. Use parameterize --- tests/integration/test_append.py | 63 ++++++------ tests/integration/test_array_creation.py | 118 +++++++++++++++-------- tests/integration/utils/utils.py | 34 +++---- 3 files changed, 129 insertions(+), 86 deletions(-) diff --git a/tests/integration/test_append.py b/tests/integration/test_append.py index 156b6b58b0..72dad5f93c 100644 --- a/tests/integration/test_append.py +++ b/tests/integration/test_append.py @@ -38,7 +38,7 @@ @pytest.mark.parametrize("size", SIZES, ids=str) def test_append(size): a = np.random.randint(low=0, high=100, size=size) - test_args = list(range(a.ndim)) + test_args = [-1] + list(range(a.ndim)) for axis in test_args: size_b = list(size) @@ -48,36 +48,43 @@ def test_append(size): run_test("append", [a, b], {"axis": axis}, print_msg) -def test_append_axis_none(): +@pytest.mark.parametrize("size_b", SIZES, ids=str) +@pytest.mark.parametrize("size_a", SIZES, ids=str) +def test_append_axis_none(size_a, size_b): axis = None - for size_a in SIZES: - a = np.random.randint(low=0, high=100, size=size_a) - for size_b in SIZES: - b = np.random.randint(low=0, high=100, size=size_b) - print_msg = ( - f"np.append(array({a.shape}), array({b.shape}), {axis})" - ) - run_test("append", [a, b], {"axis": axis}, print_msg) - - -def test_append_negative(): - size_a = (1, DIM) - size_b = (1, DIM, 1) a = np.random.randint(low=0, high=100, size=size_a) b = np.random.randint(low=0, high=100, size=size_b) - with pytest.raises( - ValueError, - match="All arguments to concatenate must have the same number of dimensions", - ): - num.append(a, b, axis=1) - - size_c = (10, DIM) - c = np.random.randint(low=0, high=100, size=size_c) - with pytest.raises(AssertionError): - num.append(a, c, axis=1) - - with pytest.raises(IndexError): - num.append(a, a, axis=5) + print_msg = f"np.append(array({a.shape}), array({b.shape}), {axis})" + run_test("append", [a, b], {"axis": axis}, print_msg) + + +class TestAppendErrors: + + def setup(self): + size_a = (1, DIM) + self.a = np.random.randint(low=0, high=100, size=size_a) + + def test_bad_dimension(self): + size_b = (1, DIM, 1) + b = np.random.randint(low=0, high=100, size=size_b) + + msg = "All arguments to concatenate must have the " \ + "same number of dimensions" + with pytest.raises(ValueError, match=msg): + num.append(self.a, b, axis=1) + + def test_bad_index(self): + with pytest.raises(IndexError): + num.append(self.a, self.a, axis=5) + + + def test_bad_shape(self): + size_c = (10, DIM) + c = np.random.randint(low=0, high=100, size=size_c) + ## In cunumeric eager execution and np, ValueError is raised + ## In cunumeric gpu test, AssertionError is raised + with pytest.raises(AssertionError): + num.append(self.a, c, axis=1) if __name__ == "__main__": diff --git a/tests/integration/test_array_creation.py b/tests/integration/test_array_creation.py index 6b01906612..061241d541 100644 --- a/tests/integration/test_array_creation.py +++ b/tests/integration/test_array_creation.py @@ -34,13 +34,25 @@ def test_array(): assert x.dtype == y.dtype -CREATION_FUNCTIONS = ("empty", "zeros", "ones") +CREATION_FUNCTIONS = ("zeros", "ones") FILLED_VALUES = [0, 1, 1000, 123.456] SIZES = (0, 1, 2) NDIMS = 5 DTYPES = (np.uint32, np.int32, np.float64, np.complex128) +def test_empty(): + par = (SIZES, range(NDIMS), DTYPES) + for size, ndims, dtype in product(*par): + shape = ndims * [size] + + xf = num.empty(shape, dtype=dtype) + yf = np.empty(shape, dtype=dtype) + + assert xf.shape == yf.shape + assert xf.dtype == yf.dtype + + @pytest.mark.parametrize("fn", CREATION_FUNCTIONS) def test_creation_func(fn): num_f = getattr(num, fn) @@ -53,10 +65,7 @@ def test_creation_func(fn): xf = num_f(shape, dtype=dtype) yf = np_f(shape, dtype=dtype) - if fn == "empty": - assert xf.shape == yf.shape - else: - assert np.array_equal(xf, yf) + assert np.array_equal(xf, yf) assert xf.dtype == yf.dtype @@ -76,24 +85,38 @@ def test_full(value): SHAPES_NEGATIVE = [ -1, (-1, 2, 3), - # num.array([2, -3, 4]), ## it would raise RuntimeError("Unable to find attachment to remove") when num.array - # is removed at the end as global variable + ## it raises RuntimeError("Unable to find attachment to remove") + ## when num.array is removed at the end as global variable + # num.array([2, -3, 4]), np.array([2, -3, 4]), ] -def test_creation_func_negative(): - for shape in SHAPES_NEGATIVE + [num.array([2, -3, 4])]: +@pytest.mark.parametrize('shape', SHAPES_NEGATIVE, ids=str) +class TestCreationErrors: + + def test_empty_with_negative_shape(self, shape): with pytest.raises(ValueError): num.empty(shape) + + def test_zeros_with_negative_shape(self, shape): with pytest.raises(ValueError): num.zeros(shape) + + def test_ones_with_negative_shape(self, shape): with pytest.raises(ValueError): num.ones(shape) + + def test_full_with_negative_shape(self, shape): with pytest.raises(ValueError): num.full(shape, 10) - num.full((2, 3), [1]) + +# additional special case for full +def test_full_assertion(): + ## pass in cunumeric + gpu, but fail for + ## cunumeric + eager execution + ## num.full((2, 3), [1]) with pytest.raises(AssertionError): num.full((2, 3), [10, 20, 30]) @@ -114,7 +137,17 @@ def test_creation_func_negative(): (np.arange(24).reshape(2, 3, 4), None), (np.arange(24).reshape(4, 3, 2), "f4"), ] -LIKE_FUNCTIONS = ("empty_like", "zeros_like", "ones_like") +LIKE_FUNCTIONS = ("zeros_like", "ones_like") + + +@pytest.mark.parametrize("x_np,dtype", DATA_ARGS) +def test_empty_like(x_np, dtype): + x = num.array(x_np) + xfl = num.empty_like(x, dtype=dtype) + yfl = np.empty_like(x_np, dtype=dtype) + + assert xfl.shape == yfl.shape + assert xfl.dtype == yfl.dtype @pytest.mark.parametrize("x_np,dtype", DATA_ARGS) @@ -127,10 +160,7 @@ def test_func_like(fn, x_np, dtype): xfl = num_f(x, dtype=dtype) yfl = np_f(x_np, dtype=dtype) - if fn == "empty_like": - assert xfl.shape == yfl.shape - else: - assert np.array_equal(xfl, yfl) + assert np.array_equal(xfl, yfl) assert xfl.dtype == yfl.dtype @@ -145,9 +175,11 @@ def test_full_like(x_np, dtype, value): assert xfl.dtype == yfl.dtype -def test_full_like_negative(): - x = num.array([[1, 2, 3], [4, 5, 6]]) - num.full_like(x, [1]) +def test_full_like_assertion(): + x = num.array([[1, 2, 3],[4, 5, 6]]) + ## pass in cunumeric + gpu, but fail for + ## cunumeric + eager execution + ## num.full_like(x, [1]) with pytest.raises(AssertionError): num.full_like(x, [10, 20, 30]) @@ -158,7 +190,9 @@ def test_full_like_negative(): (3.5,), (2, 10), (-2.5, 10.0), - # (1, -10, -2.5), ### output: num: array([ 1, -1, -3, -5, -7]), np: array([ 1. , -1.5, -4. , -6.5, -9. ] + ### output: num: array([ 1, -1, -3, -5, -7]), + ### np: array([ 1. , -1.5, -4. , -6.5, -9. ] + # (1, -10, -2.5), (1.0, -10.0, -2.5), (-10, 10, 10), ] @@ -181,25 +215,33 @@ def test_arange_with_dtype(args, dtype): assert x.dtype == y.dtype -def test_arange_negative(): - with pytest.raises(ValueError): - num.arange(-10) ###np.arange(-10) returns [] successfully - with pytest.raises(ValueError): - num.arange(2, -10) ###np.arange(2, -10) returns [] successfully - - with pytest.raises(OverflowError): - num.arange(0, num.inf) - with pytest.raises(ValueError): - num.arange(0, 1, num.nan) - - with pytest.raises(ZeroDivisionError): - num.arange(0, 10, 0) - with pytest.raises(ZeroDivisionError): - num.arange(0.0, 10.0, 0.0) - with pytest.raises(ZeroDivisionError): - num.arange(0, 0, 0) - with pytest.raises(ZeroDivisionError): - num.arange(0.0, 0.0, 0.0) +class TestArrangeErrors: + + def test_negative_sizes(self): + with pytest.raises(ValueError): + ###np.arange(-10) returns [] successfully + num.arange(-10) + with pytest.raises(ValueError): + ###np.arange(2, -10) returns [] successfully + num.arange(2, -10) + + def test_inf(self): + with pytest.raises(OverflowError): + num.arange(0, num.inf) + + def test_nan(self): + with pytest.raises(ValueError): + num.arange(0, 1, num.nan) + + def test_zero_division(self): + with pytest.raises(ZeroDivisionError): + num.arange(0, 10, 0) + with pytest.raises(ZeroDivisionError): + num.arange(0.0, 10.0, 0.0) + with pytest.raises(ZeroDivisionError): + num.arange(0, 0, 0) + with pytest.raises(ZeroDivisionError): + num.arange(0.0, 0.0, 0.0) def test_zero_with_nd_ndarray_shape(): diff --git a/tests/integration/utils/utils.py b/tests/integration/utils/utils.py index 1a74a8a47e..d9c1e187a4 100644 --- a/tests/integration/utils/utils.py +++ b/tests/integration/utils/utils.py @@ -18,44 +18,38 @@ import cunumeric as num -def compare_array(b, c): +def compare_array(a, b): """ Compare two array using zip method. """ - is_equal = True - err_arr = [b, c] - - if len(b) != len(c): - is_equal = False - err_arr = [b, c] + if len(a) != len(b): + return False, [a, b] else: - for each in zip(b, c): + for each in zip(a, b): if not np.array_equal(*each): - err_arr = each - is_equal = False - break - return is_equal, err_arr + return False, each + return True, None def run_test(fn, args, kwargs, print_msg): """ - Run np.func and num.func respectively and compare resutls + Run np.func and num.func respectively and compare results """ - b = getattr(num, fn)(*args, **kwargs) - c = getattr(np, fn)(*args, **kwargs) + a = getattr(num, fn)(*args, **kwargs) + b = getattr(np, fn)(*args, **kwargs) - is_equal, err_arr = compare_array(b, c) + is_equal, err_arr = compare_array(a, b) assert is_equal, ( f"Failed, {print_msg}\n" - f"numpy result: {err_arr[0]}, {b.shape}\n" - f"cunumeric_result: {err_arr[1]}, {c.shape}\n" + f"numpy result: {err_arr[0]}, {a.shape}\n" + f"cunumeric_result: {err_arr[1]}, {b.shape}\n" f"cunumeric and numpy shows" f" different result\n" ) print( - f"Passed, {print_msg}, np: ({b.shape}, {b.dtype})" - f", cunumeric: ({c.shape}, {c.dtype})" + f"Passed, {print_msg}, np: ({a.shape}, {a.dtype})" + f", cunumeric: ({b.shape}, {b.dtype})" ) From 5796cb9d603d6272c6a7279b0a311cd0ddc47050 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Aug 2022 08:48:00 +0000 Subject: [PATCH 4/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/integration/test_append.py | 8 ++++---- tests/integration/test_array_creation.py | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/integration/test_append.py b/tests/integration/test_append.py index 72dad5f93c..979b551c19 100644 --- a/tests/integration/test_append.py +++ b/tests/integration/test_append.py @@ -59,7 +59,6 @@ def test_append_axis_none(size_a, size_b): class TestAppendErrors: - def setup(self): size_a = (1, DIM) self.a = np.random.randint(low=0, high=100, size=size_a) @@ -68,8 +67,10 @@ def test_bad_dimension(self): size_b = (1, DIM, 1) b = np.random.randint(low=0, high=100, size=size_b) - msg = "All arguments to concatenate must have the " \ - "same number of dimensions" + msg = ( + "All arguments to concatenate must have the " + "same number of dimensions" + ) with pytest.raises(ValueError, match=msg): num.append(self.a, b, axis=1) @@ -77,7 +78,6 @@ def test_bad_index(self): with pytest.raises(IndexError): num.append(self.a, self.a, axis=5) - def test_bad_shape(self): size_c = (10, DIM) c = np.random.randint(low=0, high=100, size=size_c) diff --git a/tests/integration/test_array_creation.py b/tests/integration/test_array_creation.py index 061241d541..50b4e4beaf 100644 --- a/tests/integration/test_array_creation.py +++ b/tests/integration/test_array_creation.py @@ -92,9 +92,8 @@ def test_full(value): ] -@pytest.mark.parametrize('shape', SHAPES_NEGATIVE, ids=str) +@pytest.mark.parametrize("shape", SHAPES_NEGATIVE, ids=str) class TestCreationErrors: - def test_empty_with_negative_shape(self, shape): with pytest.raises(ValueError): num.empty(shape) @@ -176,7 +175,7 @@ def test_full_like(x_np, dtype, value): def test_full_like_assertion(): - x = num.array([[1, 2, 3],[4, 5, 6]]) + x = num.array([[1, 2, 3], [4, 5, 6]]) ## pass in cunumeric + gpu, but fail for ## cunumeric + eager execution ## num.full_like(x, [1]) @@ -216,7 +215,6 @@ def test_arange_with_dtype(args, dtype): class TestArrangeErrors: - def test_negative_sizes(self): with pytest.raises(ValueError): ###np.arange(-10) returns [] successfully From d3c2261ec3368f62d90277ca627debc7d37f8dde Mon Sep 17 00:00:00 2001 From: robinw Date: Wed, 10 Aug 2022 16:08:55 +0800 Subject: [PATCH 5/8] Address comments - part2 1. update run_test name to check_array_method 2. use parameterize for step zero cases of arange --- tests/integration/test_append.py | 10 ++--- tests/integration/test_array_creation.py | 49 ++++++++++++++---------- tests/integration/utils/utils.py | 2 +- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/tests/integration/test_append.py b/tests/integration/test_append.py index 979b551c19..b75aa4c607 100644 --- a/tests/integration/test_append.py +++ b/tests/integration/test_append.py @@ -15,7 +15,7 @@ import numpy as np import pytest -from utils.utils import run_test +from utils.utils import check_array_method import cunumeric as num @@ -45,7 +45,7 @@ def test_append(size): size_b[axis] = size[axis] + 10 b = np.random.randint(low=0, high=100, size=size_b) print_msg = f"np.append(array({a.shape}), array({b.shape}), {axis})" - run_test("append", [a, b], {"axis": axis}, print_msg) + check_array_method("append", [a, b], {"axis": axis}, print_msg) @pytest.mark.parametrize("size_b", SIZES, ids=str) @@ -55,7 +55,7 @@ def test_append_axis_none(size_a, size_b): a = np.random.randint(low=0, high=100, size=size_a) b = np.random.randint(low=0, high=100, size=size_b) print_msg = f"np.append(array({a.shape}), array({b.shape}), {axis})" - run_test("append", [a, b], {"axis": axis}, print_msg) + check_array_method("append", [a, b], {"axis": axis}, print_msg) class TestAppendErrors: @@ -81,8 +81,8 @@ def test_bad_index(self): def test_bad_shape(self): size_c = (10, DIM) c = np.random.randint(low=0, high=100, size=size_c) - ## In cunumeric eager execution and np, ValueError is raised - ## In cunumeric gpu test, AssertionError is raised + # In cunumeric eager execution and np, ValueError is raised + # In cunumeric gpu test, AssertionError is raised with pytest.raises(AssertionError): num.append(self.a, c, axis=1) diff --git a/tests/integration/test_array_creation.py b/tests/integration/test_array_creation.py index 50b4e4beaf..d7904bb2aa 100644 --- a/tests/integration/test_array_creation.py +++ b/tests/integration/test_array_creation.py @@ -85,8 +85,8 @@ def test_full(value): SHAPES_NEGATIVE = [ -1, (-1, 2, 3), - ## it raises RuntimeError("Unable to find attachment to remove") - ## when num.array is removed at the end as global variable + # it raises RuntimeError("Unable to find attachment to remove") + # when num.array is removed at the end as global variable # num.array([2, -3, 4]), np.array([2, -3, 4]), ] @@ -113,9 +113,9 @@ def test_full_with_negative_shape(self, shape): # additional special case for full def test_full_assertion(): - ## pass in cunumeric + gpu, but fail for - ## cunumeric + eager execution - ## num.full((2, 3), [1]) + # pass in cunumeric + gpu, but fail for + # cunumeric + eager execution + # num.full((2, 3), [1]) with pytest.raises(AssertionError): num.full((2, 3), [10, 20, 30]) @@ -176,9 +176,9 @@ def test_full_like(x_np, dtype, value): def test_full_like_assertion(): x = num.array([[1, 2, 3], [4, 5, 6]]) - ## pass in cunumeric + gpu, but fail for - ## cunumeric + eager execution - ## num.full_like(x, [1]) + # pass in cunumeric + gpu, but fail for + # cunumeric + eager execution + # num.full_like(x, [1]) with pytest.raises(AssertionError): num.full_like(x, [10, 20, 30]) @@ -189,8 +189,8 @@ def test_full_like_assertion(): (3.5,), (2, 10), (-2.5, 10.0), - ### output: num: array([ 1, -1, -3, -5, -7]), - ### np: array([ 1. , -1.5, -4. , -6.5, -9. ] + # output: num: array([ 1, -1, -3, -5, -7]), + # np: array([ 1. , -1.5, -4. , -6.5, -9. ] # (1, -10, -2.5), (1.0, -10.0, -2.5), (-10, 10, 10), @@ -214,13 +214,27 @@ def test_arange_with_dtype(args, dtype): assert x.dtype == y.dtype +ARANGE_ARGS_STEP_ZERO = [ + (0, 0, 0), + (0, 10, 0), + (-10, 10, 0), + (1, 10, 0), + (10, -10, 0), + (0.0, 0.0, 0.0), + (0.0, 10.0, 0.0), + (-10.0, 10.0, 0.0), + (1.0, 10.0, 0.0), + (10.0, -10.0, 0.0), +] + + class TestArrangeErrors: def test_negative_sizes(self): with pytest.raises(ValueError): - ###np.arange(-10) returns [] successfully + # np.arange(-10) returns [] successfully num.arange(-10) with pytest.raises(ValueError): - ###np.arange(2, -10) returns [] successfully + # np.arange(2, -10) returns [] successfully num.arange(2, -10) def test_inf(self): @@ -231,15 +245,10 @@ def test_nan(self): with pytest.raises(ValueError): num.arange(0, 1, num.nan) - def test_zero_division(self): - with pytest.raises(ZeroDivisionError): - num.arange(0, 10, 0) - with pytest.raises(ZeroDivisionError): - num.arange(0.0, 10.0, 0.0) - with pytest.raises(ZeroDivisionError): - num.arange(0, 0, 0) + @pytest.mark.parametrize("args", ARANGE_ARGS_STEP_ZERO, ids=str) + def test_zero_division(self, args): with pytest.raises(ZeroDivisionError): - num.arange(0.0, 0.0, 0.0) + num.arange(*args) def test_zero_with_nd_ndarray_shape(): diff --git a/tests/integration/utils/utils.py b/tests/integration/utils/utils.py index d9c1e187a4..98bff79c6e 100644 --- a/tests/integration/utils/utils.py +++ b/tests/integration/utils/utils.py @@ -32,7 +32,7 @@ def compare_array(a, b): return True, None -def run_test(fn, args, kwargs, print_msg): +def check_array_method(fn, args, kwargs, print_msg): """ Run np.func and num.func respectively and compare results """ From edb93645a867bf2ba4f699281c72eeb567c0ccc5 Mon Sep 17 00:00:00 2001 From: robinw Date: Fri, 12 Aug 2022 16:07:56 +0800 Subject: [PATCH 6/8] Address comments - Part 3 1. add pytest.mark.xfail for cases with expected failure 2. Small Fix: replace Assert with raising ValueError in deferred.py --- cunumeric/deferred.py | 9 ++- tests/integration/test_append.py | 4 +- tests/integration/test_array_creation.py | 76 ++++++++++-------------- 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/cunumeric/deferred.py b/cunumeric/deferred.py index c99c1c9e82..c2e5d96458 100644 --- a/cunumeric/deferred.py +++ b/cunumeric/deferred.py @@ -708,7 +708,11 @@ def _broadcast(self, shape: NdShape) -> Any: for dim in range(len(shape)): if result.shape[dim] != shape[dim]: - assert result.shape[dim] == 1 + if result.shape[dim] != 1: + raise ValueError( + f"Shape did not match along dimension {dim}" + "and the value is not equal to 1" + ) result = result.project(dim, 0).promote(dim, shape[dim]) return result @@ -1235,7 +1239,8 @@ def _fill(self, value: Any) -> None: def fill(self, numpy_array: Any) -> None: assert isinstance(numpy_array, np.ndarray) - assert numpy_array.size == 1 + if numpy_array.size != 1: + raise ValueError("Filled value array size is not equal to 1") assert self.dtype == numpy_array.dtype # Have to copy the numpy array because this launch is asynchronous # and we need to make sure the application doesn't mutate the value diff --git a/tests/integration/test_append.py b/tests/integration/test_append.py index b75aa4c607..222ae632a1 100644 --- a/tests/integration/test_append.py +++ b/tests/integration/test_append.py @@ -81,9 +81,7 @@ def test_bad_index(self): def test_bad_shape(self): size_c = (10, DIM) c = np.random.randint(low=0, high=100, size=size_c) - # In cunumeric eager execution and np, ValueError is raised - # In cunumeric gpu test, AssertionError is raised - with pytest.raises(AssertionError): + with pytest.raises(ValueError): num.append(self.a, c, axis=1) diff --git a/tests/integration/test_array_creation.py b/tests/integration/test_array_creation.py index d7904bb2aa..6c0274c66e 100644 --- a/tests/integration/test_array_creation.py +++ b/tests/integration/test_array_creation.py @@ -85,39 +85,38 @@ def test_full(value): SHAPES_NEGATIVE = [ -1, (-1, 2, 3), - # it raises RuntimeError("Unable to find attachment to remove") - # when num.array is removed at the end as global variable - # num.array([2, -3, 4]), np.array([2, -3, 4]), ] -@pytest.mark.parametrize("shape", SHAPES_NEGATIVE, ids=str) class TestCreationErrors: - def test_empty_with_negative_shape(self, shape): + def setup(self): + self.bad_type_shape = (2, 3.0) + + @pytest.mark.parametrize("shape", SHAPES_NEGATIVE, ids=str) + class TestNegativeShape(): + @pytest.mark.parametrize("fn", ("empty", "zeros", "ones")) + def test_creation(self, shape, fn): + with pytest.raises(ValueError): + getattr(num, fn)(shape) + + def test_full(self, shape): + with pytest.raises(ValueError): + num.full(shape, 10) + + @pytest.mark.parametrize("fn", ("empty", "zeros", "ones")) + def test_creation_bad_type(self, fn): + with pytest.raises(TypeError): + getattr(num, fn)(self.bad_type_shape) + + def test_full_bad_type(self): + with pytest.raises(TypeError): + num.full(self.bad_type_shape, 10) + + # additional special case for full + def test_full_bad_filled_value(self): with pytest.raises(ValueError): - num.empty(shape) - - def test_zeros_with_negative_shape(self, shape): - with pytest.raises(ValueError): - num.zeros(shape) - - def test_ones_with_negative_shape(self, shape): - with pytest.raises(ValueError): - num.ones(shape) - - def test_full_with_negative_shape(self, shape): - with pytest.raises(ValueError): - num.full(shape, 10) - - -# additional special case for full -def test_full_assertion(): - # pass in cunumeric + gpu, but fail for - # cunumeric + eager execution - # num.full((2, 3), [1]) - with pytest.raises(AssertionError): - num.full((2, 3), [10, 20, 30]) + num.full((2, 3), [10, 20, 30]) DATA_ARGS = [ @@ -133,6 +132,7 @@ def test_full_assertion(): (np.arange(6).reshape(2, 3), None), (np.arange(6).reshape(3, 2), "i1"), # 3D arrays + (np.array([[[]]]), None), (np.arange(24).reshape(2, 3, 4), None), (np.arange(24).reshape(4, 3, 2), "f4"), ] @@ -174,12 +174,9 @@ def test_full_like(x_np, dtype, value): assert xfl.dtype == yfl.dtype -def test_full_like_assertion(): +def test_full_like_bad_filled_value(): x = num.array([[1, 2, 3], [4, 5, 6]]) - # pass in cunumeric + gpu, but fail for - # cunumeric + eager execution - # num.full_like(x, [1]) - with pytest.raises(AssertionError): + with pytest.raises(ValueError): num.full_like(x, [10, 20, 30]) @@ -187,13 +184,14 @@ def test_full_like_assertion(): (0,), (10,), (3.5,), + pytest.param((-10), marks=pytest.mark.xfail), (2, 10), + pytest.param((2, -10), marks=pytest.mark.xfail), (-2.5, 10.0), - # output: num: array([ 1, -1, -3, -5, -7]), - # np: array([ 1. , -1.5, -4. , -6.5, -9. ] - # (1, -10, -2.5), + pytest.param((1, -10, -2.5), marks=pytest.mark.xfail), (1.0, -10.0, -2.5), (-10, 10, 10), + (-10, 10, -100), ] @@ -229,14 +227,6 @@ def test_arange_with_dtype(args, dtype): class TestArrangeErrors: - def test_negative_sizes(self): - with pytest.raises(ValueError): - # np.arange(-10) returns [] successfully - num.arange(-10) - with pytest.raises(ValueError): - # np.arange(2, -10) returns [] successfully - num.arange(2, -10) - def test_inf(self): with pytest.raises(OverflowError): num.arange(0, num.inf) From e045f8b7221e5eaff115dbefff63b29da455a376 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Aug 2022 08:12:46 +0000 Subject: [PATCH 7/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/integration/test_array_creation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_array_creation.py b/tests/integration/test_array_creation.py index 6c0274c66e..6054a57599 100644 --- a/tests/integration/test_array_creation.py +++ b/tests/integration/test_array_creation.py @@ -94,7 +94,7 @@ def setup(self): self.bad_type_shape = (2, 3.0) @pytest.mark.parametrize("shape", SHAPES_NEGATIVE, ids=str) - class TestNegativeShape(): + class TestNegativeShape: @pytest.mark.parametrize("fn", ("empty", "zeros", "ones")) def test_creation(self, shape, fn): with pytest.raises(ValueError): From 02bc9da07ef000cbb59b15de4c2269a8d8758064 Mon Sep 17 00:00:00 2001 From: robinw Date: Mon, 15 Aug 2022 16:42:25 +0800 Subject: [PATCH 8/8] Address comments - fix a typo --- cunumeric/deferred.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cunumeric/deferred.py b/cunumeric/deferred.py index c2e5d96458..98ea9026a2 100644 --- a/cunumeric/deferred.py +++ b/cunumeric/deferred.py @@ -710,7 +710,7 @@ def _broadcast(self, shape: NdShape) -> Any: if result.shape[dim] != shape[dim]: if result.shape[dim] != 1: raise ValueError( - f"Shape did not match along dimension {dim}" + f"Shape did not match along dimension {dim} " "and the value is not equal to 1" ) result = result.project(dim, 0).promote(dim, shape[dim])