diff --git a/3/TP3_voisin.py b/3/TP3_voisin.py index 7a1f6b7..1c586aa 100755 --- a/3/TP3_voisin.py +++ b/3/TP3_voisin.py @@ -137,8 +137,13 @@ def animation_nuage(l_pts, loops=10, time_sleep=2, delta_bruit=3): def main(argv): parser = argparse.ArgumentParser() gps = parser.add_mutually_exclusive_group(required=True) - parser.add_argument("-i", "--input", + gpi = parser.add_mutually_exclusive_group(required=True) + gpi.add_argument("-i", "--input", help="input file for dots - if none, generate dots") + gpi.add_argument("-f", "--function", + help="function to use to generate dots, ex -f 3*x+4") + parser.add_argument("-N", "--nb-dots", type=int, default=500, + help="number of dots to generate (from 0 to NB_DOTS) from function") gps.add_argument("-s", "--show", action="store_true", help="show cloud of dots with u1 and u2") gps.add_argument("-l", "--loop", type=int, default=10, @@ -159,9 +164,9 @@ def main(argv): l_pts = acquérir_depuis_fichier(args.input) else: l_pts = [] - n = 500 # nombre de points - f = lambda x: x/2 + 3 # fonction génératrice de la ditribution - delta_bruit = 10 # bruit généré, 0 si on en veut aucun + n = args.nb_dots # nombre de points + f = lambda x: eval(args.function) # fonction génératrice de la ditribution + delta_bruit = 0 # bruit généré, 0 si on en veut aucun for i in range(n): y = f(i) + choice((-1, 1)) * random() * delta_bruit/2 l_pts.append([i, y]) diff --git a/3/__pycache__/argparse.cpython-38.pyc b/3/__pycache__/argparse.cpython-38.pyc deleted file mode 100644 index abb6b40..0000000 Binary files a/3/__pycache__/argparse.cpython-38.pyc and /dev/null differ