astropy / astropy/regions

BUG: RangeSphericalSkyRegion frame isn't correct, so compound regions with range fail

Open Beginner friendly
#703 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
65
Forks
64
Avg merge
2d 13h
Merged PRs (30d)
4

Description

Currently, the standardization of frame input (used for RangeSphericalSkyRegion) ends up setting the frame attribute to an astropy.coordinates.BaseCoordinateFrame **class**. This enables frame transformation to work, but frame comparisons fail when trying to create a compound region using RangeSphericalSkyRegions.

Example of error:
```
from astropy import units as u
from regions import RangeSphericalSkyRegion

reg1 = RangeSphericalSkyRegion(
frame="icrs",
latitude_range=[0 * u.deg, 1 * u.deg],
)
reg2 = RangeSphericalSkyRegion(
frame="icrs",
latitude_range=[0.5 * u.deg, 1.5 * u.deg],
)
reg1 & reg2
```
returns
```
[snip path] regions/regions/core/compound.py:353, in CompoundSphericalSkyRegion._validate_regions(region1, region2)
348 from regions.shapes.whole_sky import WholeSphericalSkyRegion
350 # If one region is WholeSphericalSkyRegion, skip check:
351 if (not (isinstance(region1, WholeSphericalSkyRegion)
352 | isinstance(region2, WholeSphericalSkyRegion))
--> 353 and not region1.frame.is_equivalent_frame(region2.frame)):
354 raise ValueError(
355 'To create a compound region, "region1" & "region2"'
356 ' must be in the same coordinate frame!',
357 )

TypeError: BaseCoordinateFrame.is_equivalent_frame() missing 1 required positional argument: 'other'
```

A fix to the SphericalSkyRegion._standardize_frame() method is forthcoming.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with SphericalSkyRegion._standardize_frame(), which the issue identifies as the source of the incorrect frame value. Reproduce the two RangeSphericalSkyRegion objects from the issue and combine them with &, then verify that equivalent-frame comparison succeeds without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.