diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000..78949e17 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,55 @@ +name: Test AMRClaw + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +env: + CLAW: ${{ github.workspace }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install gfortran + python -m pip install --upgrade pip + pip install flake8 meson-python ninja pytest numpy + # if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Checkout Clawpack + uses: actions/checkout@v4.1.5 + with: + repository: clawpack/clawpack + submodules: true + - name: Checkout AMRClaw branch + uses: actions/checkout@v4.1.5 + with: + path: amrclaw + + - name: Install clawpack + run: | + pip install --no-build-isolation --editable . + + - name: Lint with flake8 + run: | + cd ${CLAW}/amrclaw + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude dev + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + cd ${CLAW}/amrclaw + pytest diff --git a/.gitignore b/.gitignore index a06ab4f3..e8c08d49 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store *.pyc *.o *.mod @@ -8,6 +9,7 @@ xclaw xamr xgeoclaw *.html +*.data _output/ _plots/ *~ diff --git a/examples/acoustics_2d_adjoint/run_adjoint_flagging.py b/examples/acoustics_2d_adjoint/run_adjoint_flagging.py index c4c57856..fbdc0776 100644 --- a/examples/acoustics_2d_adjoint/run_adjoint_flagging.py +++ b/examples/acoustics_2d_adjoint/run_adjoint_flagging.py @@ -4,17 +4,17 @@ import os -currentdir = os.getcwd() -adjointdir = currentdir + '/adjoint' +current_dir = os.getcwd() +adjoint_dir = os.path.join(current_dir, "adjoint") # Running the adjoint problem -os.chdir(adjointdir) +os.chdir(adjoint_dir) os.system('make new') os.system('make .plots') # Running the forward problem -os.chdir(currentdir) +os.chdir(current_dir) os.system('make new') os.system('make .plots') -print 'Finished running example with adjoint refinement' \ No newline at end of file +print('Finished running example with adjoint refinement') \ No newline at end of file diff --git a/src/python/amrclaw/data.py b/src/python/amrclaw/data.py index 42276e11..89343832 100755 --- a/src/python/amrclaw/data.py +++ b/src/python/amrclaw/data.py @@ -228,7 +228,7 @@ def __init__(self, num_dim, region=None): self.convert_old_region(region) - def convert_old_region(region): + def convert_old_region(self, region): """ Take a list region = [minlevel, maxlevel, t1, t2, x1, x2, y1, y2] in the old style and convert to a new flagregion. @@ -266,10 +266,10 @@ def __init__(self,flagregions=None,num_dim=2): super(FlagRegionData,self).__init__() - if flagregions is None or not isinstance(regions,list): + if flagregions is None or not isinstance(flagregions,list): self.add_attribute('flagregions',[]) else: - self.add_attribute('flagregions',regions) + self.add_attribute('flagregions',flagregions) self.add_attribute('num_dim',num_dim) diff --git a/tests/advection_1d_example1/setplot.py b/tests/advection_1d_example1/setplot.py index 86c6f4b4..aa2701cb 100644 --- a/tests/advection_1d_example1/setplot.py +++ b/tests/advection_1d_example1/setplot.py @@ -11,7 +11,7 @@ from numpy import linspace probdata = ClawData() probdata.read('setprob.data', force=True) -print "Parameters: u = %g, beta = %g" % (probdata.u, probdata.beta) +print("Parameters: u = %g, beta = %g" % (probdata.u, probdata.beta)) def qtrue(x,t): """