Skip to content

Commit

Permalink
Merge pull request #39 from e-koch/shape_check_fix
Browse files Browse the repository at this point in the history
Shape check fix and tests fix with version updates
  • Loading branch information
e-koch authored Jun 4, 2024
2 parents d491f5f + 0a04650 commit d05bd34
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: "3.10"
name: Python 3.10 with minimal dependencies
toxenv: py310-test
- os: ubuntu-latest
python-version: 3.11
name: Python 3.11 with minimal dependencies
toxenv: py311-test
- os: ubuntu-latest
python-version: 3.9
name: Python 3.9 with minimal dependencies
Expand Down Expand Up @@ -42,9 +50,15 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install testing dependencies
run: python -m pip install tox codecov
run: |
python -m pip install tox codecov
mkdir ${GITHUB_WORKSPACE}/.casa
echo "datapath=['${GITHUB_WORKSPACE}/.casa/']; measurespath=datapath[0]; measures_auto_update=True; data_auto_update=True" > $GITHUB_WORKSPACE/config.py
pip install casadata
export CASASITECONFIG=$GITHUB_WORKSPACE/config.py
- name: Run tests with ${{ matrix.name }}
run: tox -v -e ${{ matrix.toxenv }}
run: CASASITECONFIG=$GITHUB_WORKSPACE/config.py tox -v -e ${{ matrix.toxenv }}
- name: Upload coverage to codecov
if: ${{ contains(matrix.toxenv,'-cov') }}
uses: codecov/[email protected]
Expand Down
5 changes: 3 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version: 2

build:
image: latest
os: "ubuntu-20.04"
tools:
python: "3.12"

# Install regular dependencies.
python:
version: 3.8
install:
- method: pip
path: .
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{36,37,38,39}-test{,-all,-dev,-novis,-cov}
py{36,37,38,39,310,311}-test{,-all,-dev,-novis,-cov}
build_docs
codestyle
requires =
Expand All @@ -18,6 +18,7 @@ passenv =
LC_ALL
LC_CTYPE
ON_TRAVIS
CASASITECONFIG
changedir =
.tmp/{envname}
description =
Expand Down
11 changes: 9 additions & 2 deletions uvcombine/tests/test_feather.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ def test_feather_simple(plaw_test_data):
assert nmse < 3e-2

# Test against structural similarity metric
ssim = structural_similarity(orig_data, combo.real)
min_val = min(orig_data.min(), combo.real.min())
max_val = max(orig_data.max(), combo.real.max())
ssim = structural_similarity(orig_data, combo.real,
data_range=max_val-min_val)
assert ssim > 0.99


Expand Down Expand Up @@ -191,9 +194,13 @@ def test_feather_simple_cube(cube_data, use_dask, use_memmap):
# Test against structural similarity metric
# Compare channel vs. channel
for ii in range(orig_cube.shape[0]):
min_val = min(orig_cube.unitless_filled_data[ii].min(),
combo_cube_sc.unitless_filled_data[ii].min())
max_val = max(orig_cube.unitless_filled_data[ii].max(),
combo_cube_sc.unitless_filled_data[ii].max())
ssim = structural_similarity(orig_cube.unitless_filled_data[ii],
combo_cube_sc.unitless_filled_data[ii],
)
data_range=max_val - min_val)
assert ssim > 0.99


Expand Down
6 changes: 3 additions & 3 deletions uvcombine/uvcombine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ def feather_simple_cube(cube_hi, cube_lo,
cube_hi.allow_huge_operations = allow_huge_operations
cube_lo.allow_huge_operations = allow_huge_operations

if cube_lo.shape[0] == cube_hi.shape[1]:
if cube_lo.shape[0] == cube_hi.shape[0]:
is_spec_matched = np.isclose(cube_lo.spectral_axis, cube_hi.spectral_axis).all()
else:
is_spec_matched = False
Expand Down Expand Up @@ -1160,11 +1160,11 @@ def feather_simple_cube(cube_hi, cube_lo,
# Check that we have a single chunk size in the spatial dimensions.
# This is required for the fft per plane for feathering.
has_one_spatial_chunk_hi = cube_hi.shape[1:] == cube_hi._data.chunksize[1:]
has_one_spatial_chunk_lo = cube_lo.shape[1:] == cube_lo._data.chunksize[1:]
has_one_spatial_chunk_lo = cube_lo_reproj.shape[1:] == cube_lo_reproj._data.chunksize[1:]

if not has_one_spatial_chunk_hi or not has_one_spatial_chunk_lo:
raise ValueError("Cubes must have a single chunk along the spatial axes."
f" cube_lo has chunksize: {cube_lo._data.chunksize}."
f" cube_lo has chunksize: {cube_lo_reproj._data.chunksize}."
f" cube_hi has chunksize: {cube_hi._data.chunksize}."
" Enable `force_spatial_rechunk=True` to rechunk the cubes.")

Expand Down

0 comments on commit d05bd34

Please sign in to comment.