@@ -629,64 +629,61 @@ def UnwrapPyValueHolder(vhs):
629
629
return [vh .value for vh in vhs ]
630
630
631
631
632
+ PASS_ARRAY_PYOBJECT_RETURN_SUM_STR_VALUES_FUNCTIONS = [
633
+ m .pass_array_pyobject_ptr_return_sum_str_values ,
634
+ m .pass_array_handle_return_sum_str_values ,
635
+ m .pass_array_object_return_sum_str_values ,
636
+ ]
637
+
638
+
632
639
@pytest .mark .parametrize (
633
- "func" ,
634
- [
635
- m .pass_array_pyobject_ptr_return_sum_str_values ,
636
- m .pass_array_handle_return_sum_str_values ,
637
- m .pass_array_object_return_sum_str_values ,
638
- ],
640
+ "pass_array" , PASS_ARRAY_PYOBJECT_RETURN_SUM_STR_VALUES_FUNCTIONS
639
641
)
640
- def test_pass_array_object_return_sum_str_values_ndarray (func ):
642
+ def test_pass_array_object_return_sum_str_values_ndarray (pass_array ):
641
643
# Intentionally all temporaries, do not change.
642
644
assert (
643
- func (np .array (WrapWithPyValueHolder (- 3 , "four" , 5.0 ), dtype = object ))
645
+ pass_array (np .array (WrapWithPyValueHolder (- 3 , "four" , 5.0 ), dtype = object ))
644
646
== "-3four5.0"
645
647
)
646
648
647
649
648
650
@pytest .mark .parametrize (
649
- "func" ,
650
- [
651
- m .pass_array_pyobject_ptr_return_sum_str_values ,
652
- m .pass_array_handle_return_sum_str_values ,
653
- m .pass_array_object_return_sum_str_values ,
654
- ],
651
+ "pass_array" , PASS_ARRAY_PYOBJECT_RETURN_SUM_STR_VALUES_FUNCTIONS
655
652
)
656
- def test_pass_array_object_return_sum_str_values_list (func ):
653
+ def test_pass_array_object_return_sum_str_values_list (pass_array ):
657
654
# Intentionally all temporaries, do not change.
658
- assert func (WrapWithPyValueHolder (2 , "three" , - 4.0 )) == "2three-4.0"
655
+ assert pass_array (WrapWithPyValueHolder (2 , "three" , - 4.0 )) == "2three-4.0"
659
656
660
657
661
658
@pytest .mark .parametrize (
662
- "func " ,
659
+ "pass_array " ,
663
660
[
664
661
m .pass_array_pyobject_ptr_return_as_list ,
665
662
m .pass_array_handle_return_as_list ,
666
663
m .pass_array_object_return_as_list ,
667
664
],
668
665
)
669
- def test_pass_array_object_return_as_list (func ):
666
+ def test_pass_array_object_return_as_list (pass_array ):
670
667
# Intentionally all temporaries, do not change.
671
668
assert UnwrapPyValueHolder (
672
- func (np .array (WrapWithPyValueHolder (- 1 , "two" , 3.0 ), dtype = object ))
669
+ pass_array (np .array (WrapWithPyValueHolder (- 1 , "two" , 3.0 ), dtype = object ))
673
670
) == [- 1 , "two" , 3.0 ]
674
671
675
672
676
673
@pytest .mark .parametrize (
677
- "func" ,
674
+ ( "return_array" , "unwrap" ) ,
678
675
[
679
- m .return_array_pyobject_ptr_cpp_loop ,
680
- m .return_array_handle_cpp_loop ,
681
- m .return_array_object_cpp_loop ,
682
- m .return_array_pyobject_ptr_from_list ,
683
- m .return_array_handle_from_list ,
684
- m .return_array_object_from_list ,
676
+ ( m .return_array_pyobject_ptr_cpp_loop , list ) ,
677
+ ( m .return_array_handle_cpp_loop , list ) ,
678
+ ( m .return_array_object_cpp_loop , list ) ,
679
+ ( m .return_array_pyobject_ptr_from_list , UnwrapPyValueHolder ) ,
680
+ ( m .return_array_handle_from_list , UnwrapPyValueHolder ) ,
681
+ ( m .return_array_object_from_list , UnwrapPyValueHolder ) ,
685
682
],
686
683
)
687
- def test_return_array_object_cpp_loop (func ):
684
+ def test_return_array_object_cpp_loop (return_array , unwrap ):
688
685
# Intentionally all temporaries, do not change.
689
- arr_from_list = func (WrapWithPyValueHolder (6 , "seven" , - 8.0 ))
686
+ arr_from_list = return_array (WrapWithPyValueHolder (6 , "seven" , - 8.0 ))
690
687
assert isinstance (arr_from_list , np .ndarray )
691
688
assert arr_from_list .dtype == np .dtype ("O" )
692
- assert UnwrapPyValueHolder (arr_from_list ) == [6 , "seven" , - 8.0 ]
689
+ assert unwrap (arr_from_list ) == [6 , "seven" , - 8.0 ]
0 commit comments