Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions jazzhands/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,18 @@
from jazzhands import utils


def test_phi_1():
"""Test to make sure the output is an array of ones"""
phi1 = utils.phi_1([1, 2, 3], 3, 10)
expected = np.array([1., 1., 1.])
assert np.allclose(phi1, expected)
class TestUtils(object):
def test_phi_1(self):
phi1 = utils.phi_1(np.arange(1, 4), 3, 10)
expected = np.array([1., 1., 1.])
assert np.allclose(phi1, expected)

def test_phi_2(self):
phi2 = utils.phi_2(np.arange(1, 4), 3, 10)
expected = np.array([1., -0.99, 0.96])
assert pytest.approx(phi2, expected)

def test_phi_2():
"""Test to make sure the function output gives an approximate expected result"""
time = np.array([1, 2, 3])
phi2 = utils.phi_2(time, 3, 10)
expected = np.array([1., -0.99, 0.96])
assert pytest.approx(phi2, expected)


def test_phi_3():
"""Test to make sure the function output gives an approximate expected result"""
time = np.array([1, 2, 3])
phi3 = utils.phi_3(time, 3, 10)
expected = np.array([0., 0.14, -0.28])
assert pytest.approx(phi3, expected)
def test_phi_3(self):
phi3 = utils.phi_3(np.arange(1, 4), 3, 10)
expected = np.array([0., 0.14, -0.28])
assert pytest.approx(phi3, expected)
36 changes: 14 additions & 22 deletions jazzhands/tests/test_wavelets.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
import os
import shutil
import unittest
import numpy as np
import pytest

from jazzhands import wavelets


class WaveletsTest(unittest.TestCase):

def setUp(self):
self.outdir = "test"
os.makedirs(self.outdir, exist_ok=True)

def tearDown(self):
if os.path.exists(self.outdir):
shutil.rmtree(self.outdir)

class TestWavelets(object):
def test_correct_constructor(self):
wavelets.WaveletTransformer(func_list=[0, 0], f1=[0, 0], data=[0, 0],
time=[0, 0], omegas=[0, 0], taus=[0, 0], c=0.0125)
wavelets.WaveletTransformer(func_list=[0, 0], f1=[0, 0], counts=[0, 0],
time=[0, 0], omegas=[10, 10], taus=[0, 0], c=0.0125)

# def test_omegas_taus_from_min_max_nu(self):
# wav = wavelets.WaveletTransformer(func_list=[0, 0], f1=[0, 0], data=[0, 0], time=[0, 0], omegas=[0, 0], taus=[0, 0], c=0.0125)
def test_incorrect_constructor(self):
with pytest.raises(TypeError) as excinfo:
wavelets.WaveletTransformer(func_list=[0, 0], f1=[0, 0], counts=[0, 0], time=[0, 0], omegas="hello", taus="blah", c=0.0125)
assert str(excinfo.value)

# res = wav.auto_compute(1, 1, 1, 1, 1, 1)
# self.assertIsNotNone(res)
# self.assertIsInstance(res[0], np.ndarray)
def test_omegas_taus_from_min_max_nu(self):
wav = wavelets.WaveletTransformer(func_list=[0, 0], f1=[0, 0], counts=[0, 0], time=[0, 0], omegas=[10, 10], taus=[0, 0], c=0.0125)

res = wav._omegas_taus_from_min_max_nu(1, 1, 1, 1)

if __name__ == '__main__':
unittest.main()
assert res is not None
assert isinstance((res[0] and res[1]), np.ndarray)
Loading