@@ -85,14 +85,16 @@ def test_to_numpy_ndarray_numpy_dtypes_numeric(dtype, expected_dtype):
85
85
86
86
Test both 1-D and 2-D arrays.
87
87
"""
88
- # 1-D array
89
- array = np .array ([1 , 2 , 3 ], dtype = dtype )
88
+ # 1-D array that is not C-contiguous
89
+ array = np .array ([1 , 2 , 3 , 4 , 5 , 6 ], dtype = dtype )[::2 ]
90
+ assert array .flags .c_contiguous is False
90
91
result = _to_numpy (array )
91
92
_check_result (result , expected_dtype )
92
93
npt .assert_array_equal (result , array , strict = True )
93
94
94
- # 2-D array
95
- array = np .array ([[1 , 2 , 3 ], [4 , 5 , 6 ]], dtype = dtype )
95
+ # 2-D array that is not C-contiguous
96
+ array = np .array ([[1 , 2 , 3 , 4 ], [5 , 6 , 7 , 8 ]], dtype = dtype )[::2 , ::2 ]
97
+ assert array .flags .c_contiguous is False
96
98
result = _to_numpy (array )
97
99
_check_result (result , expected_dtype )
98
100
npt .assert_array_equal (result , array , strict = True )
@@ -132,7 +134,7 @@ def test_to_numpy_pandas_series_numpy_dtypes_numeric(dtype, expected_dtype):
132
134
"""
133
135
Test the _to_numpy function with pandas.Series of NumPy numeric dtypes.
134
136
"""
135
- series = pd .Series ([1 , 2 , 3 ], dtype = dtype )
137
+ series = pd .Series ([1 , 2 , 3 , 4 , 5 , 6 ], dtype = dtype )[:: 2 ] # Not C-contiguous
136
138
result = _to_numpy (series )
137
139
_check_result (result , expected_dtype )
138
140
npt .assert_array_equal (result , series )
0 commit comments