Skip to content

Commit 0af0ddc

Browse files
leofangclaude
andcommitted
Unify strides assertion pattern across all _check_view methods
Use the same if/else pattern with `in (None, strides_in_counts)` in all three _check_view methods for consistency. Previously TestViewCPU and TestViewCudaArrayInterfaceGPU used a one-liner that was harder to read and behaved slightly differently. Verified locally: 66/66 tests pass across TestViewCPU, TestViewGPU, and TestViewCudaArrayInterfaceGPU (including all torch variants). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3969657 commit 0af0ddc

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

cuda_core/tests/test_utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ def _check_view(self, view, in_arr):
171171
assert view.shape == expected_shape
172172
assert view.size == _arr_size(in_arr)
173173
strides_in_counts = _arr_strides_in_counts(in_arr)
174-
assert (_arr_is_c_contiguous(in_arr) and view.strides is None) or view.strides == strides_in_counts
174+
if _arr_is_c_contiguous(in_arr):
175+
assert view.strides in (None, strides_in_counts)
176+
else:
177+
assert view.strides == strides_in_counts
175178
assert view.device_id == -1
176179
assert view.is_device_accessible is False
177180
assert view.exporting_obj is in_arr
@@ -348,7 +351,10 @@ def _check_view(self, view, in_arr, dev):
348351
assert view.shape == expected_shape
349352
assert view.size == _arr_size(in_arr)
350353
strides_in_counts = _arr_strides_in_counts(in_arr)
351-
assert (_arr_is_c_contiguous(in_arr) and view.strides is None) or view.strides == strides_in_counts
354+
if _arr_is_c_contiguous(in_arr):
355+
assert view.strides in (None, strides_in_counts)
356+
else:
357+
assert view.strides == strides_in_counts
352358
assert view.device_id == dev.device_id
353359
assert view.is_device_accessible is True
354360
assert view.exporting_obj is in_arr

0 commit comments

Comments
 (0)