-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to expose View controls (#137)
- Loading branch information
1 parent
94f4fa0
commit 0b29e67
Showing
4 changed files
with
157 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from pathlib import Path | ||
|
||
import holoviews as hv | ||
|
||
from panel.param import Param | ||
|
||
from lumen.sources import FileSource | ||
from lumen.target import Target | ||
|
||
|
||
def test_view_controls(): | ||
source = FileSource(tables={'test': 'sources/test.csv'}, root=str(Path(__file__).parent)) | ||
views = { | ||
'test': { | ||
'type': 'hvplot', 'table': 'test', 'controls': ['x', 'y'], | ||
'x': 'A', 'y': 'B', 'kind': 'scatter' | ||
} | ||
} | ||
target = Target(source=source, views=views) | ||
|
||
filter_panel = target.get_filter_panel() | ||
param_pane = filter_panel[0][0] | ||
assert isinstance(param_pane, Param) | ||
assert param_pane.parameters == ['x', 'y'] | ||
|
||
assert len(target._cards) == 1 | ||
card = target._cards[0] | ||
hv_pane = card[0][0] | ||
isinstance(hv_pane.object, hv.Scatter) | ||
assert hv_pane.object.kdims == ['A'] | ||
assert hv_pane.object.vdims == ['B'] | ||
|
||
param_pane._widgets['x'].value = 'C' | ||
param_pane._widgets['y'].value = 'D' | ||
|
||
isinstance(hv_pane.object, hv.Scatter) | ||
assert hv_pane.object.kdims == ['C'] | ||
assert hv_pane.object.vdims == ['D'] | ||
|
||
|
||
def test_view_controls_facetted(): | ||
source = FileSource(tables={'test': 'sources/test.csv'}, root=str(Path(__file__).parent)) | ||
views = { | ||
'test': { | ||
'type': 'hvplot', 'table': 'test', 'controls': ['x', 'y'], | ||
'x': 'A', 'y': 'B', 'kind': 'scatter' | ||
} | ||
} | ||
spec = { | ||
'source': 'test', | ||
'facet': {'by': 'C'}, | ||
'views': views | ||
} | ||
target = Target.from_spec(spec, sources={'test': source}) | ||
|
||
filter_panel = target.get_filter_panel() | ||
param_pane = filter_panel[4][0] | ||
assert isinstance(param_pane, Param) | ||
assert param_pane.parameters == ['x', 'y'] | ||
|
||
assert len(target._cards) == 5 | ||
for card in target._cards: | ||
hv_pane = card[0][0] | ||
isinstance(hv_pane.object, hv.Scatter) | ||
assert hv_pane.object.kdims == ['A'] | ||
assert hv_pane.object.vdims == ['B'] | ||
|
||
param_pane._widgets['x'].value = 'C' | ||
param_pane._widgets['y'].value = 'D' | ||
|
||
for card in target._cards: | ||
hv_pane = card[0][0] | ||
isinstance(hv_pane.object, hv.Scatter) | ||
assert hv_pane.object.kdims == ['C'] | ||
assert hv_pane.object.vdims == ['D'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters