Skip to content

Commit 3c4d1c4

Browse files
committed
add test for circle_fitting
1 parent 17b87c0 commit 3c4d1c4

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

Mapping/circle_fitting/circle_fitting.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import random
1313
import numpy as np
1414

15+
show_animation = True
16+
1517

1618
def circle_fitting(x, y):
1719
"""
@@ -120,15 +122,17 @@ def main():
120122
ex, ey, er, error = circle_fitting(x, y)
121123
print("Error:", error)
122124

123-
plt.cla()
124-
plt.axis("equal")
125-
plt.plot(0.0, 0.0, "*r")
126-
plot_circle(cx, cy, cr)
127-
plt.plot(x, y, "xr")
128-
plot_circle(ex, ey, er, "-r")
129-
plt.pause(dt)
125+
if show_animation:
126+
plt.cla()
127+
plt.axis("equal")
128+
plt.plot(0.0, 0.0, "*r")
129+
plot_circle(cx, cy, cr)
130+
plt.plot(x, y, "xr")
131+
plot_circle(ex, ey, er, "-r")
132+
plt.pause(dt)
133+
134+
print("Done")
130135

131136

132137
if __name__ == '__main__':
133-
# main1()
134138
main()

tests/test_circle_fitting.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from unittest import TestCase
2+
3+
from Mapping.circle_fitting import circle_fitting as m
4+
5+
print(__file__)
6+
7+
8+
class Test(TestCase):
9+
10+
def test1(self):
11+
m.show_animation = False
12+
m.main()

0 commit comments

Comments
 (0)