diff --git a/hvplot/tests/testutil.py b/hvplot/tests/testutil.py index 71dc7c42a..2dc7cac67 100644 --- a/hvplot/tests/testutil.py +++ b/hvplot/tests/testutil.py @@ -393,13 +393,13 @@ def test_geoviews_is_available(): def test_geoviews_is_available_no_raise(): - with patch('hvplot.util.geoviews_is_available', side_effect=ImportError): + with patch('hvplot.util.find_spec', return_value=None): result = geoviews_is_available(raise_error=False) assert result is False def test_geoviews_is_available_with_raise(): - with patch('hvplot.util.geoviews_is_available', side_effect=ImportError): + with patch('hvplot.util.find_spec', return_value=None): with pytest.raises( ImportError, match='GeoViews must be installed to enable the geographic options.' ): diff --git a/hvplot/ui.py b/hvplot/ui.py index b6256ecef..ad9b19023 100644 --- a/hvplot/ui.py +++ b/hvplot/ui.py @@ -665,8 +665,8 @@ def _plot(self): if kwargs.get('geo'): if 'crs' not in kwargs: xmax = np.max(np.abs(self.xlim())) - self.geographic.crs = 'PlateCarree' if xmax <= 360 else 'GOOGLE_MERCATOR' - kwargs['crs'] = self.geographic.crs + # self.geographic.crs = 'PlateCarree' if xmax <= 360 else 'GOOGLE_MERCATOR' + kwargs['crs'] = 'PlateCarree' if xmax <= 360 else 'GOOGLE_MERCATOR' for key in ['crs', 'projection']: if key not in kwargs: continue diff --git a/hvplot/util.py b/hvplot/util.py index 6a86cab7f..33dcb336c 100644 --- a/hvplot/util.py +++ b/hvplot/util.py @@ -2,6 +2,7 @@ Provides utilities to convert data and projections """ +from importlib.util import find_spec import sys from collections.abc import Hashable @@ -756,15 +757,8 @@ def geoviews_is_available(raise_error: bool = False): """ Check if GeoViews is available and raise an ImportError if not. """ - try: - import geoviews # noqa - - gv_available = True - except ImportError: - gv_available = False - - if not raise_error: - return gv_available + gv_available = find_spec('geoviews') is not None if not gv_available and raise_error: raise ImportError('GeoViews must be installed to enable the geographic options.') + return gv_available