Skip to content

Commit

Permalink
Remove loops that aren't strictly needed
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartenBaert committed Nov 1, 2024
1 parent 67e5724 commit 02eff18
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions tests/test_numpy_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,11 @@ def UnwrapPyValueHolder(vhs):
)
def test_pass_array_object_return_sum_str_values_ndarray(func):
initial_counter = PyValueHolder.counter
for loop in range(100):
# Intentionally all temporaries, do not change.
assert (
func(np.array(WrapWithPyValueHolder(-3, "four", 5.0), dtype=object))
== "-3four5.0"
)
# Intentionally all temporaries, do not change.
assert (
func(np.array(WrapWithPyValueHolder(-3, "four", 5.0), dtype=object))
== "-3four5.0"
)
assert PyValueHolder.counter == initial_counter

Check failure on line 653 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_ndarray[pass_array_pyobject_ptr_return_sum_str_values] AssertionError

Check failure on line 653 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_ndarray[pass_array_handle_return_sum_str_values] AssertionError

Check failure on line 653 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_ndarray[pass_array_object_return_sum_str_values] AssertionError

Check failure on line 653 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_ndarray[pass_array_pyobject_ptr_return_sum_str_values] assert 3 == 0 + where 3 = PyValueHolder.counter

Check failure on line 653 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_ndarray[pass_array_handle_return_sum_str_values] assert 6 == 3 + where 6 = PyValueHolder.counter

Check failure on line 653 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_ndarray[pass_array_object_return_sum_str_values] assert 9 == 6 + where 9 = PyValueHolder.counter

Check failure on line 653 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_pass_array_object_return_sum_str_values_ndarray[pass_array_pyobject_ptr_return_sum_str_values] assert 3 == 0 + where 3 = PyValueHolder.counter

Check failure on line 653 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_pass_array_object_return_sum_str_values_ndarray[pass_array_handle_return_sum_str_values] assert 6 == 3 + where 6 = PyValueHolder.counter

Check failure on line 653 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_pass_array_object_return_sum_str_values_ndarray[pass_array_object_return_sum_str_values] assert 9 == 6 + where 9 = PyValueHolder.counter


Expand All @@ -664,9 +663,8 @@ def test_pass_array_object_return_sum_str_values_ndarray(func):
)
def test_pass_array_object_return_sum_str_values_list(func):
initial_counter = PyValueHolder.counter
for loop in range(100):
# Intentionally all temporaries, do not change.
assert func(WrapWithPyValueHolder(2, "three", -4.0)) == "2three-4.0"
# Intentionally all temporaries, do not change.
assert func(WrapWithPyValueHolder(2, "three", -4.0)) == "2three-4.0"
assert PyValueHolder.counter == initial_counter

Check failure on line 668 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_list[pass_array_pyobject_ptr_return_sum_str_values] AssertionError

Check failure on line 668 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_list[pass_array_handle_return_sum_str_values] AssertionError

Check failure on line 668 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_list[pass_array_object_return_sum_str_values] AssertionError

Check failure on line 668 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_list[pass_array_pyobject_ptr_return_sum_str_values] assert 12 == 9 + where 12 = PyValueHolder.counter

Check failure on line 668 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_list[pass_array_handle_return_sum_str_values] assert 15 == 12 + where 15 = PyValueHolder.counter

Check failure on line 668 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_sum_str_values_list[pass_array_object_return_sum_str_values] assert 18 == 15 + where 18 = PyValueHolder.counter

Check failure on line 668 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_pass_array_object_return_sum_str_values_list[pass_array_pyobject_ptr_return_sum_str_values] assert 12 == 9 + where 12 = PyValueHolder.counter

Check failure on line 668 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_pass_array_object_return_sum_str_values_list[pass_array_handle_return_sum_str_values] assert 15 == 12 + where 15 = PyValueHolder.counter

Check failure on line 668 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_pass_array_object_return_sum_str_values_list[pass_array_object_return_sum_str_values] assert 18 == 15 + where 18 = PyValueHolder.counter


Expand All @@ -680,11 +678,10 @@ def test_pass_array_object_return_sum_str_values_list(func):
)
def test_pass_array_object_return_as_list(func):
initial_counter = PyValueHolder.counter
for loop in range(100):
# Intentionally all temporaries, do not change.
assert UnwrapPyValueHolder(
func(np.array(WrapWithPyValueHolder(-1, "two", 3.0), dtype=object))
) == [-1, "two", 3.0]
# Intentionally all temporaries, do not change.
assert UnwrapPyValueHolder(
func(np.array(WrapWithPyValueHolder(-1, "two", 3.0), dtype=object))
) == [-1, "two", 3.0]
assert PyValueHolder.counter == initial_counter

Check failure on line 685 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_as_list[pass_array_pyobject_ptr_return_as_list] AssertionError

Check failure on line 685 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_as_list[pass_array_handle_return_as_list] AssertionError

Check failure on line 685 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_as_list[pass_array_object_return_as_list] AssertionError

Check failure on line 685 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_as_list[pass_array_pyobject_ptr_return_as_list] assert 21 == 18 + where 21 = PyValueHolder.counter

Check failure on line 685 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_as_list[pass_array_handle_return_as_list] assert 24 == 21 + where 24 = PyValueHolder.counter

Check failure on line 685 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_pass_array_object_return_as_list[pass_array_object_return_as_list] assert 27 == 24 + where 27 = PyValueHolder.counter

Check failure on line 685 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_pass_array_object_return_as_list[pass_array_pyobject_ptr_return_as_list] assert 21 == 18 + where 21 = PyValueHolder.counter

Check failure on line 685 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_pass_array_object_return_as_list[pass_array_handle_return_as_list] assert 24 == 21 + where 24 = PyValueHolder.counter

Check failure on line 685 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_pass_array_object_return_as_list[pass_array_object_return_as_list] assert 27 == 24 + where 27 = PyValueHolder.counter


Expand All @@ -701,11 +698,10 @@ def test_pass_array_object_return_as_list(func):
)
def test_return_array_object_cpp_loop(func):
initial_counter = PyValueHolder.counter
for loop in range(100):
# Intentionally all temporaries, do not change.
arr_from_list = func(WrapWithPyValueHolder(6, "seven", -8.0))
assert isinstance(arr_from_list, np.ndarray)
assert arr_from_list.dtype == np.dtype("O")
assert UnwrapPyValueHolder(arr_from_list) == [6, "seven", -8.0]
# Intentionally all temporaries, do not change.
arr_from_list = func(WrapWithPyValueHolder(6, "seven", -8.0))
assert isinstance(arr_from_list, np.ndarray)
assert arr_from_list.dtype == np.dtype("O")
assert UnwrapPyValueHolder(arr_from_list) == [6, "seven", -8.0]
del arr_from_list
assert PyValueHolder.counter == initial_counter

Check failure on line 707 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_return_array_object_cpp_loop[return_array_pyobject_ptr_cpp_loop] AssertionError

Check failure on line 707 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_return_array_object_cpp_loop[return_array_pyobject_ptr_cpp_loop] assert 30 == 27 + where 30 = PyValueHolder.counter

Check failure on line 707 in tests/test_numpy_array.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_return_array_object_cpp_loop[return_array_pyobject_ptr_cpp_loop] assert 30 == 27 + where 30 = PyValueHolder.counter

0 comments on commit 02eff18

Please sign in to comment.