Question: Attempting this solution, I get the following assertion error: - - - - - - - - - - - - - - - -

Attempting this solution, I get the following assertion error:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
in
34 # TODO: Redefine the three lists using the select_all_items function
35 # your code here
--->36 upto_1_year = select_all_items_in_freq_range(0,1/52)
37 one_year_to_1_quarter = select_all_items_in_freq_range(1/52,1/13)
38 less_than_1_quarter = select_all_items_in_freq_range(1/13, float('inf'))
in select_all_items_in_freq_range(lo, hi)
25 new_fft_data.append(0.0)
26 filtered_data = ifft(new_fft_data)
--->27 assert all( abs(imag(x))<=1E-10 for x in filtered_data)
28 return [real(x) for x in filtered_data]
29
AssertionError:
I also get the following assertion error on the plotting portion:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
in
27 N = len(weekly_prices)
28 assert(len(fft_frequencies)== len(weekly_prices))
--->29 assert(fft_frequencies[0]==0.0)
30 assert(abs(fft_frequencies[N//2]-0.5)<=0.05), f'fft frequncies incorrect: {fft_frequencies[N//2]} does not equal 0.5'
31 assert(abs(fft_frequencies[N//4]-0.25)<=0.05), f'fft frequncies incorrect: {fft_frequencies[N//4]} does not equal 0.25'
AssertionError:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!