Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Testing to PyTest and CI to GitHub Actions #610

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8bd73fa
Add support for PyTest
mandli May 9, 2024
9aa2053
Add testing github action
mandli May 10, 2024
27f09a6
Add github CI script
mandli May 10, 2024
ac53c2c
Correct multiple python errors so that linting passes
mandli May 10, 2024
261fb77
Merge remote-tracking branch 'clawpack/master' into switch-pytest
mandli May 10, 2024
ecc66c5
Fix git branch checkout reference
mandli May 10, 2024
a909c0b
Add tests badge to readme
mandli May 10, 2024
1ad18db
Try another variable for checkout
mandli May 10, 2024
d0bb3a6
Try to use checkout default action
mandli May 10, 2024
28a9924
Remove caching
mandli May 10, 2024
929c2e0
Add explicit pathing
mandli May 10, 2024
55db9ee
Add more explicit pathing
mandli May 10, 2024
b2c2a9e
Add more explicit pathing
mandli May 10, 2024
15da52a
Add more explicit pathing
mandli May 10, 2024
3c870bf
Modify testing action
mandli May 10, 2024
67e15cc
Modify testing action
mandli May 10, 2024
e3e8378
Modify testing action
mandli May 10, 2024
6abcaa8
Modify testing action
mandli May 10, 2024
5f22653
Modify testing action
mandli May 10, 2024
b8990da
Modify testing action
mandli May 10, 2024
803a00b
Modify testing action
mandli May 10, 2024
84c0b37
Modify testing action
mandli May 10, 2024
aea3072
Modify testing action
mandli May 10, 2024
9ce11ad
Modify testing action
mandli May 10, 2024
82cb147
Modify testing action
mandli May 10, 2024
fd67ed5
Modify testing action
mandli May 10, 2024
5664380
Modify testing action
mandli May 10, 2024
b80dc77
Modify testing action
mandli May 10, 2024
7f4223f
Modify testing action
mandli May 10, 2024
3f08d40
Modify testing action
mandli May 10, 2024
07fa18b
Modify testing action
mandli May 10, 2024
6e16d76
Modify testing action
mandli May 10, 2024
98a9d70
Modify testing action
mandli May 10, 2024
f7a1620
Try installing clawpack not in user
mandli May 13, 2024
76134f2
Futzing with ninja
mandli May 13, 2024
7b28937
Restore ninja and try debugging line
mandli May 13, 2024
2fdf54a
Think worked out kinks in CI action
mandli May 31, 2024
9e85d95
Fix numpy reference
mandli May 31, 2024
e901439
Add xarray to test environment
mandli May 31, 2024
fb8e638
Add netCDF4 module
mandli May 31, 2024
b10cd81
Merge remote-tracking branch 'clawpack/master' into switch-pytest
mandli Jun 10, 2024
dd5c411
Merge branch 'clawpack:master' into switch-pytest
mandli Jul 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application
name: Test GeoClaw

on:
push:
Expand All @@ -12,43 +9,47 @@ on:
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: Checkout clawpack
uses: actions/[email protected]
with:
repository: clawpack/clawpack
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran liblapack-pic liblapack-dev libnetcdf-dev libnetcdff-dev
python -m pip install --upgrade pip
pip install flake8 pytest
- name: Setup clawpack super repository
run: |
git submodule init
git submodule update
pip install --user -e .
- name: Setup geoclaw
pip install flake8 meson-python ninja pytest numpy pandas xarray netCDF4
# 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 GeoClaw branch
uses: actions/[email protected]
with:
path: geoclaw

- name: Install clawpack
run: |
cd geoclaw
git checkout ${{ github.ref }}
pip install --no-build-isolation --editable .

- name: Lint with flake8
run: |
cd geoclaw
cd ${CLAW}/geoclaw
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude old_dtopotools.py
# 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 geoclaw
cd ${CLAW}/geoclaw
pytest
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# GeoClaw - Geophysical Shallow Flow Package

[![Test GeoClaw](https://github.com/clawpack/geoclaw/actions/workflows/testing.yml/badge.svg)](https://github.com/clawpack/geoclaw/actions/workflows/testing.yml)

This repository hosts the source code for GeoClaw.

1 change: 0 additions & 1 deletion README.txt

This file was deleted.

35 changes: 9 additions & 26 deletions examples/multi-layer/bowl-radial/setplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ def pcolor_afteraxes(current_data):
# bathy_ref_lines(current_data)
gauge_locations(current_data)

def contour_afteraxes(current_data):
# gauge_locations(current_data)
# m_to_km_labels()
plt.hold(True)
pos = -80.0 * (23e3 / 180) + 500e3 - 5e3
plt.plot([pos,pos],[-300e3,300e3],'b',[pos-5e3,pos-5e3],[-300e3,300e3],'y')
plt.hold(False)
wind_contours(current_data)
bathy_ref_lines(current_data)
# def contour_afteraxes(current_data):
# # gauge_locations(current_data)
# # m_to_km_labels()
# plt.hold(True)
# pos = -80.0 * (23e3 / 180) + 500e3 - 5e3
# plt.plot([pos,pos],[-300e3,300e3],'b',[pos-5e3,pos-5e3],[-300e3,300e3],'y')
# plt.hold(False)
# wind_contours(current_data)
# bathy_ref_lines(current_data)

def profile_afteraxes(current_data):
pass
Expand Down Expand Up @@ -259,23 +259,6 @@ def gaugetopo(current_data):
plotitem.plot_var = gaugetopo
plotitem.plotstyle = 'g-'

def add_zeroline(current_data):
from pylab import plot, legend, xticks, floor, axis, xlabel
t = current_data.t
gaugeno = current_data.gaugeno

if gaugeno == 32412:
try:
plot(TG32412[:,0], TG32412[:,1], 'r')
legend(['GeoClaw','Obs'],loc='lower right')
except: pass
axis((0,t.max(),-0.3,0.3))

plot(t, 0*t, 'k')
n = int(floor(t.max()/3600.) + 2)
xticks([3600*i for i in range(n)], ['%i' % i for i in range(n)])
xlabel('time (hours)')


#-----------------------------------------

Expand Down
36 changes: 13 additions & 23 deletions examples/multi-layer/plane_wave/setplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def transform_p2c(x, y, x0, y0, theta):

plotdata.clearfigures()
plotdata.save_frames = False
plotdata.format = 'ascii'
# plotdata.format = 'ascii'

# ========================================================================
# Generic helper functions
Expand All @@ -88,7 +88,6 @@ def contour_afteraxes(current_data):
pos = -80.0 * (23e3 / 180) + 500e3 - 5e3
axes.plot([pos, pos], [-300e3, 300e3], 'b',
[pos-5e3, pos-5e3], [-300e3, 300e3], 'y')
wind_contours(current_data)
bathy_ref_lines(current_data)

def profile_afteraxes(current_data):
Expand All @@ -105,7 +104,6 @@ def bathy_ref_lines(current_data):

# ========================================================================
# Axis limits

xlimits = [-0.5, 0.5]
ylimits = [-0.5, 0.5]
eta = [multilayer_data.eta[0], multilayer_data.eta[1]]
Expand All @@ -129,8 +127,6 @@ def bathy_ref_lines(current_data):
plotaxes.ylimits = ylimits
plotaxes.afteraxes = pcolor_afteraxes
ml_plot.add_surface_elevation(plotaxes,1,bounds=top_surface_limits)
# ml_plot.add_surface_elevation(plotaxes,1,bounds=[-0.06,0.06])
# ml_plot.add_surface_elevation(plotaxes,1)
ml_plot.add_land(plotaxes, 1)

# Bottom surface
Expand All @@ -141,9 +137,7 @@ def bathy_ref_lines(current_data):
plotaxes.xlimits = xlimits
plotaxes.ylimits = ylimits
plotaxes.afteraxes = pcolor_afteraxes
# ml_plot.add_surface_elevation(plotaxes,2,bounds=[-300-0.5,-300+0.5])
ml_plot.add_surface_elevation(plotaxes,2,bounds=internal_surface_limits)
# ml_plot.add_surface_elevation(plotaxes,2)
ml_plot.add_land(plotaxes, 2)

# ========================================================================
Expand Down Expand Up @@ -177,6 +171,7 @@ def bathy_ref_lines(current_data):

# ========================================================================
# Water Speed
# ========================================================================
plotfigure = plotdata.new_plotfigure(name='speed')
plotfigure.show = True
plotfigure.kwargs = {'figsize': (14, 4)}
Expand All @@ -200,9 +195,7 @@ def bathy_ref_lines(current_data):
plotaxes.ylimits = ylimits
plotaxes.axescmd = 'subplot(1,2,2)'
plotaxes.afteraxes = pcolor_afteraxes
# add_speed(plotaxes,2,bounds=[0.0,1e-10])
ml_plot.add_speed(plotaxes,2,bounds=internal_speed_limits)
# add_speed(plotaxes,2)
ml_plot.add_land(plotaxes, 2)

# Individual components
Expand All @@ -218,7 +211,6 @@ def bathy_ref_lines(current_data):
plotaxes.ylimits = ylimits
plotaxes.axescmd = 'subplot(2,2,1)'
plotaxes.afteraxes = pcolor_afteraxes
# add_x_velocity(plotaxes,1,bounds=[-1e-10,1e-10])
ml_plot.add_x_velocity(plotaxes,1)
ml_plot.add_land(plotaxes, 1)

Expand All @@ -229,7 +221,6 @@ def bathy_ref_lines(current_data):
plotaxes.ylimits = ylimits
plotaxes.axescmd = 'subplot(2,2,2)'
plotaxes.afteraxes = pcolor_afteraxes
# add_y_velocity(plotaxes,1,bounds=[-0.000125,0.000125])
ml_plot.add_y_velocity(plotaxes,1)
ml_plot.add_land(plotaxes, 1)

Expand All @@ -241,7 +232,6 @@ def bathy_ref_lines(current_data):
plotaxes.ylimits = ylimits
plotaxes.axescmd = 'subplot(2,2,3)'
plotaxes.afteraxes = pcolor_afteraxes
# add_x_velocity(plotaxes,2,bounds=[-1e-10,1e-10])
ml_plot.add_x_velocity(plotaxes,2)
ml_plot.add_land(plotaxes, 2)

Expand All @@ -252,10 +242,9 @@ def bathy_ref_lines(current_data):
plotaxes.ylimits = ylimits
plotaxes.axescmd = 'subplot(2,2,4)'
plotaxes.afteraxes = pcolor_afteraxes
# add_y_velocity(plotaxes,2,bounds=[-0.8e-6,.8e-6])
ml_plot.add_y_velocity(plotaxes,2)

ml_plot.add_land(plotaxes, 2)

# ========================================================================
# Profile Plots
# Note that these are not currently plotted by default - set
Expand All @@ -274,39 +263,40 @@ def bathy_ref_lines(current_data):

# Internal surface
def bathy_profile(current_data):
return current_data.x[:, slice_index], b(current_data)[:, slice_index]
return current_data.x[:, slice_index], \
ml_plot.b(current_data)[:, slice_index]

def lower_surface(current_data):
if multilayer_data.init_type == 2:
return current_data.x[:, slice_index], \
eta2(current_data)[:, slice_index]
ml_plot.eta2(current_data)[:, slice_index]
elif multilayer_data.init_type == 6:
return current_data.y[slice_index, :], \
eta2(current_data)[slice_index, :]
ml_plot.eta2(current_data)[slice_index, :]

def upper_surface(current_data):
if multilayer_data.init_type == 2:
return current_data.x[:, slice_index], \
eta1(current_data)[:, slice_index]
ml_plot.eta1(current_data)[:, slice_index]
elif multilayer_data.init_type == 6:
return current_data.y[slice_index, :], \
eta1(current_data)[slice_index, :]
ml_plot.eta1(current_data)[slice_index, :]

def top_speed(current_data):
if multilayer_data.init_type == 2:
return current_data.x[:, slice_index], \
water_u1(current_data)[:, slice_index]
ml_plot.water_u1(current_data)[:, slice_index]
elif multilayer_data.init_type == 6:
return current_data.y[slice_index, :], \
water_u1(current_data)[slice_index, :]
ml_plot.water_u1(current_data)[slice_index, :]

def bottom_speed(current_data):
if multilayer_data.init_type == 2:
return current_data.x[:, slice_index], \
water_u2(current_data)[:, slice_index]
ml_plot.water_u2(current_data)[:, slice_index]
elif multilayer_data.init_type == 6:
return current_data.y[slice_index, :], \
water_u2(current_data)[slice_index, :]
ml_plot.water_u2(current_data)[slice_index, :]

# Bathy
plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data')
Expand Down
28 changes: 14 additions & 14 deletions examples/multi-layer/plane_wave/setrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
that will be read in by the Fortran code.
"""

from __future__ import absolute_import
from __future__ import print_function
import numpy
import os

import numpy as np

import clawpack.geoclaw.data
import clawpack.geoclaw.topotools as tt


# Rotation transformations
def transform_c2p(x,y,x0,y0,theta):
return ((x+x0)*numpy.cos(theta) - (y+y0)*numpy.sin(theta),
(x+x0)*numpy.sin(theta) + (y+y0)*numpy.cos(theta))
return ((x+x0)*np.cos(theta) - (y+y0)*np.sin(theta),
(x+x0)*np.sin(theta) + (y+y0)*np.cos(theta))

def transform_p2c(x,y,x0,y0,theta):
return ( x*numpy.cos(theta) + y*numpy.sin(theta) - x0,
-x*numpy.sin(theta) + y*numpy.cos(theta) - y0)
return ( x*np.cos(theta) + y*np.sin(theta) - x0,
-x*np.sin(theta) + y*np.cos(theta) - y0)


# Class containing some setup for the qinit especially for multilayer tests
Expand Down Expand Up @@ -300,15 +300,15 @@ def setrun(claw_pkg='geoclaw'):
# Do not checkpoint at all
pass

elif numpy.abs(clawdata.checkpt_style) == 1:
elif np.abs(clawdata.checkpt_style) == 1:
# Checkpoint only at tfinal.
pass

elif numpy.abs(clawdata.checkpt_style) == 2:
elif np.abs(clawdata.checkpt_style) == 2:
# Specify a list of checkpoint times.
clawdata.checkpt_times = [0.1,0.15]

elif numpy.abs(clawdata.checkpt_style) == 3:
elif np.abs(clawdata.checkpt_style) == 3:
# Checkpoint every checkpt_interval timesteps (on Level 1)
# and at the final time.
clawdata.checkpt_interval = 5
Expand Down Expand Up @@ -384,8 +384,8 @@ def setrun(claw_pkg='geoclaw'):
for (i,x_c) in enumerate(gauge_locations):
# y0 = (self.run_data.clawdata.yupper - self.run_data.clawdata.ylower) / 2.0
# x_p,y_p = transform_c2p(x_c,0.0,location[0],location[1],angle)
x_p = x_c * numpy.cos(0.0)
y_p = x_c * numpy.sin(0.0)
x_p = x_c * np.cos(0.0)
y_p = x_c * np.sin(0.0)
# print "+=====+"
# print x_c,0.0
# print x_p,y_p
Expand Down Expand Up @@ -487,10 +487,10 @@ def write_topo_file(run_data, out_file, **kwargs):
# Make topography
topo_func = lambda x, y: bathy_step(x, y, **kwargs)
topo = tt.Topography(topo_func=topo_func)
topo.x = numpy.linspace(run_data.clawdata.lower[0],
topo.x = np.linspace(run_data.clawdata.lower[0],
run_data.clawdata.upper[0],
run_data.clawdata.num_cells[0] + 8)
topo.y = numpy.linspace(run_data.clawdata.lower[1],
topo.y = np.linspace(run_data.clawdata.lower[1],
run_data.clawdata.upper[1],
run_data.clawdata.num_cells[1] + 8)
topo.write(out_file)
Expand Down
33 changes: 0 additions & 33 deletions src/2d/bouss/setrun_changes.py

This file was deleted.

Loading
Loading