Пример #1
0
class TestLogBase10(unittest.TestCase):

    def setUp(self):
        self.l = Logs()
        self.l.base_ln = mock

    def test_log_base10_zero(self):
        self.assertRaises(ValueError, self.l.log_base_10, 0)

    def test_log_base10_negative_result(self):
        self.assertAlmostEqual(self.l.log_base_10(0.3), -0.522879, 3)

    def test_log_base10_at_one(self):
        self.assertEqual(self.l.log_base_10(1), 0)

    def test_log_base10_at_two(self):
        self.assertAlmostEqual(self.l.log_base_10(2.3), 0.361727, 3)
Пример #2
0
class TestLogBase5(unittest.TestCase):

    def setUp(self):
            self.l = Logs()
            self.l.base_ln = mock

    def test_log_base5_zero(self):
        self.assertRaises(ValueError, self.l.log_base_5, 0)

    def test_log_base5_negative_result(self):
        self.assertAlmostEqual(self.l.log_base_5(0.2), -1, 3)

    def test_log_base5_at_one(self):
        self.assertEqual(self.l.log_base_5(1), 0)

    def test_log_base5_at_two(self):
        self.assertAlmostEqual(self.l.log_base_5(2.1), 0.460992, 3)
Пример #3
0
class TestLn(unittest.TestCase):

    def setUp(self):
        self.l = Logs()
        self.l.base_ln = mock

    def test_log_base5_zero(self):        
        self.assertRaises(ValueError, self.l.ln, 0)

    def test_log_base5_negative(self):
        self.assertRaises(ValueError, self.l.ln, -1)

    def test_log_base(self):
        self.assertAlmostEqual(self.l.ln(0.1), np.log(0.1), 3)

    def test_log_out_of_default_range(self):
        ''' this case checks invariant of the formula '''
        self.assertAlmostEqual(self.l.ln(10), np.log(10), 3)
Пример #4
0
 def test_log_base10_zero(self):
     self.assertRaises(ValueError, Logs().log_base_10, 0)
Пример #5
0
 def test_log_base5_at_two(self):
     self.assertAlmostEqual(Logs().log_base_5(2.1), 0.460992, 3)
Пример #6
0
 def test_log_base5_at_one(self):
     self.assertEqual(Logs().log_base_5(1), 0)
Пример #7
0
 def test_log_base5_negative_result(self):
     self.assertAlmostEqual(Logs().log_base_5(0.2), -1, 3)
Пример #8
0
 def test_log_base5_zero(self):
     with self.assertRaises(ValueError):
         Logs().log_base_5(0)
Пример #9
0
 def ln(self, x):
     return Logs().ln(x)
Пример #10
0
 def test_log_base10_at_two(self):
     self.assertAlmostEqual(Logs().log_base_10(2.3), 0.361727, 3)
Пример #11
0
 def test_log_base5_negative(self):
     self.assertRaises(ValueError, Logs().ln, -1)
Пример #12
0
from lab2.sin import sin
from lab2.ln import ln
from lab2.logs import Logs
from lab2.main import BigFunction
from lab2.dump import dump

if __name__ == '__main__':
    dump(sin, -1, 1, 0.1)
    dump(Logs().ln, 0.1, 1, 0.1)
    dump(Logs().log_base_5, 0.1, 1, 0.1)
    dump(Logs().log_base_10, 0.1, 1, 0.1)

    dump(BigFunction().calculate, -1, 1, 0.1)
    dump(ln, 0.1, 1, 0.1)
Пример #13
0
 def setUp(self):
     self.l = Logs()
     self.l.base_ln = mock
Пример #14
0
 def log_base_5(self, x):
     return Logs().log_base_5(x)
Пример #15
0
 def test_log_base10_negative_result(self):
     self.assertAlmostEqual(Logs().log_base_10(0.3), -0.522879, 3)
Пример #16
0
 def test_log_base(self):
     self.assertAlmostEqual(Logs().ln(0.1), np.log(0.1), 3)
Пример #17
0
 def test_log_base10_at_one(self):
     self.assertEqual(Logs().log_base_10(1), 0)
Пример #18
0
 def test_log_out_of_default_range(self):
     ''' this case checks invariant of the formula '''
     self.assertAlmostEqual(Logs().ln(10), np.log(10), 3)
Пример #19
0
 def test_log_base5_zero(self):
     self.assertRaises(ValueError, Logs().ln, 0)
Пример #20
0
 def log_base_10(self, x):
     return Logs().log_base_10(x)