annotate tests/test_distance.py @ 83:1b61ce99ee82

derivative calculation: midpoint rule
author Jeff Hammel <k0scist@gmail.com>
date Sun, 17 Dec 2017 13:51:13 -0800
parents c05ce6b7f941
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
82
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 test distance calculations
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 import os
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import unittest
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 from tvii.distance import distance
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 class TestDistance(unittest.TestCase):
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 def test_triagle(self):
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 """a simple triangle"""
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 x = [0., 3.]
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 y = [4., 0.]
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 assert (distance(x, y) - 5.)**2 < 1e-6
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 if __name__ == '__main__':
c05ce6b7f941 test distance calculations
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 unittest.main()