Skip to content

Commit

Permalink
Update CI to use Python versions 3.7 and 3.10 (#1926)
Browse files Browse the repository at this point in the history
* Update CI to use Python versions 3.7 and 3.10

* surround 3.10 with quotes to treat as string

* unpin coverage version

* remove obsolete Python 2 related imports

* pin coverage package due to nedbat/coveragepy#916

* pin coveragepy to 5.0.3

* run coverage in parallel mode, combine coverage report, and add type annotation for chunk_layout

* append coverage data only during combine and not run

* output test logs if make check fails
  • Loading branch information
oskooi committed Feb 6, 2022
1 parent 95a1cbf commit 1416331
Show file tree
Hide file tree
Showing 30 changed files with 60 additions and 113 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/build-ci.yml
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.9]
python-version: [3.7, '3.10']
enable-mpi: [false, true]

steps:
Expand Down Expand Up @@ -126,8 +126,8 @@ jobs:
run: pip install -r python/requirements.txt

- name: Install coverage
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
run: pip install coverage==4.5.4
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: pip install coverage

- name: Install mpi4py
if: ${{ matrix.enable-mpi && steps.cache.outputs.cache-hit != true }}
Expand All @@ -140,66 +140,67 @@ jobs:
echo "MEEP_VERSION=${MEEP_VERSION}" >> $GITHUB_ENV
- name: Run configure with OpenMP
if: ${{ !(matrix.enable-mpi == false && matrix.python-version == 3.6) && !(matrix.enable-mpi == true && matrix.python-version == 3.9) }}
if: ${{ !(matrix.enable-mpi == false && matrix.python-version == 3.7) && !(matrix.enable-mpi == true && matrix.python-version == 3.10) }}
run: |
mkdir -p build &&
pushd build &&
../configure --enable-maintainer-mode --prefix=${HOME}/local --with-libctl=${HOME}/local/share/libctl ${MPICONF} --with-openmp &&
popd
- name: Run configure with coverage
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: ./configure --enable-maintainer-mode --with-coverage --prefix=${HOME}/local --with-libctl=${HOME}/local/share/libctl ${MPICONF}

- name: Run configure with single-precision floating point and swig threads
if: ${{ matrix.enable-mpi == true && matrix.python-version == 3.9 }}
if: ${{ matrix.enable-mpi == true && matrix.python-version == 3.10 }}
run: |
mkdir -p build &&
pushd build &&
../configure --enable-maintainer-mode --prefix=${HOME}/local --with-libctl=${HOME}/local/share/libctl ${MPICONF} --enable-single --enable-swig-python-threads &&
popd
- name: Run make
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: make ${MKCHECKFLAGS}

- name: Run make check
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: |
pushd python/ &&
make ${MKCHECKFLAGS} check &&
{ make ${MKCHECKFLAGS} check || cat test-suite.log; } &&
popd
- name: Run make distcheck
if: ${{ !(matrix.enable-mpi == false && matrix.python-version == 3.6) }}
if: ${{ !(matrix.enable-mpi == false && matrix.python-version == 3.7) }}
run: |
pushd build &&
make ${MKCHECKFLAGS} distcheck DISTCHECK_CONFIGURE_FLAGS="--with-libctl=${HOME}/local/share/libctl ${MPICONF}" &&
popd
- name: Generate coverage report
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
run: |
pushd python/ &&
coverage combine -a &&
coverage report -i &&
coverage xml -i &&
popd
- name: Upload coverage to Codecov
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.7 }}
uses: codecov/codecov-action@v1
with:
files: ${{ github.workspace }}/python/coverage.xml

- name: Archive C++ test logs
if: ${{ failure() && !(matrix.enable-mpi == false && matrix.python-version == 3.6) }}
if: ${{ failure() && !(matrix.enable-mpi == false && matrix.python-version == 3.7) }}
uses: actions/upload-artifact@v2
with:
name: cpp-tests-mpi-${{ matrix.enable-mpi }}-log
path: ${{ github.workspace }}/build/meep-${{ env.MEEP_VERSION }}/_build/sub/tests/test-suite.log

- name: Archive Python test logs
if: ${{ failure() && !(matrix.enable-mpi == false && matrix.python-version == 3.6) }}
if: ${{ failure() && !(matrix.enable-mpi == false && matrix.python-version == 3.7) }}
uses: actions/upload-artifact@v2
with:
name: py${{ matrix.python-version }}-tests-mpi-${{ matrix.enable-mpi }}-log
Expand Down
68 changes: 34 additions & 34 deletions doc/docs/Python_User_Interface.md
Expand Up @@ -87,40 +87,40 @@ control various parameters of the Meep computation.

```python
def __init__(self,
cell_size: Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...], NoneType] = None,
resolution: float = None,
geometry: Optional[List[meep.geom.GeometricObject]] = None,
sources: Optional[List[meep.source.Source]] = None,
eps_averaging: bool = True,
dimensions: int = 3,
boundary_layers: Optional[List[meep.simulation.PML]] = None,
symmetries: Optional[List[meep.simulation.Symmetry]] = None,
force_complex_fields: bool = False,
default_material: meep.geom.Medium = Medium(),
m: float = 0,
k_point: Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...], bool] = False,
kz_2d: str = 'complex',
extra_materials: Optional[List[meep.geom.Medium]] = None,
material_function: Optional[Callable[[Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...]]], meep.geom.Medium]] = None,
epsilon_func: Optional[Callable[[Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...]]], float]] = None,
epsilon_input_file: str = '',
progress_interval: float = 4,
subpixel_tol: float = 0.0001,
subpixel_maxeval: int = 100000,
loop_tile_base_db: int = 0,
loop_tile_base_eh: int = 0,
ensure_periodicity: bool = True,
num_chunks: int = 0,
Courant: float = 0.5,
accurate_fields_near_cylorigin: bool = False,
filename_prefix: Optional[str] = None,
output_volume: Optional[meep.simulation.Volume] = None,
output_single_precision: bool = False,
geometry_center: Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...]] = Vector3<0.0, 0.0, 0.0>,
force_all_components: bool = False,
split_chunks_evenly: bool = True,
chunk_layout=None,
collect_stats: bool = False):
cell_size: 'Optional[Vector3Type]' = None,
resolution: 'float' = None,
geometry: 'Optional[List[GeometricObject]]' = None,
sources: 'Optional[List[Source]]' = None,
eps_averaging: 'bool' = True,
dimensions: 'int' = 3,
boundary_layers: 'Optional[List[PML]]' = None,
symmetries: 'Optional[List[Symmetry]]' = None,
force_complex_fields: 'bool' = False,
default_material: 'Medium' = Medium(),
m: 'float' = 0,
k_point: 'Union[Vector3Type, bool]' = False,
kz_2d: 'str' = 'complex',
extra_materials: 'Optional[List[Medium]]' = None,
material_function: 'Optional[Callable[[Vector3Type], Medium]]' = None,
epsilon_func: 'Optional[Callable[[Vector3Type], float]]' = None,
epsilon_input_file: 'str' = '',
progress_interval: 'float' = 4,
subpixel_tol: 'float' = 0.0001,
subpixel_maxeval: 'int' = 100000,
loop_tile_base_db: 'int' = 0,
loop_tile_base_eh: 'int' = 0,
ensure_periodicity: 'bool' = True,
num_chunks: 'int' = 0,
Courant: 'float' = 0.5,
accurate_fields_near_cylorigin: 'bool' = False,
filename_prefix: 'Optional[str]' = None,
output_volume: 'Optional[Volume]' = None,
output_single_precision: 'bool' = False,
geometry_center: 'Vector3Type' = Vector3<0.0, 0.0, 0.0>,
force_all_components: 'bool' = False,
split_chunks_evenly: 'bool' = True,
chunk_layout: 'Optional[str, Simulation, BinaryPartition]' = None,
collect_stats: 'bool' = False):
```

<div class="method_docstring" markdown="1">
Expand Down
2 changes: 1 addition & 1 deletion python/Makefile.am
Expand Up @@ -95,7 +95,7 @@ TESTS = \
$(WVG_SRC_TEST)

if WITH_COVERAGE
PY_LOG_COMPILER = coverage run -a --source=$(top_srcdir)/python/meep --omit=$(top_srcdir)/python/tests/*,$(top_srcdir)/python/examples/*,$(top_srcdir)/python/meep/materials.py
PY_LOG_COMPILER = coverage run -p --source=$(top_srcdir)/python/meep --omit=$(top_srcdir)/python/tests/*,$(top_srcdir)/python/examples/*,$(top_srcdir)/python/meep/materials.py
else
PY_LOG_COMPILER = $(RUNCODE) $(PYTHON)
endif
Expand Down
2 changes: 0 additions & 2 deletions python/geom.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import division

import functools
import math
import numbers
Expand Down
3 changes: 0 additions & 3 deletions python/mpb_data.py
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import division

import math

import numpy as np
import meep as mp
from . import map_data
Expand Down
6 changes: 3 additions & 3 deletions python/simulation.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import division, print_function
from __future__ import annotations

from typing import Callable, List, Tuple, Union, Optional

Expand Down Expand Up @@ -170,7 +170,7 @@ def p(self):
return self._p

DefaultPMLProfile = lambda u: u * u
Vector3Type = Union[Vector3, Tuple[float, ...], Tuple[int, ...]]
Vector3Type = Union[Vector3, Tuple[float, ...]]

class PML(object):
"""
Expand Down Expand Up @@ -968,7 +968,7 @@ def __init__(self,
geometry_center: Vector3Type = Vector3(),
force_all_components: bool = False,
split_chunks_evenly: bool = True,
chunk_layout = None,
chunk_layout: Optional[str, Simulation, BinaryPartition] = None,
collect_stats: bool = False):
"""
All `Simulation` attributes are described in further detail below. In brackets
Expand Down
2 changes: 0 additions & 2 deletions python/solver.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import division, print_function

import functools
import math
import os
Expand Down
3 changes: 0 additions & 3 deletions python/source.py
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import division

import warnings

import meep as mp
from meep.geom import Vector3, check_nonnegative

Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_absorber_1d.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import meep as mp
from meep.materials import Al
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_antenna_radiation.py
@@ -1,5 +1,3 @@
from __future__ import division

import meep as mp
import math
import numpy as np
Expand Down
10 changes: 4 additions & 6 deletions python/tests/test_binary_grating.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import meep as mp
import math
Expand All @@ -9,7 +7,7 @@
class TestEigCoeffs(unittest.TestCase):

def run_binary_grating_oblique(self, theta):

resolution = 30 # pixels/um

dpml = 1.0 # PML thickness
Expand All @@ -25,7 +23,7 @@ def run_binary_grating_oblique(self, theta):
cell_size = mp.Vector3(sx,sy,0)

# replace anisotropic PML with isotropic Absorber to attenuate parallel-directed fields of oblique source
abs_layers = [mp.Absorber(thickness=dpml,direction=mp.X)]
abs_layers = [mp.Absorber(thickness=dpml,direction=mp.X)]

wvl = 0.5 # center wavelength
fcen = 1/wvl # center frequency
Expand All @@ -46,7 +44,7 @@ def run_binary_grating_oblique(self, theta):
k = mp.Vector3(0,0,0)
symmetries = [mp.Mirror(mp.Y)]
eig_parity += mp.EVEN_Y

def pw_amp(k,x0):
def _pw_amp(x):
return cmath.exp(1j*2*math.pi*k.dot(x+x0))
Expand All @@ -71,7 +69,7 @@ def _pw_amp(x):
refl_flux = sim.add_flux(fcen, 0, 1, mp.FluxRegion(center=refl_pt, size=mp.Vector3(0,sy,0)))

sim.run(until_after_sources=100)

input_flux = mp.get_fluxes(refl_flux)
input_flux_data = sim.get_flux_data(refl_flux)

Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_cyl_ellipsoid.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import meep as mp

Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_diffracted_planewave.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import meep as mp
import math
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_faraday_rotation.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import numpy as np
import meep as mp
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_fragment_stats.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import meep as mp

Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_gaussianbeam.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import meep as mp
import math
Expand Down
4 changes: 1 addition & 3 deletions python/tests/test_kdom.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import meep as mp
import math
Expand Down Expand Up @@ -30,7 +28,7 @@ def run_kdom(self, theta, num_band):
k = mp.Vector3(0,0,0)
eig_parity += mp.EVEN_Y
symmetries = [mp.Mirror(mp.Y)]

sim = mp.Simulation(resolution=resolution,
cell_size=cell_size,
k_point=k,
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_material_dispersion.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import numpy as np
import meep as mp
Expand Down
4 changes: 1 addition & 3 deletions python/tests/test_medium_evaluations.py
Expand Up @@ -3,12 +3,10 @@
# Checks materials with lorentizian, drude, and non uniform diagonals.
# The extracted values are compared against actual datapoints pulled from
# refractiveindex.info.
# TODO:
# TODO:
# * check materials with off diagonal components
# * check magnetic profiles

from __future__ import division

import unittest
import meep as mp
import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_mpb.py
@@ -1,5 +1,3 @@
from __future__ import division, print_function

import glob
import math
import os
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_oblique_source.py
@@ -1,5 +1,3 @@
from __future__ import division

import meep as mp
import math
import unittest
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_physical.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import meep as mp

Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_prism.py
@@ -1,5 +1,3 @@
from __future__ import division

import os
import unittest
import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_ring.py
@@ -1,7 +1,5 @@
# Python port of meep/examples/ring.ctl
# Calculating 2d ring-resonator modes, from the Meep tutorial.
from __future__ import division

import unittest
import meep as mp

Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_ring_cyl.py
@@ -1,5 +1,3 @@
from __future__ import division

import unittest
import meep as mp
from utils import ApproxComparisonTestCase
Expand Down

0 comments on commit 1416331

Please sign in to comment.