Skip to content

Commit

Permalink
Merge pull request clawpack#296 from mandli/add-ci-action
Browse files Browse the repository at this point in the history
Add CI Action for Linting and Testing
  • Loading branch information
rjleveque authored Jun 11, 2024
2 parents a1d1ecc + 6d6dac1 commit 2d9d076
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 9 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
repository: clawpack/clawpack
submodules: true
- name: Checkout AMRClaw branch
uses: actions/[email protected]
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
*.pyc
*.o
*.mod
Expand All @@ -8,6 +9,7 @@ xclaw
xamr
xgeoclaw
*.html
*.data
_output/
_plots/
*~
Expand Down
10 changes: 5 additions & 5 deletions examples/acoustics_2d_adjoint/run_adjoint_flagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
print('Finished running example with adjoint refinement')
6 changes: 3 additions & 3 deletions src/python/amrclaw/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion tests/advection_1d_example1/setplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 2d9d076

Please sign in to comment.