ejeschke / ginga

The Ginga astronomical FITS file viewer
BSD 3-Clause "New" or "Revised" License
120 stars 77 forks source link

[4.0.0] Test error with Test_R2G #1038

Closed olebole closed 1 year ago

olebole commented 1 year ago

When trying to build the Debian package for Ginga 4.0.0, I observed failures for the tests in Test_R2G. They all look like this:

    def test_rectangle_annulus_pix1(self):
        o = dc.Annulus2R(42, 43, 4.2, 7.2, xwidth=1, ywidth=1, rot_deg=5.0, atype='box')
>       r = g2r(o)

ginga/tests/test_ap_regions.py:442: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = <ginga.canvas.types.astro.Annulus2R object at 0x7fe6ec70f850>
frame = 'icrs', logger = None

    def ginga_canvas_object_to_astropy_region(obj, frame='icrs', logger=None):
        """..."""
        if not HAVE_REGIONS:
            raise ValueError("Please install the Astropy 'regions' package to use this function")

        dc = get_canvas_types()
        r = None

        if isinstance(obj, (dc.Circle,)):
           if obj.coord == 'data':
                […]
            elif obj.coord == 'wcs':
                […]
        elif isinstance(obj, (dc.Ellipse,)):
        […many more elifs…]
        else:
          […]

        # Set visual styling attributes
>       r.visual['color'] = obj.color
E       AttributeError: 'NoneType' object has no attribute 'visual'

ginga/util/ap_region.py:427: AttributeError

Full build log here. The reason seems that at all places in the outer if/elif chains there is a construct

           if obj.coord == 'data':
                r = […]
            elif obj.coord == 'wcs':
                r = […]

however in the failure cases obj.coord is None.

Versions:

ejeschke commented 1 year ago

Hmm, looks like there might have been a change in the regions package. I'll take a look.

pllim commented 1 year ago

Sounds very similar to https://github.com/astropy/astrowidgets/issues/154 . I wonder why Ginga CI isn't catching it.

pllim commented 1 year ago

Ah, looks like the current CI test suite does not install optional dependencies and regions also not declared anywhere in setup.cfg. So maybe that's why. I bet you would see the same failure if you install regions into the test suite here.

ejeschke commented 1 year ago

The test only runs if regions is installed, which is an optional package. It's only used to export things from the Drawing plugin.

ejeschke commented 1 year ago

Fixed by a88af4824e29d5433256be31e1bef0940c1ccc35

Was a problem with ginga v4 changes not regions.

Will include this in a v4.0.1 release soon.

olebole commented 1 year ago

Thank you; 4.0.1 works perfectly for me! Uploading to Debian now.