diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cecef424bf9e5ffabaec87dbf441481d5841b66..568a0a1c8cae502493f3f2992d9c5153a5209e56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,10 +29,6 @@ jobs: 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 @@ -41,8 +37,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 @@ -53,8 +49,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 @@ -64,4 +60,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: + - 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 + EXTRA_INSTALL="pyvisfile scipy" + build_py_project_in_conda_env + run_examples + # vim: sw=4 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10c6580faad6a583f12f1d860b8863f478a4344f..1bfb6726ca6f4b7e9c8f07af13ec80283a4e5b8d 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 @@ -84,6 +84,20 @@ Python 3.6 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 + EXTRA_INSTALL="pyvisfile scipy" + build_py_project_in_conda_env + run_examples + tags: + - large-node + except: + - tags + Documentation: script: - EXTRA_INSTALL="pybind11 numpy mako" diff --git a/examples/curve-pot.py b/examples/curve-pot.py index 7ce25a823030fdab892b3be9419126d7bab2a276..3bed529c359898aac2a4da20f0c09038572298e5 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): @@ -130,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() @@ -167,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 @@ -192,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() # }}} @@ -206,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() # }}} @@ -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() # }}} @@ -265,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 diff --git a/examples/expansion-toys.py b/examples/expansion-toys.py index 12543b931366ddd0f210a20dcbfcb1cc3701319c..e774b17ae6b57a387eec39e1d220db1b9ddb51a7 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 ModuleNotFoundError: + 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 bde21c42abdd2cf006903a968945c9ffe280cd26..49e20ead986b880b86529ee8d436843d10ef3cbb 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__":