From e380354f81578b975df8d35f7cce57ee791b5c41 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:31:53 -0600 Subject: [PATCH 01/11] Remove unnecessary python-version in Github CI --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cecef42..38c7bbd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,11 +28,6 @@ jobs: name: Documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-python@v1 - with: - python-version: '3.x' - name: "Main Script" run: | CONDA_ENVIRONMENT=.test-conda-env-py3.yml -- GitLab From 7667a0d3e1bc6bee87ef17b97808a6dd8e35b9b5 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:32:13 -0600 Subject: [PATCH 02/11] Rationalize test names in Github CI --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38c7bbd7..b4a25884 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,8 +36,8 @@ jobs: build_py_project_in_conda_env build_docs - pytest3: - name: Conda Pytest Py3 + pytest: + name: Conda Pytest runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -48,8 +48,8 @@ jobs: curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project-within-miniconda.sh . ./build-and-test-py-project-within-miniconda.sh - pytest3symengine: - name: Conda Pytest Py3 Symengine + pytest_symengine: + name: Conda Pytest Symengine runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 -- GitLab From bcd145e970468d023ccbf2b4571da13500de1fcc Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:32:30 -0600 Subject: [PATCH 03/11] Rationalize test names in Gitlab CI --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10c6580f..aba598c7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ # reports: # junit: test/pytest.xml -Python 3 POCL: +Pytest POCL: script: - export PY_EXE=python3 - export PYOPENCL_TEST=portable:pthread @@ -33,7 +33,7 @@ Python 3 POCL: reports: junit: test/pytest.xml -Python 3 Titan X: +Pytest Titan X: script: - py_version=3 - export PYOPENCL_TEST=nvi:titan @@ -50,7 +50,7 @@ Python 3 Titan X: reports: junit: test/pytest.xml -Python 3 Conda: +Pytest Conda: script: # Disable caching to ensure SymEngine code generation is exercised. - export SUMPY_NO_CACHE=1 @@ -67,7 +67,7 @@ Python 3 Conda: reports: junit: test/pytest.xml -Python 3.6 POCL Titan X: +Pytest POCL Titan X: script: # Disable caching to ensure SymEngine code generation is exercised. - export SUMPY_NO_CACHE=1 -- GitLab From 75015cd4fbb04394244cdc51809790d27b3e8e20 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:32:47 -0600 Subject: [PATCH 04/11] Add example runs in Github/Gitlab CI --- .github/workflows/ci.yml | 15 +++++++++++++++ .gitlab-ci.yml | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4a25884..e1259681 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,4 +59,19 @@ jobs: curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project-within-miniconda.sh . ./build-and-test-py-project-within-miniconda.sh + examples: + name: Conda Examples + runs-on: ubuntu-latest + steps: + steps: + - uses: actions/checkout@v2 + - name: "Main Script" + run: | + grep -v symengine .test-conda-env-py3.yml > .test-conda-env.yml + CONDA_ENVIRONMENT=.test-conda-env.yml + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh + . ci-support.sh + build_py_project_in_conda_env + run_examples + # vim: sw=4 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aba598c7..845a4b4b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -84,6 +84,19 @@ Pytest POCL Titan X: reports: junit: test/pytest.xml +Examples Conda: + script: | + grep -v symengine .test-conda-env-py3.yml > .test-conda-env.yml + CONDA_ENVIRONMENT=.test-conda-env.yml + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh + . ci-support.sh + build_py_project_in_conda_env + run_examples + tags: + - large-node + except: + - tags + Documentation: script: - EXTRA_INSTALL="pybind11 numpy mako" -- GitLab From e8076d1ebc2ff01589d765b2485274c1b9206e78 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:45:08 -0600 Subject: [PATCH 05/11] Make plot imports in examples optional --- examples/curve-pot.py | 29 +++++++++++++++++++---------- examples/expansion-toys.py | 9 ++++++--- examples/sym-exp-complexity.py | 26 +++++++++++++++----------- 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/examples/curve-pot.py b/examples/curve-pot.py index 7ce25a82..7d34ee34 100644 --- a/examples/curve-pot.py +++ b/examples/curve-pot.py @@ -1,7 +1,16 @@ import pyopencl as cl import numpy as np import numpy.linalg as la -import matplotlib.pyplot as pt + +try: + import matplotlib.pyplot as plt +except ModuleNotFoundError: + plt = None + +try: + from mayavi import mlab +except ModuleNotFoundError: + mlab = None def process_kernel(knl, what_operator): @@ -248,15 +257,15 @@ def draw_pot_figure(aspect_ratio, plotval_vol[outlier_flag] = sum( nb[outlier_flag] for nb in neighbors)/len(neighbors) - fp.show_scalar_in_mayavi(scale*plotval_vol, max_val=1) - from mayavi import mlab - mlab.colorbar() - if 1: - mlab.points3d( - native_curve.pos[0], - native_curve.pos[1], - scale*plotval_c, scale_factor=0.02) - mlab.show() + if mlab is not None: + fp.show_scalar_in_mayavi(scale*plotval_vol, max_val=1) + mlab.colorbar() + if 1: + mlab.points3d( + native_curve.pos[0], + native_curve.pos[1], + scale*plotval_c, scale_factor=0.02) + mlab.show() # }}} diff --git a/examples/expansion-toys.py b/examples/expansion-toys.py index 12543b93..97c0eceb 100644 --- a/examples/expansion-toys.py +++ b/examples/expansion-toys.py @@ -2,7 +2,10 @@ import pyopencl as cl import sumpy.toys as t import numpy as np from sumpy.visualization import FieldPlotter -import matplotlib.pyplot as plt +try: + import matplotlib.pyplot as plt +except ImportError: + plt = None def main(): @@ -22,7 +25,7 @@ def main(): fp = FieldPlotter([3, 0], extent=8) - if 0: + if 0 and plt is not None: t.logplot(fp, pt_src, cmap="jet") plt.colorbar() plt.show() @@ -37,7 +40,7 @@ def main(): diff = lexp2 - pt_src print(t.l_inf(diff, 1.2, center=lexp2.center)) - if 1: + if 1 and plt is not None: t.logplot(fp, diff, cmap="jet", vmin=-3, vmax=0) plt.colorbar() plt.show() diff --git a/examples/sym-exp-complexity.py b/examples/sym-exp-complexity.py index bde21c42..49e20ead 100644 --- a/examples/sym-exp-complexity.py +++ b/examples/sym-exp-complexity.py @@ -11,6 +11,10 @@ from sumpy.expansion.multipole import ( HelmholtzConformingVolumeTaylorMultipoleExpansion, ) from sumpy.e2e import E2EFromCSR +try: + import matplotlib.pyplot as plt +except ModuleNotFoundError: + plt = None def find_flops(): @@ -59,28 +63,28 @@ def plot_flops(): flops = [62, 300, 914, 2221, 4567, 8405, 14172, 22538, 34113] filename = "laplace-m2l-complexity-3d.pdf" - elif 0: + elif 1: case = "2D Laplace M2L" orders = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] flops = [36, 99, 193, 319, 476, 665, 889, 1143, 1429, 1747, 2097, 2479, 2893, 3339, 3817, 4327, 4869, 5443, 6049, 6687] filename = "laplace-m2l-complexity-2d.pdf" - elif 1: + elif 0: case = "2D Helmholtz M2L" orders = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] flops = [45, 194, 474, 931, 1650, 2632, 3925, 5591, 7706, 10272] filename = "helmholtz-m2l-complexity-2d.pdf" - import matplotlib.pyplot as plt - plt.rc("font", size=16) - plt.title(case) - plt.ylabel("Flop count") - plt.xlabel("Expansion order") - plt.loglog(orders, flops, "o-") - plt.grid() - plt.tight_layout() - plt.savefig(filename) + if plt is not None: + plt.rc("font", size=16) + plt.title(case) + plt.ylabel("Flop count") + plt.xlabel("Expansion order") + plt.loglog(orders, flops, "o-") + plt.grid() + plt.tight_layout() + plt.savefig(filename) if __name__ == "__main__": -- GitLab From be0233a81740cd68aa9ebed2e4ef5c99c5e0ea56 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:48:33 -0600 Subject: [PATCH 06/11] Github CI: remove duplicate steps key --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1259681..47abc446 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,6 @@ jobs: name: Conda Examples runs-on: ubuntu-latest steps: - steps: - uses: actions/checkout@v2 - name: "Main Script" run: | -- GitLab From b052c08209cc4c9d64142aad87bfca53f239224d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:51:19 -0600 Subject: [PATCH 07/11] ImportError -> ModuleNotFoundError in expansion-toys --- examples/expansion-toys.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/expansion-toys.py b/examples/expansion-toys.py index 97c0eceb..e774b17a 100644 --- a/examples/expansion-toys.py +++ b/examples/expansion-toys.py @@ -4,7 +4,7 @@ import numpy as np from sumpy.visualization import FieldPlotter try: import matplotlib.pyplot as plt -except ImportError: +except ModuleNotFoundError: plt = None -- GitLab From 2b0a84958e2c88a2b483c269a22c716ef0cf34b0 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:51:34 -0600 Subject: [PATCH 08/11] pt -> plt in curve-pot example --- examples/curve-pot.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/curve-pot.py b/examples/curve-pot.py index 7d34ee34..3bed529c 100644 --- a/examples/curve-pot.py +++ b/examples/curve-pot.py @@ -139,7 +139,7 @@ def draw_pot_figure(aspect_ratio, * center_dist*native_curve.normal) #native_curve.plot() - #pt.show() + #plt.show() volpot_kwargs = knl_kwargs.copy() lpot_kwargs = knl_kwargs.copy() @@ -176,7 +176,7 @@ def draw_pot_figure(aspect_ratio, op = LinearOperator((nsrc, nsrc), apply_lpot) mat = build_matrix(op, dtype=np.complex128) w, v = la.eig(mat) - pt.plot(w.real, "o-") + plt.plot(w.real, "o-") #import sys; sys.exit(0) return @@ -201,10 +201,10 @@ def draw_pot_figure(aspect_ratio, if 0: # {{{ plot on-surface potential in 2D - pt.plot(curve_pot, label="pot") - pt.plot(density, label="dens") - pt.legend() - pt.show() + plt.plot(curve_pot, label="pot") + plt.plot(density, label="dens") + plt.legend() + plt.show() # }}} @@ -215,23 +215,23 @@ def draw_pot_figure(aspect_ratio, if 0: # {{{ 2D false-color plot - pt.clf() + plt.clf() plotval = np.log10(1e-20+np.abs(vol_pot)) im = fp.show_scalar_in_matplotlib(plotval.real) from matplotlib.colors import Normalize im.set_norm(Normalize(vmin=-2, vmax=1)) src = native_curve.pos - pt.plot(src[:, 0], src[:, 1], "o-k") + plt.plot(src[:, 0], src[:, 1], "o-k") # close the curve - pt.plot(src[-1::-len(src)+1, 0], src[-1::-len(src)+1, 1], "o-k") + plt.plot(src[-1::-len(src)+1, 0], src[-1::-len(src)+1, 1], "o-k") - #pt.gca().set_aspect("equal", "datalim") - cb = pt.colorbar(shrink=0.9) + #plt.gca().set_aspect("equal", "datalim") + cb = plt.colorbar(shrink=0.9) cb.set_label(r"$\log_{10}(\mathdefault{Error})$") #from matplotlib.ticker import NullFormatter - #pt.gca().xaxis.set_major_formatter(NullFormatter()) - #pt.gca().yaxis.set_major_formatter(NullFormatter()) + #plt.gca().xaxis.set_major_formatter(NullFormatter()) + #plt.gca().yaxis.set_major_formatter(NullFormatter()) fp.set_matplotlib_limits() # }}} @@ -274,14 +274,14 @@ if __name__ == "__main__": draw_pot_figure(aspect_ratio=1, nsrc=100, novsmp=100, helmholtz_k=(35+4j)*0.3, what_operator="D", what_operator_lpot="D", force_center_side=1) -# pt.savefig("eigvals-ext-nsrc100-novsmp100.pdf") - #pt.clf() +# plt.savefig("eigvals-ext-nsrc100-novsmp100.pdf") + #plt.clf() #draw_pot_figure(aspect_ratio=1, nsrc=100, novsmp=100, helmholtz_k=0, # what_operator="D", what_operator_lpot="D", force_center_side=-1) - #pt.savefig("eigvals-int-nsrc100-novsmp100.pdf") - #pt.clf() + #plt.savefig("eigvals-int-nsrc100-novsmp100.pdf") + #plt.clf() #draw_pot_figure(aspect_ratio=1, nsrc=100, novsmp=200, helmholtz_k=0, # what_operator="D", what_operator_lpot="D", force_center_side=-1) - #pt.savefig("eigvals-int-nsrc100-novsmp200.pdf") + #plt.savefig("eigvals-int-nsrc100-novsmp200.pdf") # vim: fdm=marker -- GitLab From 5c8d35843703ffa8520cdb27985400f0826eef7e Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:56:22 -0600 Subject: [PATCH 09/11] Restore missing checkout step from docs Github CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47abc446..51db4c0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ jobs: name: Documentation runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - name: "Main Script" run: | CONDA_ENVIRONMENT=.test-conda-env-py3.yml -- GitLab From 699aaeb41ff0c7d6993e3938ababd8993e557557 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 17:58:56 -0600 Subject: [PATCH 10/11] Add scipy to test conda env for examples --- .test-conda-env-py3.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index 208f46e0..7ec236ca 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -15,3 +15,6 @@ dependencies: - python-symengine=0.6.0 - pyfmmlib - pyrsistent + +# Only needed for examples +- scipy -- GitLab From a5065e46e07cfa4821170ac64794c14b50485cc6 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 11 Jan 2021 18:08:37 -0600 Subject: [PATCH 11/11] Also install pyvisfile for example builds --- .github/workflows/ci.yml | 1 + .gitlab-ci.yml | 1 + .test-conda-env-py3.yml | 3 --- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51db4c0f..568a0a1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,7 @@ jobs: CONDA_ENVIRONMENT=.test-conda-env.yml curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh . ci-support.sh + EXTRA_INSTALL="pyvisfile scipy" build_py_project_in_conda_env run_examples diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 845a4b4b..1bfb6726 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -90,6 +90,7 @@ Examples Conda: CONDA_ENVIRONMENT=.test-conda-env.yml curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/ci-support.sh . ci-support.sh + EXTRA_INSTALL="pyvisfile scipy" build_py_project_in_conda_env run_examples tags: diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index 7ec236ca..208f46e0 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -15,6 +15,3 @@ dependencies: - python-symengine=0.6.0 - pyfmmlib - pyrsistent - -# Only needed for examples -- scipy -- GitLab