Skip to content

Commit 933bc62

Browse files
committed
Input array now is not C-contiguous
1 parent 0d102a2 commit 933bc62

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pygmt/tests/test_clib_to_numpy.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,16 @@ def test_to_numpy_ndarray_numpy_dtypes_numeric(dtype, expected_dtype):
8585
8686
Test both 1-D and 2-D arrays.
8787
"""
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
9091
result = _to_numpy(array)
9192
_check_result(result, expected_dtype)
9293
npt.assert_array_equal(result, array, strict=True)
9394

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
9698
result = _to_numpy(array)
9799
_check_result(result, expected_dtype)
98100
npt.assert_array_equal(result, array, strict=True)
@@ -132,7 +134,7 @@ def test_to_numpy_pandas_series_numpy_dtypes_numeric(dtype, expected_dtype):
132134
"""
133135
Test the _to_numpy function with pandas.Series of NumPy numeric dtypes.
134136
"""
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
136138
result = _to_numpy(series)
137139
_check_result(result, expected_dtype)
138140
npt.assert_array_equal(result, series)

0 commit comments

Comments
 (0)