Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that no projection is set when tiles is used without geo=True #1113

Merged
merged 7 commits into from
Oct 12, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions hvplot/tests/testgeo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pathlib
import sys

import pytest

from unittest import TestCase, SkipTest

from packaging.version import Version
Expand All @@ -11,6 +13,13 @@
from hvplot.util import proj_to_cartopy


bk_renderer = hv.Store.renderers['bokeh']

@pytest.fixture
def simple_df():
return pd.DataFrame(np.random.rand(10, 2), columns=['x', 'y'])


class TestGeo(TestCase):

def setUp(self):
Expand Down Expand Up @@ -174,6 +183,45 @@ def test_plot_with_specific_gv_tile_obj(self):
self.assertIsInstance(plot.get(0), gv.element.WMTS)


class TestAnnotationNotGeo:

@classmethod
def setup_class(cls):
import hvplot.pandas # noqa

def test_plot_tiles_doesnt_set_geo(self, simple_df):
plot = simple_df.hvplot.points('x', 'y', tiles=True)
assert len(plot) == 2
assert isinstance(plot.get(0), hv.Tiles)
assert 'openstreetmap' in plot.get(0).data
bk_plot = bk_renderer.get_plot(plot)
assert bk_plot.projection == 'mercator'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true if the test is executed on its own. When the whole module runs, GeoViews is imported and this comes with some side-effects, bk_plot.projection becomes Cartopy CRS (Mercator). I'm not sure this side-effect is desired.


def test_plot_specific_tiles_doesnt_set_geo(self, simple_df):
plot = simple_df.hvplot.points('x', 'y', tiles='ESRI')
assert len(plot) == 2
assert isinstance(plot.get(0), hv.Tiles)
assert 'ArcGIS' in plot.get(0).data
bk_plot = bk_renderer.get_plot(plot)
assert bk_plot.projection == 'mercator'

def test_plot_with_specific_tile_class(self, simple_df):
plot = simple_df.hvplot.points('x', 'y', tiles=hv.element.tiles.EsriImagery)
assert len(plot) == 2
assert isinstance(plot.get(0), hv.Tiles)
assert 'ArcGIS' in plot.get(0).data
bk_plot = bk_renderer.get_plot(plot)
assert bk_plot.projection == 'mercator'

def test_plot_with_specific_tile_obj(self, simple_df):
plot = simple_df.hvplot.points('x', 'y', tiles=hv.element.tiles.EsriImagery())
assert len(plot) == 2
assert isinstance(plot.get(0), hv.Tiles)
assert 'ArcGIS' in plot.get(0).data
bk_plot = bk_renderer.get_plot(plot)
assert bk_plot.projection == 'mercator'


class TestGeoElements(TestCase):

def setUp(self):
Expand Down
Loading