Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window/Unwindow #44

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
fixed pytest errors
abruns123 committed Nov 8, 2024
commit ae352feb32e576b0cb31c81bb04f9754e5760694
33 changes: 23 additions & 10 deletions test_preparation.py
Original file line number Diff line number Diff line change
@@ -15,12 +15,13 @@
f1, f2 = 50, 120
data = pd.Series(np.sin(f1*t)+0.5*np.sin(f2*t),index=range(0,len(t)))
# index_values = data.index.tolist()
"""
freq = calc_freq(data)
print(freq)
print(inv_fft(data))
print(data)
plot_rets(freq,fft(data))

"""

t = np.linspace(0, 2, 2000, endpoint=False)
f1, f2 = 50, 120
@@ -29,38 +30,46 @@
#trange = date_range(datetime.now(), datetime.now()+pd.timedelta(days=9),freq='d')
#trange[i].timestamp()


"""
def test_fft(data):
magnitudes = fft(data)
from preparation import fft_powerspectrum, fft_mag, inv_fft, calc_freq
import pytest

"""
"""
@pytest.fixture
"""
def data():
trange = pd.date_range(datetime.now(), datetime.now() + timedelta(days=9), freq='d')
return pd.Series([1, 2, 3, 2, 1, 2, 3, 2, 1, 2], index=trange)

"""
def test_fft_powerspectrum(data):
"""
"""
test the powerspectrums length and type of export
"""
"""
powrspec = fft_powerspectrum(data)
assert len(powrspec) == len(data)/2
assert isinstance(powrspec, np.ndarray)

def test_fft_mag(data):
"""
"""
test the fft_mag length and type of export
"""
"""
magnitudes = fft_mag(data)
assert len(magnitudes) == len(data)
assert isinstance(magnitudes, np.ndarray)

def test_inv_fft(data):
"""
"""
tests inv_fft length export aswell as testing to see if
the fit matches the data
"""
"""
invdata = inv_fft(fft_mag(data))
assert len(invdata) == len(data)
assert np.allclose(invdata, data.values, atol=1e-4)
@@ -69,15 +78,15 @@ def test_inv_fft(data):
trange = pd.date_range(datetime.now(), datetime.now()+timedelta(days=9),freq='d')
data1 = pd.Series([1,2,3,4,5,6,7,8,9,10],index=trange)



"""
"""
print(len(data1))

print(data1.index[0].timestamp())


print(data1.iloc[2] * 1)

"""


def test_window():
@@ -138,9 +147,13 @@ def test_unwindow():
for i in test_func:
assert round(i,3)==round(new.values[count],3)
count+=1

"""
def test_calc_freq(data):
"""calcs the length of the export of calc_freq"""
"""
"""
calcs the length of the export of calc_freq
"""
"""
freq = calc_freq(data, 'seconds')
assert len(freq) == len(data)

"""