user [email protected] usertags 1143310 python3.15 tags 1143310 patch thanks
Hi! While rebuilding the python related packages against the Python 3.15rc2 version I ran into this FTBFS [1]. To solve this issue, I had to: - Apply upstream fix b2be557592ad3fceba8988ecbeb0e7f5172daa2c: Removed import from deprecated regions function. This was already added as a patch in salsa, but not uploaded to Debian. - Add a patch to update use of the regions library. I've applied these fixes in the sandbox [2] to verify that it builds successfully, these should be applied in Debian to get the package back to a healthy state. Happy hacking, [1]: https://debusine.debian.net/debian/r-python-python3.15/artifact/4598894/ [2]: https://debusine.debian.net/debian/r-python-python3.15/ -- "Can you imagine what I would do if I could do all I can?" -- Sun Tzu Saludos /\/\ /\ >< `/
Description: Fix compatibility with regions >= 0.12 Handle point regions and direct center calculation in RegionGeom. Avoid pixel roundtrip in region_to_frame to correctly rotate region angles. Author: Maximiliano Curia <[email protected]> Forwarded: not-needed Last-Update: 2026-09-13 --- Index: gammapy/gammapy/maps/region/geom.py =================================================================== --- gammapy.orig/gammapy/maps/region/geom.py +++ gammapy/gammapy/maps/region/geom.py @@ -173,6 +173,8 @@ class RegionGeom(Geom): Dimensions of the region in both spatial dimensions. Units: ``deg`` """ + if self.is_all_point_sky_regions: + return u.Quantity([0.0, 0.0], "deg") rectangle = self._rectangle_bbox return u.Quantity([rectangle.width.to("deg"), rectangle.height.to("deg")]) @@ -218,7 +220,10 @@ class RegionGeom(Geom): if self.region is None: return SkyCoord(np.nan * u.deg, np.nan * u.deg) - return self._rectangle_bbox.center + if isinstance(self.region, CompoundSkyRegion): + return compound_region_center(self.region) + + return self.region.center @property def npix(self): Index: gammapy/gammapy/modeling/models/spatial.py =================================================================== --- gammapy.orig/gammapy/modeling/models/spatial.py +++ gammapy/gammapy/modeling/models/spatial.py @@ -535,7 +535,8 @@ class SpatialModel(ModelBase): model : `SpatialModel` Spatial model. """ - lon_0, lat_0 = position.data.lon, position.data.lat + lon_0 = position.data.lon.to("deg") + lat_0 = position.data.lat.to("deg") return cls(lon_0=lon_0, lat_0=lat_0, frame=position.frame.name, **kwargs) @property Index: gammapy/gammapy/utils/regions.py =================================================================== --- gammapy.orig/gammapy/utils/regions.py +++ gammapy/gammapy/utils/regions.py @@ -20,11 +20,13 @@ from regions import ( CircleAnnulusSkyRegion, CircleSkyRegion, CompoundSkyRegion, + EllipseAnnulusSkyRegion, EllipseSkyRegion, + PointSkyRegion, + PolygonPixelRegion, + PolygonSkyRegion, RectangleSkyRegion, Regions, - PolygonSkyRegion, - PolygonPixelRegion, ) from regions.core.pixcoord import PixCoord @@ -453,11 +455,68 @@ def region_to_frame(region, frame): region_new : `~regions.SkyRegion` Region in the given frame. """ - from gammapy.maps import WcsGeom + if isinstance(region, PointSkyRegion): + return PointSkyRegion( + center=region.center.transform_to(frame), + meta=region.meta.copy(), + visual=region.visual.copy(), + ) + elif isinstance(region, CircleSkyRegion): + return CircleSkyRegion( + center=region.center.transform_to(frame), + radius=region.radius, + meta=region.meta.copy(), + visual=region.visual.copy(), + ) + elif isinstance(region, (EllipseSkyRegion, RectangleSkyRegion)): + center_new = region.center.transform_to(frame) + offset = 1 * u.arcsec + north_orig = region.center.directional_offset_by(0.0 * u.deg, offset) + north_orig_new = north_orig.transform_to(frame) + dphi = center_new.position_angle(north_orig_new) + angle_new = (region.angle + dphi).wrap_at("180 deg") + return type(region)( + center=center_new, + width=region.width, + height=region.height, + angle=angle_new, + meta=region.meta.copy(), + visual=region.visual.copy(), + ) + elif isinstance(region, CircleAnnulusSkyRegion): + return CircleAnnulusSkyRegion( + center=region.center.transform_to(frame), + inner_radius=region.inner_radius, + outer_radius=region.outer_radius, + meta=region.meta.copy(), + visual=region.visual.copy(), + ) + elif isinstance(region, EllipseAnnulusSkyRegion): + center_new = region.center.transform_to(frame) + offset = 1 * u.arcsec + north_orig = region.center.directional_offset_by(0.0 * u.deg, offset) + north_orig_new = north_orig.transform_to(frame) + dphi = center_new.position_angle(north_orig_new) + angle_new = (region.angle + dphi).wrap_at("180 deg") + return EllipseAnnulusSkyRegion( + center=center_new, + inner_width=region.inner_width, + inner_height=region.inner_height, + outer_width=region.outer_width, + outer_height=region.outer_height, + angle=angle_new, + meta=region.meta.copy(), + visual=region.visual.copy(), + ) + elif isinstance(region, CompoundSkyRegion): + regions = compound_region_to_regions(region) + regions_new = [region_to_frame(r, frame) for r in regions] + return regions_to_compound_region(regions_new) + else: + from gammapy.maps import WcsGeom - wcs = WcsGeom.create(skydir=region.center, binsz=0.01, frame=frame).wcs - region_new = region.to_pixel(wcs).to_sky(wcs) - return region_new + wcs = WcsGeom.create(skydir=region.center, binsz=0.01, frame=frame).wcs + return region.to_pixel(wcs).to_sky(wcs) def region_circle_to_ellipse(region):

