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

TST fix tests for JAX-Galsim #1252

Open
wants to merge 354 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
354 commits
Select commit Hold shift + click to select a range
f4da2e1
photon array test fixes
beckermr Nov 21, 2023
aee1d8c
file paths
beckermr Nov 21, 2023
8905ef7
file paths
beckermr Nov 21, 2023
3b7020c
file paths
beckermr Nov 21, 2023
a01cc05
file paths
beckermr Nov 21, 2023
41482af
draw exceptions
beckermr Nov 21, 2023
1561a15
array tests
beckermr Nov 21, 2023
1bf8ca9
array tests
beckermr Nov 21, 2023
4bb3fd9
array tests
beckermr Nov 21, 2023
e7778a0
array tests
beckermr Nov 21, 2023
caa88d9
jax no warn
beckermr Nov 21, 2023
a4cb713
jax no warn
beckermr Nov 21, 2023
60424b8
jax no warn
beckermr Nov 21, 2023
efd15fc
jax no warn
beckermr Nov 21, 2023
011944c
jax no warn
beckermr Nov 21, 2023
a7503db
jax no fwd fft complex
beckermr Nov 21, 2023
7131c51
jax no fwd fft complex
beckermr Nov 21, 2023
da8ae43
jax no fwd fft complex
beckermr Nov 21, 2023
3d32477
array compare
beckermr Nov 21, 2023
8b25443
array compare
beckermr Nov 21, 2023
0515ad8
jax rounds a bit different
beckermr Nov 21, 2023
19471ac
jax rounds a bit different
beckermr Nov 21, 2023
6bcd68f
jax rounds a bit different
beckermr Nov 21, 2023
e3c5280
make_const not supported
beckermr Nov 21, 2023
5f55582
paths
beckermr Nov 21, 2023
0d3ca1a
paths
beckermr Nov 21, 2023
c1aa753
paths
beckermr Nov 21, 2023
ac7d4d9
paths
beckermr Nov 21, 2023
51151af
paths
beckermr Nov 21, 2023
b7cad5b
paths
beckermr Nov 21, 2023
030bda0
paths
beckermr Nov 21, 2023
c07af19
support make const
beckermr Nov 21, 2023
3940467
support make const
beckermr Nov 21, 2023
0a92bc4
support make const
beckermr Nov 21, 2023
86682d2
support make const
beckermr Nov 21, 2023
163687f
support make const
beckermr Nov 21, 2023
4cd1536
support make const
beckermr Nov 21, 2023
0952f29
no references
beckermr Nov 21, 2023
f3a65d3
no references
beckermr Nov 21, 2023
7786e37
no references
beckermr Nov 21, 2023
be2e75f
no references
beckermr Nov 21, 2023
2169160
no references
beckermr Nov 21, 2023
bcee242
no references
beckermr Nov 21, 2023
cb75725
no references
beckermr Nov 21, 2023
6214b62
no references
beckermr Nov 21, 2023
5e5b57d
no references
beckermr Nov 21, 2023
1d988d1
no references
beckermr Nov 21, 2023
7191fa0
no references
beckermr Nov 21, 2023
90791a6
weird failure
beckermr Nov 21, 2023
0505fc7
weird failure
beckermr Nov 21, 2023
6b5fa52
weird failure
beckermr Nov 21, 2023
5c838bb
weird failure
beckermr Nov 21, 2023
b2700bb
weird failure
beckermr Nov 21, 2023
ff23b6d
weird failure
beckermr Nov 21, 2023
6539ce1
weird failure
beckermr Nov 21, 2023
46a0e10
weird failure
beckermr Nov 21, 2023
56dc788
weird failure
beckermr Nov 21, 2023
0035409
weird failure
beckermr Nov 21, 2023
b2c451f
paths
beckermr Nov 21, 2023
ed7dae2
paths
beckermr Nov 21, 2023
27bfe2b
paths
beckermr Nov 21, 2023
cc94ba8
paths
beckermr Nov 21, 2023
ad4395d
norefs
beckermr Nov 21, 2023
f3aefd2
norefs
beckermr Nov 21, 2023
5158546
norefs
beckermr Nov 21, 2023
54cffec
norefs
beckermr Nov 21, 2023
ebf552c
norefs
beckermr Nov 21, 2023
da90aac
norefs
beckermr Nov 21, 2023
51a8583
norefs
beckermr Nov 21, 2023
3fbe8d4
norefs
beckermr Nov 21, 2023
e2cfddd
norefs
beckermr Nov 21, 2023
93632df
norefs
beckermr Nov 21, 2023
4ba61f6
paths
beckermr Nov 21, 2023
f6cfcd6
paths
beckermr Nov 21, 2023
53cd860
paths
beckermr Nov 21, 2023
f50323f
norefs
beckermr Nov 21, 2023
2100ade
norefs
beckermr Nov 21, 2023
9e69cc1
norefs
beckermr Nov 21, 2023
b2bcdc9
norefs
beckermr Nov 21, 2023
2ef3457
norefs
beckermr Nov 21, 2023
0994337
norefs
beckermr Nov 21, 2023
458cabb
norefs
beckermr Nov 21, 2023
d2f41ff
norefs
beckermr Nov 21, 2023
52b9910
norefs
beckermr Nov 21, 2023
8427e0b
norefs
beckermr Nov 21, 2023
5e4036a
norefs
beckermr Nov 21, 2023
b2a33fb
norefs
beckermr Nov 21, 2023
a534b6f
norefs
beckermr Nov 21, 2023
eb01912
norefs
beckermr Nov 21, 2023
88d7404
norefs
beckermr Nov 21, 2023
a6c0b3d
norefs
beckermr Nov 21, 2023
913aa52
norefs
beckermr Nov 21, 2023
213823c
norefs
beckermr Nov 21, 2023
cbcf0ec
norefs
beckermr Nov 21, 2023
e222d5e
norefs
beckermr Nov 21, 2023
5dd48a0
norefs
beckermr Nov 21, 2023
2cbb070
norefs
beckermr Nov 21, 2023
0d1dad3
norefs
beckermr Nov 21, 2023
ffe9e8a
norefs
beckermr Nov 21, 2023
caecb71
norefs
beckermr Nov 21, 2023
92a0f0c
norefs
beckermr Nov 21, 2023
7e24347
norefs
beckermr Nov 21, 2023
ac7876a
norefs
beckermr Nov 21, 2023
ad828a4
norefs
beckermr Nov 21, 2023
98346bf
norefs
beckermr Nov 21, 2023
bdeeb71
norefs
beckermr Nov 21, 2023
b4ad42e
norefs
beckermr Nov 21, 2023
13b55be
norefs
beckermr Nov 21, 2023
856169c
norefs
beckermr Nov 21, 2023
3524b8c
norefs
beckermr Nov 21, 2023
6c497dc
norefs
beckermr Nov 21, 2023
3d402a9
norefs
beckermr Nov 21, 2023
db25fdb
norefs
beckermr Nov 21, 2023
0c97449
norefs
beckermr Nov 21, 2023
d6982b9
norefs
beckermr Nov 21, 2023
322b3db
norefs
beckermr Nov 21, 2023
b030c3b
norefs
beckermr Nov 21, 2023
16402d3
norefs
beckermr Nov 21, 2023
34b37d1
norefs
beckermr Nov 21, 2023
53d54ee
norefs
beckermr Nov 21, 2023
f598233
norefs
beckermr Nov 21, 2023
944505b
norefs
beckermr Nov 21, 2023
7641057
norefs
beckermr Nov 21, 2023
f2cab46
norefs
beckermr Nov 21, 2023
dbe4829
norefs
beckermr Nov 21, 2023
e675f72
norefs
beckermr Nov 21, 2023
a4a183b
norefs
beckermr Nov 21, 2023
a68288d
norefs
beckermr Nov 21, 2023
6c2bac1
no raise
beckermr Nov 23, 2023
d293d88
no raise
beckermr Nov 23, 2023
618a33b
no raise
beckermr Nov 23, 2023
5591ded
no raise
beckermr Nov 25, 2023
a093624
no raise
beckermr Nov 25, 2023
8a3440d
no raise
beckermr Nov 26, 2023
7d6923e
Merge branch 'main' into fix_tests
beckermr Nov 26, 2023
6fac1a7
no raise
beckermr Nov 26, 2023
552aef8
paths
beckermr Nov 26, 2023
ba43346
Merge branch 'fix_tests' of https://github.com/GalSim-developers/GalS…
beckermr Nov 26, 2023
3a225bd
paths
beckermr Nov 26, 2023
b67d4db
no refs
beckermr Nov 26, 2023
38d06d5
no refs
beckermr Nov 26, 2023
58b7f77
array asserts
beckermr Nov 26, 2023
633d0f5
Update test_random.py
beckermr Nov 27, 2023
d5b6d76
no views
beckermr Nov 27, 2023
8cc107a
Merge branch 'fix_tests' of https://github.com/GalSim-developers/GalS…
beckermr Nov 27, 2023
ed0df69
no views
beckermr Nov 27, 2023
a320a40
no views
beckermr Nov 27, 2023
49c4416
no views
beckermr Nov 27, 2023
fdfda0c
no views
beckermr Nov 27, 2023
9c660b5
no views
beckermr Nov 27, 2023
746ee19
no views
beckermr Nov 27, 2023
481cdbb
no views
beckermr Nov 27, 2023
728a18f
no views
beckermr Nov 27, 2023
3ff8c02
no views
beckermr Nov 27, 2023
5263be7
no views
beckermr Nov 27, 2023
aacd9c8
no views
beckermr Nov 27, 2023
46cbdfc
no views
beckermr Nov 27, 2023
9a2d102
no views
beckermr Nov 27, 2023
dfe3d11
no views
beckermr Nov 27, 2023
7192fa6
no views
beckermr Nov 27, 2023
8592754
no index errors
beckermr Nov 27, 2023
71400ad
bool env
beckermr Nov 27, 2023
eecef97
bool env
beckermr Nov 27, 2023
fc4e74f
zernike import
beckermr Nov 27, 2023
75dfbcb
bug in test of randoms
beckermr Nov 27, 2023
e003b5a
remove deprecation warnings
beckermr Nov 27, 2023
ef5d07a
Apply suggestions from code review
beckermr Nov 27, 2023
f1dd4d2
Apply suggestions from code review
beckermr Nov 27, 2023
73851f4
Apply suggestions from code review
beckermr Nov 27, 2023
7f4fd66
Apply suggestions from code review
beckermr Nov 27, 2023
73b4e75
Apply suggestions from code review
beckermr Nov 27, 2023
01d0ab6
Update tests/test_deprecated.py
beckermr Nov 27, 2023
e01492d
Apply suggestions from code review
beckermr Nov 27, 2023
5775587
Apply suggestions from code review
beckermr Nov 27, 2023
a5c6415
Apply suggestions from code review
beckermr Nov 27, 2023
185bb5a
Apply suggestions from code review
beckermr Nov 27, 2023
4ae8a78
Apply suggestions from code review
beckermr Nov 27, 2023
544cc29
Update tests/test_deprecated.py
beckermr Nov 27, 2023
1f1699e
Update tests/test_deprecated.py
beckermr Nov 27, 2023
496ce4d
Apply suggestions from code review
beckermr Nov 27, 2023
af11c61
Apply suggestions from code review
beckermr Nov 27, 2023
bcfc251
Apply suggestions from code review
beckermr Nov 27, 2023
3b5c1ca
Apply suggestions from code review
beckermr Nov 27, 2023
70a875f
Apply suggestions from code review
beckermr Nov 27, 2023
48edcbb
Apply suggestions from code review
beckermr Nov 27, 2023
dff8cba
Apply suggestions from code review
beckermr Nov 27, 2023
36064f5
Apply suggestions from code review
beckermr Nov 27, 2023
e4c6a49
Apply suggestions from code review
beckermr Nov 27, 2023
f9a318d
Apply suggestions from code review
beckermr Nov 27, 2023
81d788f
Apply suggestions from code review
beckermr Nov 27, 2023
e2a9c7e
Apply suggestions from code review
beckermr Nov 27, 2023
5c716c8
Apply suggestions from code review
beckermr Nov 27, 2023
88103b5
these are not supported at all in jax-galsim
beckermr Nov 27, 2023
bb64924
WIP update test for jax-galsim memory use
beckermr Jun 4, 2024
783f757
TST remove extra B
beckermr Jun 4, 2024
ab72b99
TST less memory
beckermr Jun 4, 2024
80db992
TST less memory
beckermr Jun 4, 2024
b1c10d4
TST less memory
beckermr Jun 4, 2024
0f0feeb
TST less memory
beckermr Jun 4, 2024
e61fc38
TST less memory
beckermr Jun 4, 2024
7e3cded
TST less memory
beckermr Jun 4, 2024
011fde6
TST cancel concurrent tests
beckermr Jun 4, 2024
68e4b7a
TST cancel concurrent tests
beckermr Jun 5, 2024
d6886c9
TST fix fft tests
beckermr Jun 5, 2024
1b44daa
test: update tests for jax galsim
beckermr Jun 20, 2024
ff175e1
test: lower precision for some interp image tests
beckermr Jul 12, 2024
62634db
Revert "test: lower precision for some interp image tests"
beckermr Jul 12, 2024
4161bad
Merge branch 'main' into fix_tests
beckermr Aug 21, 2024
0e379d2
fix: missing import
beckermr Aug 21, 2024
9696fbb
test: more missing imports and tests
beckermr Aug 21, 2024
6a326a7
test: rename the imports
beckermr Aug 21, 2024
0d55c54
feat: add function to extract the galsim backend
beckermr Aug 22, 2024
13a3042
fix: start to use a proper helper function
beckermr Aug 22, 2024
d80d1d8
test: convert more to use the helper functions
beckermr Aug 22, 2024
cc57eca
test: fix test helpers file for new functions
beckermr Aug 22, 2024
36da37b
test: clean up celestial tests
beckermr Aug 22, 2024
414c8ab
fix: need to test Angle
beckermr Aug 22, 2024
9cd8ab2
fix: bug in parens
beckermr Aug 22, 2024
aae4649
test: clean up test_optics
beckermr Aug 22, 2024
1b627dc
tests: always default to running tests for other backends
beckermr Aug 22, 2024
396084f
test: clean up tests for exp w/ phots
beckermr Aug 22, 2024
ae74cc7
test: clean up tests for moffat
beckermr Aug 22, 2024
ea082f5
fix: testing functions do not have atol/rtol
beckermr Aug 22, 2024
1a3b3cb
test: fix first part of deprecation test file
beckermr Aug 22, 2024
4173070
test: better test here
beckermr Aug 22, 2024
04c247a
test: check allocated
beckermr Aug 22, 2024
79536e1
test: clean up more test stuff
beckermr Aug 22, 2024
a2f674a
test: clean up more test stuff
beckermr Aug 22, 2024
ce25e31
test: get rest of test cases
beckermr Aug 22, 2024
3c4841c
test: clean up tests for photon arrays
beckermr Aug 23, 2024
c987110
test: clean up for interpolated images
beckermr Aug 23, 2024
5337334
test: clean up for noise tests
beckermr Aug 23, 2024
8454028
test: try using the olde value
beckermr Aug 23, 2024
101a36e
test: clean up tests for draw
beckermr Aug 23, 2024
682f592
test: clean up tests for draw
beckermr Aug 23, 2024
63855f9
test: clean up tests for draw
beckermr Aug 23, 2024
15943e2
test: clean up tests for image
beckermr Aug 23, 2024
3cd63b6
test: clean up tests for utils
beckermr Aug 23, 2024
9a5ab87
test: clean up random tests
beckermr Aug 26, 2024
b1632e9
fix: jax_galsim does not raise
beckermr Sep 13, 2024
108e119
fix: wrong order of if statement
beckermr Sep 13, 2024
4f93a4e
debug: figure out what is taking so long
beckermr Sep 13, 2024
b163e6f
debug: how many
beckermr Sep 13, 2024
61ae3d6
debug: how fast
beckermr Sep 13, 2024
501c0fd
test: just do less for jax
beckermr Sep 13, 2024
fb890ba
test: just do less for jax
beckermr Sep 13, 2024
3fc5a90
test: it is an array in jax
beckermr Sep 13, 2024
5e088ec
test: it is an array in jax
beckermr Sep 13, 2024
b7ef1e2
test: it is an array in jax
beckermr Sep 13, 2024
d8a549e
test: it is an array in jax
beckermr Sep 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: GalSim CI

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
Expand Down
20 changes: 10 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def supports_gpu(compiler, cc_type):
extra_cflags = copt[cc_type]
extra_lflags = lopt[cc_type]
return try_compile(cpp_code, compiler, extra_cflags, extra_lflags)

# Check for the fftw3 library in some likely places
def find_fftw_lib(output=False):
import distutils.sysconfig
Expand Down Expand Up @@ -434,29 +434,29 @@ def find_eigen_dir(output=False):
if output:
print("Downloaded %s. Unpacking tarball."%fname)
with tarfile.open(fname) as tar:

def is_within_directory(directory, target):

abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)

prefix = os.path.commonprefix([abs_directory, abs_target])

return prefix == abs_directory

def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
# Avoid security vulnerability in tar.extractall function.
# This bit of code was added by the Advanced Research Center at Trellix in PR #1188.
# For more information about the security vulnerability, see
# https://github.com/advisories/GHSA-gw9q-c7gh-j9vm

for member in tar.getmembers():
member_path = os.path.join(path, member.name)
if not is_within_directory(path, member_path):
raise Exception("Attempted Path Traversal in Tar File")
tar.extractall(path, members, numeric_owner=numeric_owner)

tar.extractall(path, members, numeric_owner=numeric_owner)

safe_extract(tar, dir)
os.remove(fname)
# This actually extracts into a subdirectory with a name eigen-eigen-5a0156e40feb/
Expand Down
102 changes: 89 additions & 13 deletions tests/galsim_test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,31 @@
from numpy.testing import assert_raises
from numpy.testing import assert_warns

__all__ = [
"default_params",
"gsobject_compare",
"printval",
"convertToShear",
"check_basic_x",
"check_basic_k",
"assert_floatlike",
"assert_intlike",
"check_basic",
"do_shoot",
"do_kvalue",
"radial_integrate",
"drawNoise",
"check_pickle",
"check_all_diff",
"timer",
"CaptureLog",
"assert_raises",
"assert_warns",
"Profile",
"galsim_backend",
"is_jax_galsim",
]

# This file has some helper functions that are used by tests from multiple files to help
# avoid code duplication.

Expand All @@ -43,6 +68,18 @@
integration_relerr = 1.e-6,
integration_abserr = 1.e-8)


def galsim_backend():
if "jax_galsim/__init__.py" in galsim.__file__:
return "jax_galsim"
else:
return "galsim"


def is_jax_galsim():
return galsim_backend() == "jax_galsim"


def gsobject_compare(obj1, obj2, conv=None, decimal=10):
"""Helper function to check that two GSObjects are equivalent
"""
Expand Down Expand Up @@ -133,20 +170,32 @@ def check_basic_x(prof, name, approx_maxsb=False, scale=None):
np.testing.assert_allclose(
image(i,j), prof._xValue(galsim.PositionD(x,y)), rtol=1.e-5,
err_msg="%s profile sb image does not match _xValue at %d,%d"%(name,i,j))
assert prof.withFlux.__doc__ == galsim.GSObject.withFlux.__doc__
assert prof.__class__.withFlux.__doc__ == galsim.GSObject.withFlux.__doc__
if is_jax_galsim():
for line in galsim.GSObject.withFlux.__doc__.splitlines():
if line.strip() and "LAX" not in line:
assert line.strip() in prof.withFlux.__doc__, (
prof.withFlux.__doc__, galsim.GSObject.withFlux.__doc__,
)
for line in galsim.GSObject.withFlux.__doc__.splitlines():
if line.strip() and "LAX" not in line:
assert line.strip() in prof.__class__.withFlux.__doc__, (
prof.__class__.withFlux.__doc__, galsim.GSObject.withFlux.__doc__,
)
else:
assert prof.withFlux.__doc__ == galsim.GSObject.withFlux.__doc__
assert prof.__class__.withFlux.__doc__ == galsim.GSObject.withFlux.__doc__

# Check negative flux:
neg_image = prof.withFlux(-prof.flux).drawImage(method='sb', scale=scale, use_true_center=False)
np.testing.assert_almost_equal(neg_image.array/prof.flux, -image.array/prof.flux, 7,
'%s negative flux drawReal is not negative of +flux image'%name)
np.testing.assert_array_almost_equal(neg_image.array/prof.flux, -image.array/prof.flux, 7,
'%s negative flux drawReal is not negative of +flux image'%name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? I thought they were equivalent. I'd rather not use the more verbose one if we can avoid it.


# Direct call to drawReal should also work and be equivalent to the above with scale = 1.
prof.drawImage(image, method='sb', scale=1., use_true_center=False)
image2 = image.copy()
prof.drawReal(image2)
np.testing.assert_equal(image2.array, image.array,
err_msg="%s drawReal not equivalent to drawImage"%name)
np.testing.assert_array_equal(image2.array, image.array,
err_msg="%s drawReal not equivalent to drawImage"%name)

# If supposed to be axisymmetric, make sure it is.
if prof.is_axisymmetric:
Expand Down Expand Up @@ -194,7 +243,7 @@ def check_basic_k(prof, name):

# Check negative flux:
neg_image = prof.withFlux(-prof.flux).drawKImage(kimage.copy())
np.testing.assert_almost_equal(neg_image.array/prof.flux, -kimage.array/prof.flux, 7,
np.testing.assert_array_almost_equal(neg_image.array/prof.flux, -kimage.array/prof.flux, 7,
'%s negative flux drawK is not negative of +flux image'%name)

# If supposed to be axisymmetric, make sure it is in the kValues.
Expand All @@ -206,6 +255,30 @@ def check_basic_k(prof, name):
np.testing.assert_allclose(test_values, ref_value, rtol=1.e-5,
err_msg="%s profile not axisymmetric in kValues"%name)

def assert_floatlike(val):
assert (
isinstance(val, float)
or (
is_jax_galsim()
and hasattr(val, "shape")
and val.shape == ()
and hasattr(val, "dtype")
and val.dtype.name in ["float", "float32", "float64"]
)
), "Value is not float-like: type(%r) = %r" % (val, type(val))

def assert_intlike(val):
assert (
isinstance(val, int)
or (
is_jax_galsim()
and hasattr(val, "shape")
and val.shape == ()
and hasattr(val, "dtype")
and val.dtype.name in ["int", "int32", "int64"]
)
), "Value is not int-like: type(%r) = %r" % (val, type(val))

def check_basic(prof, name, approx_maxsb=False, scale=None, do_x=True, do_k=True):
"""Do some basic sanity checks that should work for all profiles.
"""
Expand All @@ -220,12 +293,12 @@ def check_basic(prof, name, approx_maxsb=False, scale=None, do_x=True, do_k=True
prof.positive_flux - prof.negative_flux, prof.flux,
err_msg="%s profile flux not equal to posflux + negflux"%name)
assert isinstance(prof.centroid, galsim.PositionD)
assert isinstance(prof.flux, float)
assert isinstance(prof.positive_flux, float)
assert isinstance(prof.negative_flux, float)
assert isinstance(prof.max_sb, float)
assert isinstance(prof.stepk, float)
assert isinstance(prof.maxk, float)
assert_floatlike(prof.flux)
assert_floatlike(prof.positive_flux)
assert_floatlike(prof.negative_flux)
assert_floatlike(prof.max_sb)
assert_floatlike(prof.stepk)
assert_floatlike(prof.maxk)
assert isinstance(prof.has_hard_edges, bool)
assert isinstance(prof.is_axisymmetric, bool)
assert isinstance(prof.is_analytic_x, bool)
Expand Down Expand Up @@ -298,6 +371,9 @@ def do_shoot(prof, img, name):
print('nphot = ',nphot)
img2 = img.copy()

if is_jax_galsim():
rtol *= 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a sign of a problem with the jax-galsim implementation?


# Use a deterministic random number generator so we don't fail tests because of rare flukes
# in the random numbers.
rng = galsim.UniformDeviate(12345)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# and/or other materials provided with the distribution.
#

import os
import numpy as np

import galsim
Expand Down Expand Up @@ -198,7 +199,7 @@ def test_basic_dict():
def test_single_row():
"""Test that we can read catalogs with just one row (#394)
"""
filename = "output/test394.txt"
filename = os.path.join(os.path.dirname(__file__), "output/test394.txt")
with open(filename, 'w') as f:
f.write("3 4 5\n")
cat = galsim.Catalog(filename, file_type='ascii')
Expand Down
63 changes: 52 additions & 11 deletions tests/test_celestial.py → tests/test_celestial_galsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#

import numpy
import numpy as np
import os
import math

Expand Down Expand Up @@ -122,11 +123,11 @@ def test_angle():

# Check invalid constructors
assert_raises(TypeError,galsim.AngleUnit, galsim.degrees)
assert_raises(ValueError,galsim.AngleUnit, 'spam')
assert_raises((ValueError, TypeError), galsim.AngleUnit, 'spam')
assert_raises(TypeError,galsim.AngleUnit, 1, 3)
assert_raises(TypeError,galsim.Angle, 3.4)
assert_raises(TypeError,galsim.Angle, theta1, galsim.degrees)
assert_raises(ValueError,galsim.Angle, 'spam', galsim.degrees)
assert_raises((ValueError, TypeError), galsim.Angle, 'spam')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should remove the last arg, galsim.degrees.

assert_raises(TypeError,galsim.Angle, 1, 3)


Expand Down Expand Up @@ -155,7 +156,7 @@ def test_celestialcoord_basic():

x, y, z = c1.get_xyz()
print('c1 is at x,y,z = ',x,y,z)
np.testing.assert_equal((x,y,z), (1,0,0))
np.testing.assert_array_equal((x,y,z), (1,0,0))
assert c1 == galsim.CelestialCoord.from_xyz(x,y,z)

x, y, z = c2.get_xyz()
Expand Down Expand Up @@ -343,9 +344,19 @@ def test_projection():

# First the trivial case
p0 = center.project(center, projection='lambert')
assert p0 == (0.0 * galsim.arcsec, 0.0 * galsim.arcsec)
np.testing.assert_allclose(
(p0[0].rad, p0[1].rad),
(0.0, 0.0),
rtol=0,
atol=1e-16,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What computation are you doing in Jax-Galsim that makes this not be exactly zero. This should have been trivially true I would think

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the line bloat here seems rather gratuitous. Can we put each of these in a single line?

c0 = center.deproject(*p0, projection='lambert')
assert c0 == center
np.testing.assert_allclose(
c0.rad,
center.rad,
beckermr marked this conversation as resolved.
Show resolved Hide resolved
rtol=0,
atol=1e-16,
)
np.testing.assert_almost_equal(center.jac_deproject(*p0, projection='lambert').ravel(),
(1,0,0,1))

Expand Down Expand Up @@ -398,9 +409,19 @@ def test_projection():

# First the trivial case
p0 = center.project(center, projection='stereographic')
assert p0 == (0.0 * galsim.arcsec, 0.0 * galsim.arcsec)
np.testing.assert_allclose(
(p0[0].rad, p0[1].rad),
(0.0, 0.0),
rtol=0,
atol=1e-16,
)
c0 = center.deproject(*p0, projection='stereographic')
assert c0 == center
np.testing.assert_allclose(
c0.rad,
center.rad,
beckermr marked this conversation as resolved.
Show resolved Hide resolved
rtol=0,
atol=1e-16,
)
np.testing.assert_almost_equal(center.jac_deproject(*p0, projection='stereographic').ravel(),
(1,0,0,1))

Expand Down Expand Up @@ -456,9 +477,19 @@ def test_projection():

# First the trivial case
p0 = center.project(center, projection='gnomonic')
assert p0 == (0.0 * galsim.arcsec, 0.0 * galsim.arcsec)
np.testing.assert_allclose(
(p0[0].rad, p0[1].rad),
(0.0, 0.0),
rtol=0,
atol=1e-16,
)
c0 = center.deproject(*p0, projection='gnomonic')
assert c0 == center
np.testing.assert_allclose(
c0.rad,
center.rad,
beckermr marked this conversation as resolved.
Show resolved Hide resolved
rtol=0,
atol=1e-16,
)
np.testing.assert_almost_equal(center.jac_deproject(*p0, projection='gnomonic').ravel(),
(1,0,0,1))

Expand Down Expand Up @@ -510,9 +541,19 @@ def test_projection():

# First the trivial case
p0 = center.project(center, projection='postel')
assert p0 == (0.0 * galsim.arcsec, 0.0 * galsim.arcsec)
np.testing.assert_allclose(
(p0[0].rad, p0[1].rad),
(0.0, 0.0),
rtol=0,
atol=1e-16,
)
c0 = center.deproject(*p0, projection='postel')
assert c0 == center
np.testing.assert_allclose(
c0.rad,
center.rad,
beckermr marked this conversation as resolved.
Show resolved Hide resolved
rtol=0,
atol=1e-16,
)
np.testing.assert_almost_equal(center.jac_deproject(*p0, projection='postel').ravel(),
(1,0,0,1))

Expand Down
1 change: 1 addition & 0 deletions tests/test_chromatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# and/or other materials provided with the distribution.
#

import copy
import os
import copy
import numpy as np
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ def test_config():
}

# Test yaml
yaml_file_name = "output/test_config.yaml"
yaml_file_name = os.path.join(os.path.dirname(__file__), "output/test_config.yaml")
with open(yaml_file_name, 'w') as fout:
yaml.dump(config, fout, default_flow_style=True)
# String None will be coverted to a real None. Convert here in the comparison dict
Expand All @@ -1252,7 +1252,7 @@ def test_config():
assert config == dict(config2)

# Test json
json_file_name = "output/test_config.json"
json_file_name = os.path.join(os.path.dirname(__file__), "output/test_config.json")
with open(json_file_name, 'w') as fout:
json.dump(config, fout)

Expand Down
Loading
Loading