@@ -116,12 +116,12 @@ def time_frequency(
116
116
117
117
# Default value for length
118
118
if length is None :
119
- length = int (times [ - 1 , 1 ] * fs )
119
+ length = int (np . max ( times ) * fs )
120
120
121
121
last_time_in_secs = float (length ) / fs
122
122
123
123
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 ]))
125
125
126
126
if times .shape [0 ] != gram .shape [1 ]:
127
127
raise ValueError (
@@ -183,15 +183,14 @@ def time_frequency(
183
183
bounds_error = False ,
184
184
fill_value = (gram [:, 0 ], gram [:, - 1 ]),
185
185
)
186
+ signal = interpolator (np .arange (length ))
186
187
else :
187
188
# NOTE: This is a special case where there is only one time interval.
188
189
# scipy 1.10 and above handle this case directly with the interp1d above,
189
190
# but older scipy's do not. This is a workaround for that.
190
191
#
191
192
# 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 ))
195
194
196
195
for n , frequency in enumerate (frequencies ):
197
196
# Get a waveform of length samples at this frequency
@@ -213,17 +212,6 @@ def time_frequency(
213
212
return output
214
213
215
214
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
-
227
215
def _fast_synthesize (frequency , n_dec , fs , function , length ):
228
216
"""Efficiently synthesize a signal.
229
217
Generate one cycle, and simulate arbitrary repetitions
0 commit comments