@@ -265,12 +265,7 @@ def _bilinear_sample(x, coords, mode, constant_value):
265265 wy = y - y0 .float ()
266266 wx = x_ - x0 .float ()
267267
268- out = (
269- Ia * (1 - wy ) * (1 - wx )
270- + Ib * (1 - wy ) * wx
271- + Ic * wy * (1 - wx )
272- + Id * wy * wx
273- )
268+ out = Ia * (1 - wy ) * (1 - wx ) + Ib * (1 - wy ) * wx + Ic * wy * (1 - wx ) + Id * wy * wx
274269
275270 if mode == "constant" :
276271 const = torch .full_like (out , constant_value )
@@ -377,6 +372,7 @@ def _affine_transform_local(x, M, order, mode, constant_value, expand):
377372# Public API (MPI-safe)
378373# ============================================================
379374
375+
380376def affine_transform (x , M , order = 0 , mode = "nearest" , constant_value = 0.0 , expand = False ):
381377 """
382378 Apply an affine transformation to a Heat array.
@@ -408,7 +404,6 @@ def is_translation():
408404 def is_axis_aligned_scaling ():
409405 return np .allclose (A , np .diag (np .diag (A )))
410406
411-
412407 if x .split is None :
413408 return _affine_transform_local (x , M , order , mode , constant_value , expand )
414409
@@ -417,33 +412,26 @@ def is_axis_aligned_scaling():
417412
418413 # Fast path: split on non-spatial axis → safe
419414 if x .split not in spatial_axes :
420- return _affine_transform_local (x , M , order , mode , constant_value , expand )
415+ return _affine_transform_local (x , M , order , mode , constant_value , expand )
421416
422-
423417 if is_translation ():
424418 # translation along spatial split requires full axis coverage
425419 x_tmp = x .resplit (None )
426- y_tmp = _affine_transform_local (
427- x_tmp , M , order , mode , constant_value , expand
428- )
420+ y_tmp = _affine_transform_local (x_tmp , M , order , mode , constant_value , expand )
429421 return y_tmp .resplit (x .split )
430422
431423 if is_axis_aligned_scaling ():
432424 # scaling still requires a non-spatial axis
433425 safe_axes = [ax for ax in range (x .ndim ) if ax not in spatial_axes ]
434426 if not safe_axes :
435427 raise NotImplementedError (
436- "Axis-aligned scaling on fully spatial arrays requires "
437- "a non-spatial axis"
428+ "Axis-aligned scaling on fully spatial arrays requires a non-spatial axis"
438429 )
439430 safe_axis = safe_axes [0 ]
440431 x_tmp = x .resplit (safe_axis )
441- y_tmp = _affine_transform_local (
442- x_tmp , M , order , mode , constant_value , expand
443- )
432+ y_tmp = _affine_transform_local (x_tmp , M , order , mode , constant_value , expand )
444433 return y_tmp .resplit (x .split )
445434
446-
447435 # Rotation / shear on spatial split → not supported
448436 raise NotImplementedError (
449437 "Affine transforms with axis mixing (rotation/shear) on spatially "
0 commit comments