astropy / pyregion

ds9 region parser for python
https://pyregion.readthedocs.io
MIT License
39 stars 38 forks source link

Failure with Matplotlib dev #138

Closed astrofrog closed 3 years ago

astrofrog commented 4 years ago

I've started seeing the following issue with APLpy which uses pyregion when using the latest developer version of Matplotlib:

____________________________ TestBasic.test_regions ____________________________

self = <aplpy.tests.test_images.TestBasic object at 0x7fbcaa0b85f8>

    @pytest.mark.remote_data
    @pytest.mark.mpl_image_compare(style={}, savefig_kwargs={'adjust_bbox': False}, baseline_dir=baseline_dir, tolerance=5)
    def test_regions(self):
        f = FITSFigure(self.filename_2, figsize=(7, 5))

        # Force aspect ratio
        f.show_grayscale()
        f.hide_grayscale()

>       f.show_regions(os.path.join(DATADIR, 'shapes.reg'))

aplpy/tests/test_images.py:203: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
aplpy/decorators.py:26: in wrapper
    return f(*args, **kwargs)
aplpy/regions.py:62: in show_regions
    PC, TC = ds9(region_file, flatten_header(self._header), **kwargs)
aplpy/regions.py:128: in ds9
    pp, aa = rrim.get_mpl_patches_texts(text_offset=text_offset)
/usr/local/lib/python3.7/site-packages/pyregion/core.py:87: in get_mpl_patches_texts
    origin=origin)
/usr/local/lib/python3.7/site-packages/pyregion/mpl_helper.py:351: in as_mpl_artists
    **kwargs)]
/usr/local/lib/python3.7/site-packages/matplotlib/patches.py:3884: in __init__
    Patch.__init__(self, **kwargs)
/usr/local/lib/python3.7/site-packages/matplotlib/patches.py:95: in __init__
    self.update(kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <matplotlib.patches.FancyArrowPatch object at 0x7fbcbf9c0518>
props = {'arrow_transmuter': None, 'connector': None}

    def update(self, props):
        """
        Update this artist's properties from the dict *props*.

        Parameters
        ----------
        props : dict
        """
        ret = []
        with cbook._setattr_cm(self, eventson=False):
            for k, v in props.items():
                if k != k.lower():
                    cbook.warn_deprecated(
                        "3.3", message="Case-insensitive properties were "
                        "deprecated in %(since)s and support will be removed "
                        "%(removal)s")
                    k = k.lower()
                # White list attributes we want to be able to update through
                # art.update, art.set, setp.
                if k == "axes":
                    ret.append(setattr(self, k, v))
                else:
                    func = getattr(self, f"set_{k}", None)
                    if not callable(func):
>                       raise AttributeError(f"{type(self).__name__!r} object "
                                             f"has no property {k!r}")
E                       AttributeError: 'FancyArrowPatch' object has no property 'arrow_transmuter'

Looks like the following line needs to be updated:

https://github.com/astropy/pyregion/blob/fc3b97941a70440eb3f371348c79010cf05d83ab/pyregion/mpl_helper.py#L346

pointyNeil commented 3 years ago

In the same call it seems also necessary to remove the 'connector' parameter, which has also disappeared from FancyArrowPatch. https://github.com/astropy/pyregion/blob/fc3b97941a70440eb3f371348c79010cf05d83ab/pyregion/mpl_helper.py#L350

leejjoon commented 3 years ago

This should be fixed with v2.1.1. Please reopen if this is not the case.