pysal / tobler

Spatial interpolation, Dasymetric Mapping, & Change of Support
https://pysal.org/tobler
BSD 3-Clause "New" or "Revised" License
144 stars 30 forks source link

BUG: TypeError when astropy is missing in pycno #151

Closed martinfleis closed 2 years ago

martinfleis commented 2 years ago

If you don't have astropy, pycno errors in a way it should not.

    def pycno(
        gdf, value_field, cellsize, r=0.2, handle_null=True, converge=3, verbose=True
    ):
        try:
            from astropy.convolution import convolve as astro_convolve
        except Exception:
>           raise ("Pycnophylactic interpolation requires the astropy package")
E           TypeError: exceptions must derive from BaseException

I guess we should do

 try:
    from astropy.convolution import convolve as astro_convolve
except (ImportError, ModuleNotFoundError):
    raise ImportError("Pycnophylactic interpolation requires the astropy package")

That way we also pass through any other errors that may be coming from astropy. I'll make a PR.