Fix math function tests
@@ -4,7 +4,7 @@ import unittest
import numpy as npy
from numpy import e, log, pi, isnan, inf
from numpy.testing import assert_equal, run_module_suite, assert_almost_equal
-
+import pytest
class TestUnitConversions(unittest.TestCase):
"""
@@ -67,7 +67,9 @@ class TestUnitConversions(unittest.TestCase):
assert_almost_equal(rf.magnitude_2_db(10, True), 20)
assert_almost_equal(rf.magnitude_2_db(10, False), 20)
+ with pytest.warns(RuntimeWarning, match="divide by zero"):
assert_almost_equal(rf.magnitude_2_db(0), -inf)
+ with pytest.warns(RuntimeWarning, match="invalid value encountered in log10"):
assert_almost_equal(rf.magnitude_2_db(-1, True), LOG_OF_NEG)
assert_almost_equal(rf.magnitude_2_db([10, -1], True), [20, LOG_OF_NEG])
self.assertTrue(isnan(rf.magnitude_2_db(-1, False)))
@@ -82,7 +84,9 @@ class TestUnitConversions(unittest.TestCase):
assert_almost_equal(rf.mag_2_db10(10, True), 10)
assert_almost_equal(rf.mag_2_db10(10, False), 10)
+ with pytest.warns(RuntimeWarning, match="divide by zero"):
assert_almost_equal(rf.magnitude_2_db(0), -inf)
+ with pytest.warns(RuntimeWarning, match="invalid value encountered in log10"):
assert_almost_equal(rf.mag_2_db10(-1, True), LOG_OF_NEG)
assert_almost_equal(rf.mag_2_db10([10, -1], True), [10, LOG_OF_NEG])
self.assertTrue(isnan(rf.mag_2_db10(-1, False)))
