Skip to content

Commit

Permalink
Add export Vis option to LuxSeries (#277)
Browse files Browse the repository at this point in the history
* rec series

* rec

* add changes back

* fix tests

* rm

* change

* set plotting_style

* nice

* black

* rm

* change rec

* reuse export

* black

Co-authored-by: Caitlyn Chen <caitlynachen@berkeley.edu>
Co-authored-by: Doris Lee <dorisjunglinlee@gmail.com>
  • Loading branch information
3 people committed Feb 24, 2021
1 parent 82aa987 commit 9f6de1f
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions lux/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import numpy as np
from lux.history.history import History
from lux.utils.message import Message
from lux.vis.VisList import VisList
from typing import Dict, Union, List, Callable


class LuxSeries(pd.Series):
Expand Down Expand Up @@ -113,6 +115,7 @@ def __repr__(self):
if self.name is None:
self.name = " "
ldf = LuxDataFrame(self)
self._ldf = ldf

try:
# Ignore recommendations when Series a results of:
Expand Down Expand Up @@ -157,6 +160,9 @@ def __repr__(self):
ldf._widget.observe(ldf.remove_deleted_recs, names="deletedIndices")
ldf._widget.observe(ldf.set_intent_on_click, names="selectedIntentIndex")

self._widget = ldf._widget
self._recommendation = ldf._recommendation

if len(ldf.recommendation) > 0:
# box = widgets.Box(layout=widgets.Layout(display='inline'))
button = widgets.Button(
Expand Down Expand Up @@ -207,11 +213,35 @@ def on_button_clicked(b):
def recommendation(self):
from lux.core.frame import LuxDataFrame

if self.name is None:
self.name = " "
ldf = LuxDataFrame(self)

if self._recommendation is not None and self._recommendation == {}:
if self.name is None:
self.name = " "
ldf = LuxDataFrame(self)

ldf.maintain_metadata()
ldf.maintain_recs()
return ldf._recommendation
self._recommendation = ldf._recommendation
return self._recommendation

@property
def exported(self) -> Union[Dict[str, VisList], VisList]:
"""
Get selected visualizations as exported Vis List
Notes
-----
Convert the _selectedVisIdxs dictionary into a programmable VisList
Example _selectedVisIdxs :
{'Correlation': [0, 2], 'Occurrence': [1]}
indicating the 0th and 2nd vis from the `Correlation` tab is selected, and the 1st vis from the `Occurrence` tab is selected.
Returns
-------
Union[Dict[str,VisList], VisList]
When there are no exported vis, return empty list -> []
When all the exported vis is from the same tab, return a VisList of selected visualizations. -> VisList(v1, v2...)
When the exported vis is from the different tabs, return a dictionary with the action name as key and selected visualizations in the VisList. -> {"Enhance": VisList(v1, v2...), "Filter": VisList(v5, v7...), ..}
"""
return self._ldf.exported

0 comments on commit 9f6de1f

Please sign in to comment.