view tests/test_derivative.py @ 87:9d5a5e9f5c3b

add kmeans + dataset
author Jeff Hammel <k0scist@gmail.com>
date Sun, 17 Dec 2017 14:05:57 -0800
parents 1b61ce99ee82
children
line wrap: on
line source

#!/usr/bin/env python

import os
import shutil
import tempfile
import unittest
from tvii import derivative

class TestDerivatives(unittest.TestCase):

    def test_midpoint(self):
        def cube(x):
            return x**3

        exact = 3
        expected = 3.0001
        got = derivative.midpoint(cube, 1, 0.01)
        assert abs(expected - got) < 1e-6, "Expected {}; got {}".format(expected, got)

if __name__ == '__main__':
    unittest.main()