Skip to content

Commit

Permalink
🎨 Use ValueError instead of assert
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed May 16, 2024
1 parent 8e21d7b commit 8a4952c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/ipyaladin/region_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,16 @@ def rectangle_to_polygon_region(region: RectangleSkyRegion) -> PolygonSkyRegion:
height = region.height.rad
position_angle = region.angle.rad

assert (
0.0 <= longitude < TWICE_PI
), f"Expected: lon in [0, 2pi[. Actual: {longitude}"
assert (
-math.pi / 2 <= latitude <= math.pi / 2
), f"Expected: lat in [-pi/2, pi/2]. Actual: {latitude}"
assert 0.0 < width <= math.pi / 2, f"Expected: a in ]0, pi/2]. Actual: {width}"
assert 0.0 < height <= width, f"Expected: b in ]0, a]. Actual: {height}"
assert (
0.0 <= position_angle < math.pi
), f"Expected: pa in [0, pi[. Actual: {position_angle}"
if not 0.0 <= longitude < TWICE_PI:
raise ValueError(f"Expected: lon in [0, 2pi[. Actual: {longitude}")
if not -math.pi / 2 <= latitude <= math.pi / 2:
raise ValueError(f"Expected: lat in [-pi/2, pi/2]. Actual: {latitude}")
if not 0.0 < width <= math.pi / 2:
raise ValueError(f"Expected: a in ]0, pi/2]. Actual: {width}")
if not 0.0 < height <= width:
raise ValueError(f"Expected: b in ]0, a]. Actual: {height}")
if not 0.0 <= position_angle < math.pi:
raise ValueError(f"Expected: pa in [0, pi[. Actual: {position_angle}")

frame_rotation = RefToLocalRotMatrix.from_center(longitude, latitude)

Expand Down

0 comments on commit 8a4952c

Please sign in to comment.