@@ -89,17 +89,33 @@ def _apply_device_constraints(self, dtype):
8989 return dtype
9090
9191 def arange (self , * args , ** kwargs ):
92- # torch.arange args are slightly different if only one arg is passed?
93- # range(start, end, step) vs arange(end).
94- # torch.arange([start=0], end, [step=1]) similar to numpy.
92+ # Default to int64 for integer args, but if float args, torch.arange might default to float32.
93+ # NumPy behavior: if args are ints, return int/int64. If oats, return float64.
94+ # For simplicity and given pPXF usage (often for indices or float ranges),
95+ # let's rely on torch's inference but ensuring floats are float64 if device supports it.
96+ # However, torch.arange(float) -> float32 by default.
97+ # We should check args.
98+
99+ dtype = kwargs .get ('dtype' )
100+ if dtype is None :
101+ # Check if any arg is float
102+ is_float = any (isinstance (a , float ) for a in args )
103+ if is_float :
104+ dtype = float
105+
106+ if dtype is not None :
107+ kwargs ['dtype' ] = self ._get_dtype (dtype )
108+
95109 return torch .arange (* args , device = self .device , ** kwargs )
96110
97111 def linspace (self , start , end , steps , ** kwargs ):
112+ # Default to float64
113+ dtype = kwargs .get ('dtype' , float )
114+ kwargs ['dtype' ] = self ._get_dtype (dtype )
98115 return torch .linspace (start , end , steps , device = self .device , ** kwargs )
99116
100117 def array (self , object , dtype = None , copy = True , order = 'K' , subok = False , ndmin = 0 ):
101118 # Limited implementation of np.array
102- # copy, order, subok, ndmin ignored for now
103119 return self .asarray (object , dtype = dtype )
104120
105121 def append (self , arr , values , axis = None ):
0 commit comments