diff --git a/tests/python/examples/__init__.py b/tests/python/examples/__init__.py deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/tests/python/examples/algorithm/test_laplace.py b/tests/python/examples/algorithm/test_laplace.py deleted file mode 100644 index aae9b9aeb21ff..0000000000000 --- a/tests/python/examples/algorithm/test_laplace.py +++ /dev/null @@ -1,16 +0,0 @@ -import os - -import pytest - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_laplace(): - from taichi.examples.algorithm.laplace import laplace, x, y - - for i in range(10): - x[i, i + 1] = 1.0 - - laplace() - - for i in range(10): - assert y[i, i + 1] == (4.0 if i % 3 == 1 else 0.0) diff --git a/tests/python/examples/algorithm/test_print_offset.py b/tests/python/examples/algorithm/test_print_offset.py deleted file mode 100644 index 3490e9dc7ee14..0000000000000 --- a/tests/python/examples/algorithm/test_print_offset.py +++ /dev/null @@ -1,58 +0,0 @@ -import argparse -import os - -import pytest -from taichi.lang import impl - -import taichi as ti - -FRAMES = 100 - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_print_offset(): - from taichi.examples.algorithm.print_offset import fill - fill() - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def video_print_offset(result_dir): - from taichi.examples.algorithm.print_offset import a, fill, m, n - video_manager = ti.tools.VideoManager(output_dir=result_dir, - framerate=24, - automatic_build=False) - - fill() - - gui = ti.GUI('layout', - res=(256, 512), - background_color=0xFFFFFF, - show_gui=False) - - for f in range(FRAMES): - for i in range(1, m): - gui.line(begin=(0, i / m), - end=(1, i / m), - radius=2, - color=0x000000) - for i in range(1, n): - gui.line(begin=(i / n, 0), - end=(i / n, 1), - radius=2, - color=0x000000) - for i in range(n): - for j in range(m): - gui.text(f'{a[i, j]}', ((i + 0.3) / n, (j + 0.75) / m), - font_size=30, - color=0x0) - video_manager.write_frame(gui.get_image()) - gui.clear() - - video_manager.make_video(mp4=True, gif=False) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Generate print_offset video') - parser.add_argument('output_directory', - help='output directory of generated video') - video_print_offset(parser.parse_args().output_directory) diff --git a/tests/python/examples/autodiff/__init__.py b/tests/python/examples/autodiff/__init__.py deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/tests/python/examples/autodiff/test_minimization.py b/tests/python/examples/autodiff/test_minimization.py deleted file mode 100644 index 38d8970a7d4b5..0000000000000 --- a/tests/python/examples/autodiff/test_minimization.py +++ /dev/null @@ -1,24 +0,0 @@ -import os -import random - -import pytest - -import taichi as ti - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_minimization(): - from taichi.examples.autodiff.minimization import (L, gradient_descent, n, - reduce, x, y) - - for i in range(n): - x[i] = random.random() - y[i] = random.random() - - for k in range(100): - with ti.ad.Tape(loss=L): - reduce() - gradient_descent() - - for i in range(n): - assert x[i] == pytest.approx(y[i], rel=1e-2) diff --git a/tests/python/examples/autodiff/test_regression.py b/tests/python/examples/autodiff/test_regression.py deleted file mode 100644 index 28b49b1433248..0000000000000 --- a/tests/python/examples/autodiff/test_regression.py +++ /dev/null @@ -1,54 +0,0 @@ -import argparse -import os - -import pytest - -from tests import test_utils - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_regression(): - from taichi.examples.autodiff.regression import initialize, regress_raw - initialize() - regress_raw() - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def pic_regression(result_dir): - import numpy as np - from matplotlib import pyplot as plt - from taichi.examples.autodiff.regression import (coeffs, initialize, - number_coeffs, - regress_raw, xs, ys) - - initialize() - regress_raw() - - curve_xs = np.arange(-2.5, 2.5, 0.01) - curve_ys = curve_xs * 0 - for i in range(number_coeffs): - curve_ys += coeffs[i] * np.power(curve_xs, i) - - plt.title( - 'Nonlinear Regression with Gradient Descent (3rd order polynomial)') - ax = plt.gca() - ax.scatter(xs, ys, label='data', color='r') - ax.plot(curve_xs, curve_ys, label='fitted') - ax.legend() - ax.grid(True) - ax.spines['left'].set_position('zero') - ax.spines['right'].set_color('none') - ax.spines['bottom'].set_position('zero') - ax.spines['top'].set_color('none') - print(result_dir + '/output.png') - - # Create new directory - test_utils.mkdir_p(result_dir) - plt.savefig(result_dir + '/output.png') - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Generate regression pic') - parser.add_argument('output_directory', - help='output directory of generated pic') - pic_regression(parser.parse_args().output_directory) diff --git a/tests/python/examples/autodiff/test_simple_derivative.py b/tests/python/examples/autodiff/test_simple_derivative.py deleted file mode 100644 index 7e4b84a582ce6..0000000000000 --- a/tests/python/examples/autodiff/test_simple_derivative.py +++ /dev/null @@ -1,45 +0,0 @@ -import argparse -import os - -import pytest - -from tests import test_utils - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_simple_derivative(): - from taichi.examples.autodiff.simple_derivative import initialize - - initialize() - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def pic_simple_derivative(result_dir): - from matplotlib import pyplot as plt - from taichi.examples.autodiff.simple_derivative import (grad_xs, - initialize, xs, ys) - - initialize() - - plt.title('Auto Diff') - ax = plt.gca() - ax.plot(xs, ys, label='f(x)') - ax.plot(xs, grad_xs, label='f\'(x)') - ax.legend() - ax.grid(True) - ax.spines['left'].set_position('zero') - ax.spines['right'].set_color('none') - ax.spines['bottom'].set_position('zero') - ax.spines['top'].set_color('none') - - # Create new directory - test_utils.mkdir_p(result_dir) - plt.savefig(result_dir + '/output.png') - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description='Generate simple_derivative pic') - parser.add_argument('output_directory', - help='output directory of generated pic') - pic_simple_derivative(parser.parse_args().output_directory) diff --git a/tests/python/examples/rendering/test_cornell_box.py b/tests/python/examples/rendering/test_cornell_box.py deleted file mode 100644 index 47fb9a8c02f61..0000000000000 --- a/tests/python/examples/rendering/test_cornell_box.py +++ /dev/null @@ -1,50 +0,0 @@ -import argparse -import os - -import pytest - -import taichi as ti - -FRAMES = 200 - - -@pytest.mark.run_in_serial -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_cornell_box(): - from taichi.examples.rendering.cornell_box import render, tonemap - for i in range(FRAMES): - render() - interval = 10 - if i % interval == 0: - tonemap(i) - - -@pytest.mark.run_in_serial -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def video_cornell_box(result_dir): - from taichi.examples.rendering.cornell_box import (render, tonemap, - tonemapped_buffer) - video_manager = ti.tools.VideoManager(output_dir=result_dir, - framerate=24, - automatic_build=False) - gui = ti.GUI("Taichi Cornell Box", - res=800, - background_color=0x112F41, - show_gui=False) - for i in range(FRAMES): - render() - interval = 10 - if i % interval == 0: - tonemap(i) - - gui.set_image(tonemapped_buffer) - video_manager.write_frame(gui.get_image()) - gui.clear() - video_manager.make_video(mp4=True, gif=False) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Generate cornell_box video') - parser.add_argument('output_directory', - help='output directory of generated video') - video_cornell_box(parser.parse_args().output_directory) diff --git a/tests/python/examples/rendering/test_taichi_logo.py b/tests/python/examples/rendering/test_taichi_logo.py deleted file mode 100644 index bba48f85baa09..0000000000000 --- a/tests/python/examples/rendering/test_taichi_logo.py +++ /dev/null @@ -1,37 +0,0 @@ -import argparse -import os - -import pytest - -import taichi as ti - -FRAMES = 100 - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_taichi_logo(): - from taichi.examples.rendering.taichi_logo import paint - paint() - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def video_taichi_logo(result_dir): - from taichi.examples.rendering.taichi_logo import n, paint, x - video_manager = ti.tools.VideoManager(output_dir=result_dir, - framerate=24, - automatic_build=False) - paint() - gui = ti.GUI('Logo', (n, n), show_gui=False) - for i in range(FRAMES): - gui.set_image(x) - video_manager.write_frame(gui.get_image()) - gui.clear() - - video_manager.make_video(mp4=True, gif=False) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Generate taichi_logo video') - parser.add_argument('output_directory', - help='output directory of generated video') - video_taichi_logo(parser.parse_args().output_directory) diff --git a/tests/python/examples/simulation/test_ad_gravity.py b/tests/python/examples/simulation/test_ad_gravity.py deleted file mode 100644 index e900990143aa4..0000000000000 --- a/tests/python/examples/simulation/test_ad_gravity.py +++ /dev/null @@ -1,45 +0,0 @@ -import argparse -import os - -import pytest - -import taichi as ti - -FRAMES = 100 - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_ad_gravity(): - from taichi.examples.simulation.ad_gravity import init, substep - - init() - for _ in range(FRAMES): - for _ in range(50): - substep() - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def video_ad_gravity(result_dir): - import numpy as np - from taichi.examples.simulation.ad_gravity import init, substep, x - - video_manager = ti.tools.VideoManager(output_dir=result_dir, - framerate=24, - automatic_build=False) - - gui = ti.GUI('Autodiff gravity', show_gui=False) - init() - for _ in range(FRAMES): - for _ in range(50): - substep() - gui.circles(x.to_numpy(), radius=3) - video_manager.write_frame(gui.get_image()) - gui.clear() - video_manager.make_video(mp4=True, gif=False) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Generate ad_gravity video') - parser.add_argument('output_directory', - help='output directory of generated video') - video_ad_gravity(parser.parse_args().output_directory) diff --git a/tests/python/examples/simulation/test_game_of_life.py b/tests/python/examples/simulation/test_game_of_life.py deleted file mode 100644 index 1632bff235c0f..0000000000000 --- a/tests/python/examples/simulation/test_game_of_life.py +++ /dev/null @@ -1,43 +0,0 @@ -import argparse - -import taichi as ti - -FRAMES = 100 - - -def test_game_of_life(): - from taichi.examples.simulation.game_of_life import init, run - - init() - for i in range(FRAMES): - run() - - -def video_game_of_life(result_dir): - import numpy as np - from taichi.examples.simulation.game_of_life import (alive, img_size, init, - run) - - video_manager = ti.tools.VideoManager(output_dir=result_dir, - framerate=24, - automatic_build=False) - - gui = ti.GUI('Game of Life', (img_size, img_size), show_gui=False) - gui.fps_limit = 15 - - init() - for i in range(FRAMES): - run() - - gui.set_image( - ti.tools.imresize(alive, img_size).astype(np.uint8) * 255) - video_manager.write_frame(gui.get_image()) - gui.clear() - video_manager.make_video(mp4=True, gif=False) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Generate game_of_life video') - parser.add_argument('output_directory', - help='output directory of generated video') - video_game_of_life(parser.parse_args().output_directory) diff --git a/tests/python/examples/simulation/test_mpm99.py b/tests/python/examples/simulation/test_mpm99.py deleted file mode 100644 index 56cceb187f7ae..0000000000000 --- a/tests/python/examples/simulation/test_mpm99.py +++ /dev/null @@ -1,52 +0,0 @@ -import argparse -import os - -import pytest - -import taichi as ti - -FRAMES = 100 - - -@pytest.mark.run_in_serial -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_mpm99(): - from taichi.examples.simulation.mpm99 import dt, initialize, substep - - initialize() - for i in range(FRAMES): - for s in range(int(2e-3 // dt)): - substep() - - -@pytest.mark.run_in_serial -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def video_mpm99(result_dir): - from taichi.examples.simulation.mpm99 import (dt, initialize, material, - substep, x) - - video_manager = ti.tools.VideoManager(output_dir=result_dir, - framerate=24, - automatic_build=False) - initialize() - gui = ti.GUI("Taichi MLS-MPM-99", - res=512, - background_color=0x112F41, - show_gui=False) - for i in range(FRAMES): - for s in range(int(2e-3 // dt)): - substep() - gui.circles(x.to_numpy(), - radius=1.5, - palette=[0x068587, 0xED553B, 0xEEEEF0], - palette_indices=material) - video_manager.write_frame(gui.get_image()) - gui.clear() - video_manager.make_video(mp4=True, gif=False) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Generate mpm99 video') - parser.add_argument('output_directory', - help='output directory of generated video') - video_mpm99(parser.parse_args().output_directory) diff --git a/tests/python/examples/simulation/test_nbody.py b/tests/python/examples/simulation/test_nbody.py deleted file mode 100644 index 4c75b4f40ec68..0000000000000 --- a/tests/python/examples/simulation/test_nbody.py +++ /dev/null @@ -1,50 +0,0 @@ -import argparse -import os - -import pytest - -import taichi as ti - -FRAMES = 100 - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def test_nbody(): - from taichi.examples.simulation.nbody import (compute_force, initialize, - substepping, update) - - initialize() - for i in range(FRAMES): - for i in range(substepping): - compute_force() - update() - - -@pytest.mark.skipif(os.environ.get('TI_LITE_TEST') or '0', reason='Lite test') -def video_nbody(result_dir): - from taichi.examples.simulation.nbody import (compute_force, initialize, - planet_radius, pos, - substepping, update) - - video_manager = ti.tools.VideoManager(output_dir=result_dir, - framerate=24, - automatic_build=False) - - initialize() - gui = ti.GUI('N-body problem', (800, 800), show_gui=False) - for i in range(FRAMES): - for i in range(substepping): - compute_force() - update() - - gui.circles(pos.to_numpy(), color=0xffffff, radius=planet_radius) - video_manager.write_frame(gui.get_image()) - gui.clear() - video_manager.make_video(mp4=True, gif=False) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Generate nbody video') - parser.add_argument('output_directory', - help='output directory of generated video') - video_nbody(parser.parse_args().output_directory)