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

Add CI to fftvis repo #2

Merged
merged 13 commits into from
Feb 20, 2024
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[run]
include = fftvis/*
branch = True

[report]
omit = */tests/*
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
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
18 changes: 18 additions & 0 deletions ci/fftvis_tests.yml
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
16 changes: 16 additions & 0 deletions ci/install_conda.sh
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
2 changes: 1 addition & 1 deletion fftvis/__init__.py
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.
2 changes: 0 additions & 2 deletions fftvis/optimize.py
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


Expand Down
4 changes: 0 additions & 4 deletions fftvis/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

from . import utils
import numpy as np
from typing import Callable
from matvis import conversions

import finufft
import numpy as np
from typing import Callable
from matvis import conversions

Expand Down
Empty file added fftvis/tests/__init__.py
Empty file.
42 changes: 33 additions & 9 deletions fftvis/tests/test_simulate.py
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)
6 changes: 6 additions & 0 deletions fftvis/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest


def test_get_pos_reds():
""" """
pass
5 changes: 5 additions & 0 deletions pyproject.toml
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]
29 changes: 29 additions & 0 deletions setup.cfg
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
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"numpy",
"matvis",
"finufft",
"jax",
"jaxlib",
],
extras_require={
"dev": ["pytest", "pre-commit", "pytest-cov", "hera_sim", "pytest-xdist"]
},
python_requires=">=3.9",
classifiers=[
"Development Status :: 3 - Alpha",
Expand Down
Loading