From 88923ba0b5f87980647402850f121191787d5016 Mon Sep 17 00:00:00 2001 From: Jiafeng Liu Date: Mon, 18 Oct 2021 18:41:32 +0800 Subject: [PATCH] [Example] Fix the ti example problems of sparse matrix demos (#3215) * a quick solve * fix mass spring * remove sys * add todo and issue * fix typo --- examples/simulation/implicit_mass_spring.py | 2 +- examples/simulation/stable_fluid.py | 6 +++--- python/taichi/main.py | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/simulation/implicit_mass_spring.py b/examples/simulation/implicit_mass_spring.py index 3ab120f253649..27f23b7177c76 100644 --- a/examples/simulation/implicit_mass_spring.py +++ b/examples/simulation/implicit_mass_spring.py @@ -233,7 +233,7 @@ def displayGGUI(self, canvas, radius=0.01, color=(1.0, 1.0, 1.0)): '--use-ggui', action='store_true', help='Display with GGUI') - args = parser.parse_args() + args, unknowns = parser.parse_known_args() use_ggui = False use_ggui = args.use_ggui diff --git a/examples/simulation/stable_fluid.py b/examples/simulation/stable_fluid.py index eb159f8de7120..d0a8f293bd6ad 100644 --- a/examples/simulation/stable_fluid.py +++ b/examples/simulation/stable_fluid.py @@ -12,13 +12,13 @@ # How to run: # `python stable_fluid.py`: use the jacobi iteration to solve the linear system. -# `python stable_fluid.py -s`: use a sparse matrix to do so. +# `python stable_fluid.py -S`: use a sparse matrix to do so. parser = argparse.ArgumentParser() -parser.add_argument('-s', +parser.add_argument('-S', '--use-sp-mat', action='store_true', help='Solve Poisson\'s equation by using a sparse matrix') -args = parser.parse_args() +args, unknowns = parser.parse_known_args() res = 512 dt = 0.03 diff --git a/python/taichi/main.py b/python/taichi/main.py index f1886b75d9984..2b461059fdb09 100644 --- a/python/taichi/main.py +++ b/python/taichi/main.py @@ -180,6 +180,8 @@ def example(self, arguments: list = sys.argv[2:]): dest='save', action='store_true', help="Save source code to current directory instead of running it") + + # TODO: Pass the arguments to downstream correctly(#3216). args = parser.parse_args(arguments) examples_dir = TaichiMain._get_examples_dir()