From 7c3a3009479cd2644ceeb876226421d6231c96c0 Mon Sep 17 00:00:00 2001 From: DylanVsn <43576618+DylanVsn@users.noreply.github.com> Date: Wed, 29 Jan 2020 13:48:50 +0100 Subject: [PATCH] =?UTF-8?q?voil=C3=A0=20on=20peut=20mettre=20des=20fonctio?= =?UTF-8?q?ns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3/TP3_voisin.py | 13 +++++++++---- 3/__pycache__/argparse.cpython-38.pyc | Bin 759 -> 0 bytes 2 files changed, 9 insertions(+), 4 deletions(-) delete mode 100644 3/__pycache__/argparse.cpython-38.pyc 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 abb6b4080ec5f174e2b51ead9845a009433f9c73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 759 zcmZ8fJ#Q015Z$}8&lkr|AV^dci$r57=9HwNK!^xI86hDkTyWZW#`ePA?rA@g_$mt8 z{0FDxFKtUjPn8CCFA<5@)4tKXnRzoix{u@Wkc4ynsr>vqCFEyx?w>q3ufsLp0|0?U zkQu=Q(yyuhhGdgoky(b>rWb4<`#e1b+YpY{3w=FMEM0 z0yBa!4q*p&|1l5XA#TIoEt73VIKE0|JCJ-JlSjY8B;>>wRaG-CtEx?>yd6xZTsF?O z`<&cQ{FX&gPaYsk1OwP!dr|DAlxYrK?X-$I9qat7z0K8`NR6 znkq?kP*F8+5pKj6S_NM7C6`Q?kbx$2=-G9sxz&gGSU|znEoHTG(#8gs*GNy%o+C<% zY`*GRPIi64^s-^vVBDBwHCC11Io3;8qqOg1K>NH)(EbSnsA^{&6JlNA#auYU&#+o* z@qdw!(`u;*FX8o{h5i5=F1w8A}{2=;qSX&3z2jxoD zSPEQQRi5C5?G|6YJAPA|7iBGZX`Aw>4Aq_3^JeXfm$d>X@KyMEiFp>FNQ>m|OaJ8Q IF!>+<0%GRsX8-^I