Skip to content

Commit 152a3ed

Browse files
committed
change variable names throughout _copy_utils
more consistent with style
1 parent 5b4ae4a commit 152a3ed

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

dpctl/tensor/_copy_utils.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -349,19 +349,19 @@ def _copy_from_usm_ndarray_to_usm_ndarray(dst, src):
349349
_copy_same_shape(dst, src_same_shape)
350350

351351

352-
def _make_empty_like_orderK(X, dt, usm_type, dev):
352+
def _make_empty_like_orderK(x, dt, usm_type, dev):
353353
"""
354-
Returns empty array with shape and strides like `X`, with dtype `dt`,
354+
Returns empty array with shape and strides like `x`, with dtype `dt`,
355355
USM type `usm_type`, on device `dev`.
356356
"""
357-
st = list(X.strides)
357+
st = list(x.strides)
358358
perm = sorted(
359-
range(X.ndim),
360-
key=lambda d: builtins.abs(st[d]) if X.shape[d] > 1 else 0,
359+
range(x.ndim),
360+
key=lambda d: builtins.abs(st[d]) if x.shape[d] > 1 else 0,
361361
reverse=True,
362362
)
363-
inv_perm = sorted(range(X.ndim), key=lambda i: perm[i])
364-
sh = X.shape
363+
inv_perm = sorted(range(x.ndim), key=lambda i: perm[i])
364+
sh = x.shape
365365
sh_sorted = tuple(sh[i] for i in perm)
366366
R = dpt.empty(sh_sorted, dtype=dt, usm_type=usm_type, device=dev, order="C")
367367
if min(st) < 0:
@@ -372,58 +372,58 @@ def _make_empty_like_orderK(X, dt, usm_type, dev):
372372
if st_sorted[i] < 0
373373
else slice(None, None, None)
374374
)
375-
for i in range(X.ndim)
375+
for i in range(x.ndim)
376376
)
377377
R = R[sl]
378378
return dpt.permute_dims(R, inv_perm)
379379

380380

381-
def _empty_like_orderK(X, dt, usm_type=None, dev=None):
381+
def _empty_like_orderK(x, dt, usm_type=None, dev=None):
382382
"""
383383
Returns empty array like `x`, using order='K'
384384
385385
For an array `x` that was obtained by permutation of a contiguous
386386
array the returned array will have the same shape and the same
387387
strides as `x`.
388388
"""
389-
if not isinstance(X, dpt.usm_ndarray):
390-
raise TypeError(f"Expected usm_ndarray, got {type(X)}")
389+
if not isinstance(x, dpt.usm_ndarray):
390+
raise TypeError(f"Expected usm_ndarray, got {type(x)}")
391391
if usm_type is None:
392-
usm_type = X.usm_type
392+
usm_type = x.usm_type
393393
if dev is None:
394-
dev = X.device
395-
fl = X.flags
396-
if fl["C"] or X.size <= 1:
394+
dev = x.device
395+
fl = x.flags
396+
if fl["C"] or x.size <= 1:
397397
return dpt.empty_like(
398-
X, dtype=dt, usm_type=usm_type, device=dev, order="C"
398+
x, dtype=dt, usm_type=usm_type, device=dev, order="C"
399399
)
400400
elif fl["F"]:
401401
return dpt.empty_like(
402-
X, dtype=dt, usm_type=usm_type, device=dev, order="F"
402+
x, dtype=dt, usm_type=usm_type, device=dev, order="F"
403403
)
404-
return _make_empty_like_orderK(X, dt, usm_type, dev)
404+
return _make_empty_like_orderK(x, dt, usm_type, dev)
405405

406406

407-
def _from_numpy_empty_like_orderK(X, dt, usm_type, dev):
407+
def _from_numpy_empty_like_orderK(x, dt, usm_type, dev):
408408
"""
409409
Returns empty usm_ndarray like NumPy array `x`, using order='K'
410410
411411
For an array `x` that was obtained by permutation of a contiguous
412412
array the returned array will have the same shape and the same
413413
strides as `x`.
414414
"""
415-
if not isinstance(X, np.ndarray):
416-
raise TypeError(f"Expected numpy.ndarray, got {type(X)}")
417-
fl = X.flags
418-
if fl["C"] or X.size <= 1:
415+
if not isinstance(x, np.ndarray):
416+
raise TypeError(f"Expected numpy.ndarray, got {type(x)}")
417+
fl = x.flags
418+
if fl["C"] or x.size <= 1:
419419
return dpt.empty(
420-
X.shape, dtype=dt, usm_type=usm_type, device=dev, order="C"
420+
x.shape, dtype=dt, usm_type=usm_type, device=dev, order="C"
421421
)
422422
elif fl["F"]:
423423
return dpt.empty(
424-
X.shape, dtype=dt, usm_type=usm_type, device=dev, order="F"
424+
x.shape, dtype=dt, usm_type=usm_type, device=dev, order="F"
425425
)
426-
return _make_empty_like_orderK(X, dt, usm_type, dev)
426+
return _make_empty_like_orderK(x, dt, usm_type, dev)
427427

428428

429429
def _empty_like_pair_orderK(X1, X2, dt, res_shape, usm_type, dev):
@@ -763,7 +763,7 @@ def _extract_impl(ary, ary_mask, axis=0):
763763
if exec_q is None:
764764
raise dpctl.utils.ExecutionPlacementError(
765765
"arrays have different associated queues. "
766-
"Use `Y.to_device(X.device)` to migrate."
766+
"Use `y.to_device(x.device)` to migrate."
767767
)
768768
ary_nd = ary.ndim
769769
pp = normalize_axis_index(operator.index(axis), ary_nd)

0 commit comments

Comments
 (0)