-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Package using pyproject.toml * Begin tests * Refactor elevation * Refactor gravity function * A few more basic tests * Add a basic CI
- Loading branch information
1 parent
b75c94f
commit a20591a
Showing
6 changed files
with
143 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install -U pip pytest | ||
pip install -U . | ||
- name: Run tests | ||
run: pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[project] | ||
name = "2wave" | ||
description = "Hydrodynamic modulation for short gravity waves riding on longer waves" | ||
version = "0.1.0" | ||
readme = "README.md" | ||
requires-python = ">=3.10" | ||
license = {text = "MIT"} | ||
authors = [ | ||
{ name="Milan Curcic", email="[email protected]" }, | ||
] | ||
dependencies = [ | ||
"numpy", | ||
"rich", | ||
"xarray", | ||
] | ||
|
||
[tool.setuptools] | ||
py-modules = ["twowave"] | ||
|
||
[tool.pytest.ini_options] | ||
testpaths = ["test_twowave.py"] | ||
addopts = "-v" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import numpy as np | ||
from twowave import angular_frequency, elevation, gravity, WaveModulationModel | ||
import xarray as xr | ||
|
||
|
||
G0 = 9.8 | ||
|
||
|
||
def test_angular_frequency(): | ||
assert angular_frequency(G0, 1) == np.sqrt(G0) | ||
assert angular_frequency(G0, 1, 1) == np.sqrt(G0) + 1 | ||
|
||
|
||
def test_elevation(): | ||
assert elevation(0, 0, 1, 1, 1, wave_type="linear") == 1 | ||
|
||
|
||
def test_gravity(): | ||
assert gravity(0, 0, 0, 1, G0, wave_type="linear") == G0 | ||
assert gravity(0, 0, 0, 1, G0, wave_type="stokes") == G0 | ||
|
||
|
||
def test_wave_modulation_model(): | ||
m = WaveModulationModel(num_periods=1) | ||
m.run() | ||
ds = m.to_xarray() | ||
assert type(ds) == xr.Dataset | ||
assert np.all(np.isfinite(ds.wavenumber)) | ||
assert np.all(np.isfinite(ds.amplitude)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters