-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from tyler-a-cox/add_testing
Add CI to fftvis repo
- Loading branch information
Showing
14 changed files
with
166 additions
and
16 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,6 @@ | ||
[run] | ||
include = fftvis/* | ||
branch = True | ||
|
||
[report] | ||
omit = */tests/* |
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,47 @@ | ||
name: Run Tests | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
python-version: [3.9, "3.10", "3.11", "3.12"] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install | ||
run: | | ||
pip install --upgrade pip | ||
pip install .[dev] | ||
- name: Run Tests | ||
run: | | ||
python -m pytest --cov=fftvis --cov-config=./.coveragerc --cov-report xml:./coverage.xml --durations=15 | ||
- name: Upload coverage report | ||
if: matrix.os == 'ubuntu-latest' && success() | ||
uses: codecov/codecov-action@v3.1.3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
file: ./coverage.xml | ||
flags: unittests | ||
name: codecov-umbrella | ||
fail_ci_if_error: true |
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,18 @@ | ||
name: fftvis_tests | ||
channels: | ||
- conda-forge | ||
- defaults | ||
dependencies: | ||
- pip | ||
- astropy | ||
- numpy | ||
- pytest | ||
- scipy | ||
- pyyaml | ||
- pycodestyle | ||
- psutil | ||
- astropy-healpix | ||
- future | ||
- pytest-cov | ||
- finufft | ||
- matvis |
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,16 @@ | ||
set -xe | ||
|
||
conda config --set always_yes yes --set changeps1 no | ||
conda update -q conda | ||
conda info -a | ||
conda create --name=${ENV_NAME} python=$PYTHON --quiet | ||
conda env update -n ${ENV_NAME} -f ci/${ENV_NAME}.yml | ||
source activate ${ENV_NAME} | ||
|
||
|
||
conda list -n ${ENV_NAME} | ||
# check that the python version matches the desired one; exit immediately if not | ||
PYVER=`python -c "from __future__ import print_function; import sys; print('{:d}.{:d}'.format(sys.version_info.major, sys.version_info.minor))"` | ||
if [[ $PYVER != $PYTHON ]]; then | ||
exit 1; | ||
fi |
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 |
---|---|---|
@@ -1 +1 @@ | ||
from . import beam, optimize, utils, simulate | ||
from . import beams, optimize, utils, simulate |
File renamed without changes.
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import optax | ||
import jax_finufft | ||
from jax import numpy as jnp | ||
|
||
|
||
|
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
Empty file.
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 |
---|---|---|
@@ -1,20 +1,44 @@ | ||
import matvis | ||
import pytest | ||
import numpy as np | ||
from fftvis import simulate | ||
from pyuvsim.analyticbeam import AnalyticBeam | ||
|
||
|
||
def test_simulate(): | ||
""" """ | ||
pass | ||
# Simulation parameters | ||
ntimes = 10 | ||
nfreqs = 5 | ||
nants = 3 | ||
nsrcs = 20 | ||
|
||
# Set random set | ||
np.random.seed(42) | ||
|
||
def test_evaluate_beam(): | ||
""" """ | ||
pass | ||
# Define frequency and time range | ||
freqs = np.linspace(100e6, 200e6, nfreqs) | ||
lsts = np.linspace(0, np.pi, ntimes) | ||
|
||
# Set up the antenna positions | ||
antpos = {k: np.array([k * 10, 0, 0]) for k in range(nants)} | ||
|
||
def test_simulate_basis(): | ||
""" """ | ||
# TODO: test single polarization visibility simulation | ||
# Define a Gaussian beam | ||
beam = AnalyticBeam("gaussian", diameter=14.0) | ||
|
||
# Set sky model | ||
ra = np.linspace(0.0, 2.0 * np.pi, nsrcs) | ||
dec = np.linspace(-0.5 * np.pi, 0.5 * np.pi, nsrcs) | ||
sky_model = np.random.uniform(0, 1, size=(nsrcs, 1)) * (freqs[None] / 150e6) ** -2.5 | ||
|
||
# Use matvis as a reference | ||
mvis = matvis.simulate_vis( | ||
antpos, sky_model, ra, dec, freqs, lsts, beams=[beam], precision=2 | ||
) | ||
|
||
# Use fftvis to simulate visibilities | ||
fvis = simulate.simulate_vis( | ||
antpos, sky_model, ra, dec, freqs, lsts, beam, precision=2, accuracy=1e-10 | ||
) | ||
|
||
# TODO: test multiple polarization visibility simulations | ||
pass | ||
# assert np.allclose(mvis, fvis, atol=1e-5) |
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,6 @@ | ||
import pytest | ||
|
||
|
||
def test_get_pos_reds(): | ||
""" """ | ||
pass |
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,5 @@ | ||
[build-system] | ||
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools_scm] |
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 @@ | ||
[metadata] | ||
name = matvis | ||
description = An FFT-based visibility simulator | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/tyler-a-cox/fftvis | ||
author = Tyler Cox | ||
author_email = tyler.a.cox@berkeley.edu | ||
license = MIT | ||
license_files = LICENSE.txt | ||
platforms = any | ||
classifiers = | ||
Development Status :: 4 - Beta | ||
License :: OSI Approved :: MIT License | ||
Programming Language :: Python | ||
Programming Language :: Python :: 3 | ||
Programming Language :: Python :: 3 :: Only | ||
|
||
[aliases] | ||
test=pytest | ||
|
||
|
||
[pycodestyle] | ||
ignore = E402,E501,W291,W293,W503,W601 | ||
filename = *.py | ||
exclude = build/,docs/,.pytest_cache,.svn,CVS,.bzr,.hg,.git,__pycache__,dist/,scripts/,hera_cal.egg-info,hera_cal/data/ | ||
|
||
[pydocstyle] | ||
convention = numpy |
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