Skip to content

Commit

Permalink
Don't do timing tests on GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
rmjarvis committed Dec 9, 2024
1 parent b82f920 commit 4dcffce
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
9 changes: 6 additions & 3 deletions tests/test_interpolatedimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
KXVALS = np.array((1.30, 0.71, -4.30)) * np.pi / 2.
KYVALS = np.array((0.80, -0.02, -0.31,)) * np.pi / 2.

# The timing tests can be unreliable in environments with other processes running at the
# same time. So we disable them by default. However, on a clean system, they should all pass.
test_timing = False

@pytest.fixture
def ref():
Expand Down Expand Up @@ -1785,21 +1788,21 @@ def test_depixelize():
# Second time with the same size image is much faster, since uses a cache.
nopix_image2 = im1.depixelize(x_interpolant=interp)
t8 = time.time()
if platform.python_implementation() != 'PyPy':
if test_timing and platform.python_implementation() != 'PyPy':
# PyPy timings can be fairly arbitrary at times.
assert t8-t7 < (t3-t2)/5

# Even if the image is different.
nopix_image3 = im4.depixelize(x_interpolant=interp)
t9 = time.time()
if platform.python_implementation() != 'PyPy':
if test_timing and platform.python_implementation() != 'PyPy':
assert t9-t8 < (t3-t2)/5

# But not if you clear the cache.
galsim.Image.clear_depixelize_cache()
nopix_image4 = im4.depixelize(x_interpolant=interp)
t10 = time.time()
if platform.python_implementation() != 'PyPy':
if test_timing and platform.python_implementation() != 'PyPy':
assert t10-t9 > (t3-t2)/5

print('times:')
Expand Down
7 changes: 6 additions & 1 deletion tests/test_phase_psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

theta0 = (0*galsim.arcmin, 0*galsim.arcmin)

# The timing tests can be unreliable in environments with other processes running at the
# same time. So we disable them by default. However, on a clean system, they should all pass.
test_timing = False


@timer
def test_aperture():
Expand Down Expand Up @@ -1018,7 +1022,8 @@ def test_speedup():
psf.drawImage(method='phot', n_photons=1e3)
t1 = time.time()
print("Time for geometric approximation draw: {:6.4f}s".format(t1-t0))
assert (t1-t0) < 0.1, "Photon-shooting took too long ({0} s).".format(t1-t0)
if test_timing:
assert (t1-t0) < 0.1, "Photon-shooting took too long ({0} s).".format(t1-t0)


@timer
Expand Down
7 changes: 6 additions & 1 deletion tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
import galsim
from galsim_test_helpers import *

# The timing tests can be unreliable in environments with other processes running at the
# same time. So we disable them by default. However, on a clean system, they should all pass.
test_timing = False


@timer
def test_simple():
Expand Down Expand Up @@ -1010,7 +1014,8 @@ def test_resume(run_slow):
decimal=5)
print('Time with resume = ',t_resume)
print('Time without resume = ',t_no_resume)
assert t_resume < t_no_resume
if test_timing:
assert t_resume < t_no_resume

# The resume path should be exactly the same as doing all the photons at once.
sensor3.accumulate(all_photons, im3)
Expand Down
8 changes: 6 additions & 2 deletions tests/test_wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import galsim
from galsim_test_helpers import *

# The timing tests can be unreliable in environments with other processes running at the
# same time. So we disable them by default. However, on a clean system, they should all pass.
test_timing = False


# These positions will be used a few times below, so define them here.
# One of the tests requires that the last pair are integers, so don't change that.
Expand Down Expand Up @@ -3199,10 +3203,10 @@ def test_int_args(run_slow):
# Before fixing #1024, this took about 0.5 sec.
# Now it usually takes about 0.04 sec. Testing at 0.25 seems like a reasonable midpoint.
print('Time = ',t1-t0)
if run_slow:
if test_timing:
# Don't include this in regular unit tests, since it's not really something we need
# to guarantee. This timing estimate is appropriate for my laptop, but maybe not
# all systems. It also fails for pypy on GHA for some reason.
# all systems.
assert t1-t0 < 0.25

posi = galsim.PositionI(5,6)
Expand Down

0 comments on commit 4dcffce

Please sign in to comment.