@@ -99,26 +99,11 @@ def _compute_radial_coordinates(self, shape: tuple[int, ...], device: torch.devi
9999 coords = []
100100 for dim_size in shape :
101101 # Create frequency range from -0.5 to 0.5
102- # Compatible with older PyTorch versions
103- if hasattr (torch .fft , 'fftfreq' ):
104- freq = torch .fft .fftfreq (dim_size , device = device )
105- else :
106- # Fallback for older PyTorch versions (pre-1.8)
107- n = dim_size
108- val = 1.0 / n
109- freq = torch .arange (- (n // 2 ), (n + 1 )// 2 , device = device ) * val
110- freq = torch .roll (freq , n // 2 )
102+ freq = torch .fft .fftfreq (dim_size , device = device )
111103 coords .append (freq )
112104
113105 # Create meshgrid and compute radial distance
114- # Compatible with older PyTorch versions (pre-1.10)
115- try :
116- mesh = torch .meshgrid (coords , indexing = "ij" )
117- except TypeError :
118- # Older PyTorch doesn't support indexing parameter
119- mesh = torch .meshgrid (coords )
120- # Note: older meshgrid uses ij indexing by default in PyTorch
121-
106+ mesh = torch .meshgrid (coords , indexing = "ij" )
122107 radial = torch .sqrt (torch .stack ([c ** 2 for c in mesh ]).sum (dim = 0 ))
123108
124109 return radial
@@ -258,7 +243,7 @@ def inverse(self, radial_data: NdarrayOrTensor, original_shape: tuple[int, ...])
258243 Reconstructed spatial data.
259244
260245 Note:
261- This is an approximate inverse when radial_bins is used .
246+ Only exact inverse is supported ( radial_bins=None). Raises NotImplementedError otherwise .
262247 """
263248 if self .radial_bins is None :
264249 # Direct inverse FFT
0 commit comments