Skip to content

Commit

Permalink
Merge pull request #258 from MPoL-dev/WIP-v0.3
Browse files Browse the repository at this point in the history
Test and build refactoring
  • Loading branch information
iancze authored Dec 2, 2024
2 parents 84a5d46 + caf9f2a commit 0f357a1
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 235 deletions.
62 changes: 10 additions & 52 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,23 @@ on:
pull_request:

jobs:
dl_files:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies needed to download files
# we're just installing mpol here to reference the zenodo record number
# in __init__. below we'll reinstall for the tests.
run: |
pip install astropy
pip install frank
pip install .
- name: Cache/Restore the .mpol folder cache
uses: actions/cache@v3
env:
cache-name: cache-mpol-dls
with:
# files are stored in .mpol
path: ~/.mpol
# the "key" is the hash of the download script
key: ${{ hashFiles('docs/download_external_files.py') }}
- name: Download large files
run: |
python3 docs/download_external_files.py
tests:
needs: dl_files # don't bother running if we didn't succeed getting the files
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
continue-on-error: ${{ matrix.experimental }}
strategy:
max-parallel: 4
fail-fast: true
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
experimental: [false]
include:
- python-version: "3.13"
experimental: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# cache the Python environment, including installed dependencies
# (unique to each python-version; speeds up tests more than caching pip cache)
- name: Cache/Restore the Python env
uses: actions/cache@v3
env:
cache-name: cache-python${{ matrix.python-version }}-env
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
- name: Install pip
run: |
pip install --upgrade pip
Expand All @@ -71,15 +38,6 @@ jobs:
- name: Check types with MyPy
run: |
mypy src/mpol --pretty
- name: Cache/Restore the .mpol folder cache
uses: actions/cache@v3
env:
cache-name: cache-mpol-dls
with:
# files are stored in .mpol
path: ~/.mpol
# the "key" is the hash of the download script
key: ${{ hashFiles('docs/download_external_files.py') }}
- name: Run tests with coverage
run: |
pytest --cov=mpol
3 changes: 1 addition & 2 deletions src/mpol/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def __init__(
# store taper to register so it transfers to GPU
self.register_buffer("taper_2D", torch.tensor(taper_2D, dtype=torch.float32))

def forward(self, packed_cube):
def forward(self, packed_cube, thresh=1e-6):
r"""
Convolve a packed_cube image with a 2D Gaussian PSF. Operation is carried out
in the Fourier domain using a Gaussian taper.
Expand Down Expand Up @@ -400,7 +400,6 @@ def forward(self, packed_cube):
convolved_packed_cube = torch.fft.ifftn(tapered_vis, dim=(1, 2))

# assert imaginaries are effectively zero, otherwise something went wrong
thresh = 1e-7
assert (
torch.max(convolved_packed_cube.imag) < thresh
), "Round-tripped image contains max imaginary value {:} > {:} threshold, something may be amiss.".format(
Expand Down
Loading

0 comments on commit 0f357a1

Please sign in to comment.