Skip to content

Commit cf0c4b1

Browse files
authored
Merge pull request #3 from GalSim-developers/update-tests-ii-test-ne
test: update test_ne to run more tests and to pass more easily for flux
2 parents 0354182 + df6decf commit cf0c4b1

2 files changed

Lines changed: 30 additions & 53 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,11 @@ jobs:
2626
matrix:
2727
# First all python versions in basic linux
2828
os: [ ubuntu-latest ]
29-
py: [ 3.7, 3.8, 3.9, "3.10", 3.11, 3.12 ]
29+
py: [ "3.12" ]
3030
CC: [ gcc ]
3131
CXX: [ g++ ]
3232
FFTW_DIR: [ "/usr/local/lib" ]
3333

34-
# Add some other particular combinations to test
35-
include:
36-
# Just one in MacOS, since GitHub actions seems to have some kind of
37-
# system problem where seg faults happen randomly on their Mac machines.
38-
# Usually just restarting will fix it, but that's annoying, so minimize
39-
# that by only having one of these to fight with.
40-
- os: macos-latest
41-
py: "3.10"
42-
CC: cc
43-
CXX: c++
44-
FFTW_DIR: "/opt/homebrew/lib/"
45-
46-
# Check one with clang compiler
47-
- os: ubuntu-latest
48-
py: "3.10"
49-
CC: clang
50-
CXX: clang++
51-
FFTW_DIR: "/usr/local/lib/"
52-
53-
# And a pypy system.
54-
# As of 12/1/2022, this is broken for astropy.
55-
# pypy3 used to work, but that's Py 3.6, and GHA no longer supports it.
56-
# Maybe revisit at some point. Or maybe don't care too much about pypy...
57-
#- os: ubuntu-latest
58-
#py: pypy-3.7
59-
#CC: gcc
60-
#CXX: g++
61-
6234
env:
6335
FFTW_DIR: ${{ matrix.FFTW_DIR }}
6436

tests/test_interpolatedimage.py

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,7 @@ def test_ne(ref):
16621662
unequal InterpolatedImages or InterpolatedKImages may be the same due to truncation.
16631663
"""
16641664
final, ref_image = ref
1665-
obj1 = galsim.InterpolatedImage(ref_image, flux=20, calculate_maxk=False, calculate_stepk=False)
1665+
obj1 = galsim.InterpolatedImage(ref_image, flux=2e6, calculate_maxk=False, calculate_stepk=False)
16661666

16671667
# Copy ref_image and perturb it slightly in the middle, away from where the InterpolatedImage
16681668
# repr string will report.
@@ -1671,7 +1671,7 @@ def test_ne(ref):
16711671
perturb_image._array = perturb_image._array.at[64, 64].set(perturb_image._array[64, 64] * 100)
16721672
else:
16731673
perturb_image.array[64, 64] *= 100
1674-
obj2 = galsim.InterpolatedImage(perturb_image, flux=20, calculate_maxk=False, calculate_stepk=False)
1674+
obj2 = galsim.InterpolatedImage(perturb_image, flux=2e6, calculate_maxk=False, calculate_stepk=False)
16751675

16761676
with galsim.utilities.printoptions(threshold=128*128):
16771677
assert repr(obj1) != repr(obj2), "Reprs unexpectedly agree: %r"%obj1
@@ -1682,6 +1682,33 @@ def test_ne(ref):
16821682

16831683
assert obj1 != obj2
16841684

1685+
# Test that slightly different objects compare and hash appropriately.
1686+
gsp = galsim.GSParams(maxk_threshold=1.1e-3, folding_threshold=5.1e-3)
1687+
gals = [galsim.InterpolatedImage(ref_image),
1688+
galsim.InterpolatedImage(ref_image, calculate_maxk=False),
1689+
galsim.InterpolatedImage(ref_image, calculate_stepk=False),
1690+
galsim.InterpolatedImage(ref_image, flux=1.1),
1691+
galsim.InterpolatedImage(ref_image, offset=(0.0, 1.1)),
1692+
galsim.InterpolatedImage(ref_image, x_interpolant='Linear'),
1693+
galsim.InterpolatedImage(ref_image, k_interpolant='Linear'),
1694+
galsim.InterpolatedImage(ref_image, pad_factor=1.),
1695+
galsim.InterpolatedImage(ref_image, normalization='sb'),
1696+
galsim.InterpolatedImage(ref_image, _force_stepk=1.0),
1697+
galsim.InterpolatedImage(ref_image, _force_maxk=1.0),
1698+
galsim.InterpolatedImage(ref_image, scale=0.2),
1699+
galsim.InterpolatedImage(ref_image, use_true_center=False),
1700+
galsim.InterpolatedImage(ref_image, gsparams=gsp)]
1701+
if is_jax_galsim():
1702+
pass
1703+
else:
1704+
gals += [
1705+
galsim.InterpolatedImage(ref_image, noise_pad_size=100, noise_pad=0.1),
1706+
galsim.InterpolatedImage(ref_image, noise_pad_size=100, noise_pad=0.2),
1707+
galsim.InterpolatedImage(ref_image, noise_pad_size=100, noise_pad=0.2),
1708+
]
1709+
1710+
check_all_diff(gals)
1711+
16851712
# Now repeat for InterpolatedKImage
16861713
kim = obj1.drawKImage(nx=128, ny=128, scale=1)
16871714
obj3 = galsim.InterpolatedKImage(kim)
@@ -1703,28 +1730,6 @@ def test_ne(ref):
17031730

17041731
assert obj3 != obj4
17051732

1706-
# Test that slightly different objects compare and hash appropriately.
1707-
gsp = galsim.GSParams(maxk_threshold=1.1e-3, folding_threshold=5.1e-3)
1708-
gals = [galsim.InterpolatedImage(ref_image),
1709-
galsim.InterpolatedImage(ref_image, calculate_maxk=False),
1710-
galsim.InterpolatedImage(ref_image, calculate_stepk=False),
1711-
galsim.InterpolatedImage(ref_image, flux=1.1),
1712-
galsim.InterpolatedImage(ref_image, offset=(0.0, 1.1)),
1713-
galsim.InterpolatedImage(ref_image, x_interpolant='Linear'),
1714-
galsim.InterpolatedImage(ref_image, k_interpolant='Linear'),
1715-
galsim.InterpolatedImage(ref_image, pad_factor=1.),
1716-
galsim.InterpolatedImage(ref_image, normalization='sb'),
1717-
galsim.InterpolatedImage(ref_image, noise_pad_size=100, noise_pad=0.1),
1718-
galsim.InterpolatedImage(ref_image, noise_pad_size=100, noise_pad=0.2),
1719-
galsim.InterpolatedImage(ref_image, noise_pad_size=100, noise_pad=0.2),
1720-
galsim.InterpolatedImage(ref_image, _force_stepk=1.0),
1721-
galsim.InterpolatedImage(ref_image, _force_maxk=1.0),
1722-
galsim.InterpolatedImage(ref_image, scale=0.2),
1723-
galsim.InterpolatedImage(ref_image, use_true_center=False),
1724-
galsim.InterpolatedImage(ref_image, gsparams=gsp)]
1725-
check_all_diff(gals)
1726-
1727-
# And repeat for InterpolatedKImage
17281733
gals = [galsim.InterpolatedKImage(kim),
17291734
galsim.InterpolatedKImage(kim, k_interpolant='Linear'),
17301735
galsim.InterpolatedKImage(kim, stepk=1.1),

0 commit comments

Comments
 (0)