Skip to content

Commit

Permalink
Merge pull request #3 from beckermr/more-tests
Browse files Browse the repository at this point in the history
More tests
  • Loading branch information
beckermr authored Nov 28, 2023
2 parents de1aad9 + fd00e94 commit 325c91e
Show file tree
Hide file tree
Showing 32 changed files with 1,218 additions and 16,396 deletions.
1 change: 1 addition & 0 deletions jax_galsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
ImageS,
ImageUI,
ImageUS,
_Image,
)

# GSObject
Expand Down
10 changes: 7 additions & 3 deletions jax_galsim/angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from jax._src.numpy.util import _wraps
from jax.tree_util import register_pytree_node_class

from jax_galsim.core.utils import cast_to_array_scalar, ensure_hashable
from jax_galsim.core.utils import cast_to_float, ensure_hashable


@_wraps(_galsim.AngleUnit)
Expand All @@ -34,7 +34,11 @@ def __init__(self, value):
"""
:param value: The measure of the unit in radians.
"""
self._value = cast_to_array_scalar(value, dtype=float)
if isinstance(value, AngleUnit):
raise TypeError("Cannot construct AngleUnit from another AngleUnit")
self._value = 1.0 * cast_to_float(
value
) # this will cause an exception if things are not numeric

@property
def value(self):
Expand Down Expand Up @@ -142,7 +146,7 @@ def __init__(self, theta, unit=None):
raise TypeError("Invalid unit %s of type %s" % (unit, type(unit)))
else:
# Normal case
self._rad = cast_to_array_scalar(theta, dtype=float) * unit.value
self._rad = cast_to_float(theta) * unit.value

@property
def rad(self):
Expand Down
Loading

0 comments on commit 325c91e

Please sign in to comment.