Permalink
Browse files

update unit test on tsp

  • Loading branch information...
sdpython committed Feb 22, 2017
1 parent 786e44f commit 3569c171252d2bdf509eef38dc91708105ce808a
Showing with 12 additions and 3 deletions.
  1. +11 −2 _unittests/ut_algorithm/test_tsp.py
  2. +1 −1 src/code_beatrix/algorithm/tsp.py
@@ -38,6 +38,7 @@
import pyquickhelper as skip_
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import fix_tkinter_issues_virtualenv, get_temp_folder
from src.code_beatrix.algorithm import voyageur_commerce_simple, distance_circuit, plot_circuit
@@ -71,10 +72,18 @@ def test_voyageur_commerce_simple(self):
fLOG(d0, d1)
assert d1 < d0
fix_tkinter_issues_virtualenv(fLOG=fLOG)
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1)
plot_circuit(newp, ax=ax)
temp = get_temp_folder(__file__, "temp_voyageur_commerce_simple")
img = os.path.join(temp, "tsp.png")
fig.savefig(img)
assert os.path.exists(img)
if __name__ == "__main__":
import matplotlib.pyplot as plt
plot_circuit(newp)
plt.show()
plt.close("all")
if __name__ == "__main__":
@@ -4,7 +4,6 @@
"""
import random
import matplotlib.pyplot as plt
def distance_point(p1, p2):
@@ -121,6 +120,7 @@ def plot_circuit(points, ax=None, **kwargs):
@return ax
"""
if ax is None:
import matplotlib.pyplot as plt
f, ax = plt.subplots(**kwargs)
ax.plot([_[0] for _ in points], [_[1] for _ in points], "o")

0 comments on commit 3569c17

Please sign in to comment.