Skip to content

Commit

Permalink
add tests and fix up
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Jun 13, 2024
1 parent 01082db commit 787e2de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 8 additions & 0 deletions hvplot/tests/testui.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,11 @@ def test_explorer_xarray_multi_var_extra_dims_no_coord():
ds = xr.tutorial.open_dataset('air_temperature')
ds['lat_bnds'] = (('bnds', 'lat'), np.vstack([ds['lat'], ds['lat']]))
assert ds.hvplot.explorer()


@pytest.mark.parametrize('kind_tuple', [('scatter', 'points'), ('line', 'paths')])
def test_explorer_geo_revise_kind(kind_tuple):
da = ds_air_temperature['air'].isel(time=0)
explorer = hvplot.explorer(da, x='lon', y='lat', kind=kind_tuple[0])
explorer.geographic.geo = True
assert explorer.kind == kind_tuple[1]
16 changes: 5 additions & 11 deletions hvplot/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,11 @@ def _update_crs_projection(self):
crs_list.insert(0, 'PlateCarree')
crs_list.remove('PlateCarree')

self._update_kind()
if self.explorer.kind == 'scatter':
self.explorer.kind = 'points'
elif self.explorer.kind == 'line':
self.explorer.kind = 'paths'

self.param.crs.objects = crs_list
self.param.projection.objects = crs_list
updates = {}
Expand All @@ -417,16 +421,6 @@ def _update_crs_projection(self):

self.param.update(**updates)

@param.depends('explorer.kind', watch=True)
def _update_kind(self):
if not self.geo:
return

if self.explorer.kind == 'scatter':
self.explorer.kind = 'points'
elif self.explorer.kind == 'line':
self.explorer.kind = 'paths'


class Operations(Controls):
datashade = param.Boolean(
Expand Down

0 comments on commit 787e2de

Please sign in to comment.