Skip to content

Commit

Permalink
added explicit unit tests for power_to_db
Browse files Browse the repository at this point in the history
added explicit unit tests for power_to_db
  • Loading branch information
bmcfee committed Dec 7, 2016
1 parent e7169ea commit 27655db
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def __test(x, ref_power, amin, top_db):
yield tf, x * phase, ref_power, amin, top_db


def test_power_to_db():
def test_power_to_db_logamp():

srand()

Expand All @@ -841,6 +841,18 @@ def test_power_to_db():
assert np.allclose(db1, db2)


def test_power_to_db():

def __test(y_true, x, rp):
y = librosa.power_to_db(x, ref_power=rp, top_db=None)

assert np.isclose(y, y_true)

for k in range(-5, 6):
for erp in range(-5, 6):
yield __test, (k-erp)*10, 10.0**k, 10.0**erp


def test_amplitude_to_db():

srand()
Expand All @@ -856,7 +868,7 @@ def test_amplitude_to_db():
assert np.allclose(db1, db2)


def test_db_to_power():
def test_db_to_power_inv():

srand()

Expand All @@ -871,6 +883,19 @@ def test_db_to_power():
assert np.allclose(xp, xp2)


def test_db_to_power():

def __test(x_true, y, rp):

x = librosa.db_to_power(y, ref_power=rp)

assert np.isclose(x, x_true), (y, x_true, rp)

for db in range(-100, 101, step=10):
for erp in range(-5, 6):
yield __test, 0, db, 10.0**erp


def test_db_to_amplitude():

srand()
Expand Down

0 comments on commit 27655db

Please sign in to comment.