@@ -116,12 +116,12 @@ def time_frequency(
116116
117117 # Default value for length
118118 if length is None :
119- length = int (times [ - 1 , 1 ] * fs )
119+ length = int (np . max ( times ) * fs )
120120
121121 last_time_in_secs = float (length ) / fs
122122
123123 if time_converted and times .shape [0 ] != gram .shape [1 ]:
124- times = np .vstack ((times , [times [ - 1 , 1 ] , last_time_in_secs ]))
124+ times = np .vstack ((times , [np . max ( times ) , last_time_in_secs ]))
125125
126126 if times .shape [0 ] != gram .shape [1 ]:
127127 raise ValueError (
@@ -183,15 +183,14 @@ def time_frequency(
183183 bounds_error = False ,
184184 fill_value = (gram [:, 0 ], gram [:, - 1 ]),
185185 )
186+ signal = interpolator (np .arange (length ))
186187 else :
187188 # NOTE: This is a special case where there is only one time interval.
188189 # scipy 1.10 and above handle this case directly with the interp1d above,
189190 # but older scipy's do not. This is a workaround for that.
190191 #
191192 # In the 0.9 release, we can bump the minimum scipy to 1.10 and remove this
192- interpolator = _const_interpolator (gram [:, 0 ])
193-
194- signal = interpolator (np .arange (length ))
193+ signal = np .tile (gram [:, 0 ], (1 , length ))
195194
196195 for n , frequency in enumerate (frequencies ):
197196 # Get a waveform of length samples at this frequency
@@ -213,17 +212,6 @@ def time_frequency(
213212 return output
214213
215214
216- def _const_interpolator (value ):
217- """Return a function that returns `value`
218- no matter the input.
219- """
220-
221- def __interpolator (x ):
222- return value
223-
224- return __interpolator
225-
226-
227215def _fast_synthesize (frequency , n_dec , fs , function , length ):
228216 """Efficiently synthesize a signal.
229217 Generate one cycle, and simulate arbitrary repetitions
0 commit comments