Skip to content

Commit

Permalink
Towards 0.2.0 (#194)
Browse files Browse the repository at this point in the history
* display_complex_field (#193)
* deprecation warning for plot_complex_field in favor of display_complex_field
* updated save_video and notebooks
* points_on_circle, unit_fibonacci_sphere, circ_mask, bli_function are not private anymore
* added css and js files to paths for build_docs action
* removed __about__
* removed transformations module
* added more tests for signal_processing
* update docs and example with display_complex_field
  • Loading branch information
astanziola authored Jun 29, 2023
1 parent 2366bf8 commit 8a06c74
Show file tree
Hide file tree
Showing 44 changed files with 878 additions and 896 deletions.
3 changes: 3 additions & 0 deletions .github/actions/python-poetry-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ runs:
- name: Create virtual environment
run: poetry install --with=dev
shell: bash
- name: Install jaxlib
run: poetry run pip install jax[cpu]
shell: bash
25 changes: 25 additions & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This is a workflow that runs whenever a pull request
# changes some documentation files or the mkdocs.yml file. It
# checks that the documentation builds correctly.

name: Build Docs

on:
pull_request:
paths:
- 'docs/**'
- 'mkdocs.yml'
- '**.md'
- '**.ipynb'
- '**.sh'
- '**.css'
- '**.js'

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/python-poetry-env
- name: Build docs
run: poetry run mkdocs build
34 changes: 34 additions & 0 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow runs both the regression tests and the unit/integration tests.
# It is triggered on push to the main branch.

name: CI

on:
push:
branches: [ main ]

jobs:
full_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/python-poetry-env
- name: Downloading test data
run: |
make get_test_data
- name: Running Regression Tests
run: |
poetry run coverage run --source=jwave -m pytest -xvs ./tests/regression_tests
- name: Remove coverage data from regression tests
run: |
rm ./.coverage
- name: Running Unit and Integration tests
run: |
poetry run coverage run --source=jwave -m pytest -xvs --ignore=tests/regression_tests
poetry run coverage xml
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
name: codecov-umbrella
20 changes: 20 additions & 0 deletions .github/workflows/regression_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This is a workflow for Regression Tests.
# It is triggered by a pull request to the main branch.

name: Regression Tests

on:
pull_request:
branches: [ main ]

jobs:
regression_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/python-poetry-env
- name: Downloading test data
run: |
make get_test_data
- name: Running tests
run: poetry run coverage run --source=jwave -m pytest -xvs ./tests/regression_tests
76 changes: 0 additions & 76 deletions .github/workflows/tests.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/unit_integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is a workflow for Unit, Integration, and Regression Tests
# It is used to test the code on every pull request, whenever a
# python, matlab, yaml, makefile, or markdown file is changed.

name: Unit and Integration Tests

on:
pull_request:
paths:
- '**.py'
- '**.m'
- '**.yaml'
- '**Makefile'

jobs:
unit_and_integration_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/python-poetry-env
- name: Downloading test data
run: |
make get_test_data
- name: Running tests
run: |
poetry run coverage run --source=jwave -m pytest -xvs --ignore=tests/regression_tests
poetry run coverage xml
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
name: codecov-umbrella
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Refactored `save_video` to use opencv.

### Deprecated
- `plot_complex_field` has been deprecated in favor of `display_complex_field`

### Removed
- Removed the uncertainty propagation notebook example. For a more in depth example of using linear uncertainty propagation see [this repository](https://github.com/ucl-bug/linear-uncertainty)

### Added
- Exposed `points_on_circle` function to generate points on a circle
- Exposed `unit_fibonacci_sphere` function
- Exposed `fibonacci_sphere` function
- Exposed `sphere_mask` function for creating spherical binary masks
- Exposed `circ_mask` function for creating circular binary masks
- Exposed bli_function that is used to compute the band limited interpolant

## [0.1.3] - 2023-06-28
### Added
Expand Down Expand Up @@ -69,4 +85,3 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
[0.0.3]: https://github.com/ucl-bug/jwave/compare/0.0.2...0.0.3
[0.0.2]: https://github.com/ucl-bug/jwave/compare/0.0.1...0.0.2
[0.0.1]: https://github.com/ucl-bug/jwave/releases/tag/0.0.1

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[![Support](https://dcbadge.vercel.app/api/server/VtUb4fFznt?style=flat)](https://discord.gg/VtUb4fFznt)
[![License: LGPL v3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](LICENSE)
[![Continous Integration](https://github.com/ucl-bug/jwave/actions/workflows/tests.yml/badge.svg)](https://github.com/ucl-bug/jwave/actions/workflows/tests.yml)
[![Continous Integration](https://github.com/ucl-bug/jwave/actions/workflows/ci_tests.yml/badge.svg)](https://github.com/ucl-bug/jwave/actions/workflows/ci_tests.yml)
[![codecov](https://codecov.io/gh/ucl-bug/jwave/branch/main/graph/badge.svg?token=6J03OMVJS1)](https://codecov.io/gh/ucl-bug/jwave)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ucl-bug/jwave/main?labpath=docs%2Fnotebooks%2Fivp%2Fhomogeneous_medium.ipynb)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1xAHAognF1v9un6GNvaGPSfdVeCDK8l9z?usp=sharing)
Expand Down
2 changes: 1 addition & 1 deletion docs/api_utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
handler: python
members:
- is_numeric
- plot_complex_field
- display_complex_field
show_root_heading: true
show_source: false
16 changes: 8 additions & 8 deletions docs/notebooks/harmonic/helmholtz_problem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"from matplotlib import pyplot as plt\n",
"\n",
"from jwave import FiniteDifferences, FourierSeries\n",
"from jwave.geometry import Domain, Medium, _circ_mask\n",
"from jwave.utils import plot_complex_field, show_positive_field\n",
"from jwave.geometry import Domain, Medium, circ_mask\n",
"from jwave.utils import display_complex_field, show_positive_field\n",
"\n",
"key = random.PRNGKey(42) # Random seed"
]
Expand Down Expand Up @@ -104,7 +104,7 @@
"src = FourierSeries(jnp.expand_dims(src_field, -1), domain) * omega\n",
"\n",
"# Plotting\n",
"_ = plot_complex_field(src)"
"_ = display_complex_field(src)"
]
},
{
Expand All @@ -119,8 +119,8 @@
"sound_speed = sound_speed.at[20:105, 20:200].set(1.0)\n",
"sound_speed = (\n",
" sound_speed\n",
" * (1 - _circ_mask(N, 90, [64, 180]))\n",
" * (1 - _circ_mask(N, 50, [64, 22]))\n",
" * (1 - circ_mask(N, 90, [64, 180]))\n",
" * (1 - circ_mask(N, 50, [64, 22]))\n",
" * 0.5\n",
" + 1\n",
")\n",
Expand Down Expand Up @@ -170,7 +170,7 @@
}
],
"source": [
"_ = plot_complex_field(field, max_intensity=2e5)"
"_ = display_complex_field(field, max_intensity=2e5)"
]
},
{
Expand Down Expand Up @@ -272,7 +272,7 @@
"source": [
"# Solve new problem\n",
"field = solve_helmholtz(medium, params)\n",
"_ = plot_complex_field(field, max_intensity=2e5)"
"_ = display_complex_field(field, max_intensity=2e5)"
]
},
{
Expand Down Expand Up @@ -316,7 +316,7 @@
"\n",
"# Solve new problem\n",
"field = solve_helmholtz(medium, params)\n",
"_ = plot_complex_field(field, max_intensity=2e5)"
"_ = display_complex_field(field, max_intensity=2e5)"
]
},
{
Expand Down
31 changes: 19 additions & 12 deletions docs/notebooks/harmonic/helmholtz_solver_differentiable.ipynb

Large diffs are not rendered by default.

55 changes: 27 additions & 28 deletions docs/notebooks/ivp/3d.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/notebooks/ivp/custom_sensors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"from jwave import FourierSeries\n",
"from jwave.acoustics import simulate_wave_propagation\n",
"from jwave.geometry import *\n",
"from jwave.geometry import _circ_mask\n",
"from jwave.geometry import circ_mask\n",
"from jwave.utils import show_field\n",
"\n",
"domain = Domain((128, 128), (0.1e-3, 0.1e-3))\n",
Expand All @@ -48,10 +48,10 @@
"# Defining the initial pressure\n",
"\n",
"N = domain.N\n",
"mask1 = _circ_mask(N, 8, (50, 50))\n",
"mask2 = _circ_mask(N, 5, (80, 60))\n",
"mask3 = _circ_mask(N, 10, (64, 64))\n",
"mask4 = _circ_mask(N, 30, (64, 64))\n",
"mask1 = circ_mask(N, 8, (50, 50))\n",
"mask2 = circ_mask(N, 5, (80, 60))\n",
"mask3 = circ_mask(N, 10, (64, 64))\n",
"mask4 = circ_mask(N, 30, (64, 64))\n",
"p0 = 5.0 * mask1 + 3.0 * mask2 + 4.0 * mask3 + 0.5 * mask4\n",
"\n",
"p0 = 1.0 * jnp.expand_dims(p0, -1)\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/ivp/different_discretizations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"metadata": {},
"outputs": [],
"source": [
"from jwave.geometry import Domain, Medium, TimeAxis, _circ_mask\n",
"from jwave.geometry import Domain, Medium, TimeAxis, circ_mask\n",
"from jwave.acoustics.time_varying import simulate_wave_propagation\n",
"from jwave import FiniteDifferences, FourierSeries\n",
"from jwave.signal_processing import smooth\n",
Expand Down Expand Up @@ -50,7 +50,7 @@
"\n",
"# Smoothed initial pressure distribution\n",
"Nx = domain.N\n",
"p0 = 5.0 * _circ_mask(Nx, 5, (128, 40))\n",
"p0 = 5.0 * circ_mask(Nx, 5, (128, 40))\n",
"p0 = smooth(p0)\n",
"\n",
"# Getting time axis\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/notebooks/ivp/heterogeneous_medium.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"from jwave import FourierSeries\n",
"from jwave.acoustics import simulate_wave_propagation\n",
"from jwave.geometry import *\n",
"from jwave.geometry import _circ_mask\n",
"from jwave.geometry import circ_mask\n",
"from jwave.utils import show_field, show_positive_field\n",
"\n",
"domain = Domain((128, 128), (0.1e-3, 0.1e-3))"
Expand Down Expand Up @@ -87,7 +87,7 @@
"# Defining the initial pressure\n",
"\n",
"N = domain.N\n",
"p0 = _circ_mask(N, 3, (64, 30))\n",
"p0 = circ_mask(N, 3, (64, 30))\n",
"\n",
"p0 = 1.0 * jnp.expand_dims(p0, -1)\n",
"p0 = FourierSeries(p0, domain)"
Expand Down Expand Up @@ -244,7 +244,7 @@
"density = FiniteDifferences(np.expand_dims(density, -1), domain, accuracy=8)\n",
"\n",
"N = domain.N\n",
"p0 = _circ_mask(N, 3, (64, 30))\n",
"p0 = circ_mask(N, 3, (64, 30))\n",
"\n",
"p0 = 1.0 * jnp.expand_dims(p0, -1)\n",
"p0 = FiniteDifferences(p0, domain, accuracy=8)"
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/ivp/homogeneous_medium.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@
"from jax import numpy as jnp\n",
"\n",
"from jwave import FourierSeries\n",
"from jwave.geometry import _circ_mask\n",
"from jwave.geometry import circ_mask\n",
"\n",
"p0 = 1.0 * jnp.expand_dims(_circ_mask(N, 4, (80, 60)), -1)\n",
"p0 = 1.0 * jnp.expand_dims(circ_mask(N, 4, (80, 60)), -1)\n",
"p0 = FourierSeries(p0, domain)"
]
},
Expand Down
Loading

0 comments on commit 8a06c74

Please sign in to comment.