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

Double init semi-bug fix #131

Closed
wants to merge 22 commits into from
Closed
Changes from all 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
41 changes: 13 additions & 28 deletions lux/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ def plot_config(self, config_func: Callable):
----------
config_func : Callable
A function that takes in an AltairChart (https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html) as input and returns an AltairChart as output

Example
----------
Changing the color of marks and adding a title for all charts displayed for this dataframe
Expand Down Expand Up @@ -255,12 +254,10 @@ def set_intent(self, intent: List[Union[str, Clause]]):
"""
Main function to set the intent of the dataframe.
The intent input goes through the parser, so that the string inputs are parsed into a lux.Clause object.

Parameters
----------
intent : List[str,Clause]
intent list, can be a mix of string shorthand or a lux.Clause object

Notes
-----
:doc:`../guide/clause`
Expand Down Expand Up @@ -291,7 +288,6 @@ def copy_intent(self):
def set_intent_as_vis(self, vis: Vis):
"""
Set intent of the dataframe as the Vis

Parameters
----------
vis : Vis
Expand Down Expand Up @@ -568,14 +564,12 @@ def widget(self):
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]
Expand Down Expand Up @@ -660,9 +654,7 @@ def set_intent_on_click(self, change):
self.current_vis = Compiler.compile_intent(self, self._intent)
self.maintain_recs()

with self.output:
clear_output()
display(self._widget)
self._toggle_pandas_display = not self._toggle_pandas_display

self._widget.observe(self.remove_deleted_recs, names="deletedIndices")
self._widget.observe(self.set_intent_on_click, names="selectedIntentIndex")
Expand Down Expand Up @@ -726,30 +718,24 @@ def _repr_html_(self):
)

if len(self.recommendation) > 0:
# box = widgets.Box(layout=widgets.Layout(display='inline'))
button = widgets.Button(
description="Toggle Pandas/Lux",
layout=widgets.Layout(width="140px", top="5px"),
)
self.output = widgets.Output()
# box.children = [button,output]
# output.children = [button]
# display(box)
display(button, self.output)
# self.output = widgets.Output()
# display(button, self.output)

def on_button_clicked(b):
with self.output:
if b:
self._toggle_pandas_display = (
not self._toggle_pandas_display
)
if b:
self._toggle_pandas_display = (
not self._toggle_pandas_display
)
clear_output()
if self._toggle_pandas_display:
display(self.display_pandas())
else:
# b.layout.display = "none"
display(self._widget)
# b.layout.display = "inline-block"
display(button)
if self._toggle_pandas_display:
display(self.display_pandas())
else:
display(self._widget)

button.on_click(on_button_clicked)
on_button_clicked(None)
Expand Down Expand Up @@ -777,7 +763,6 @@ def display_pandas(self):
def render_widget(self, renderer: str = "altair", input_current_vis=""):
"""
Generate a LuxWidget based on the LuxDataFrame

Structure of widgetJSON:
{
'current_vis': {},
Expand Down Expand Up @@ -893,4 +878,4 @@ def info(self, *args, **kwargs):
def describe(self, *args, **kwargs):
self._pandas_only = True
self._history.append_event("describe", *args, **kwargs)
return super(LuxDataFrame, self).describe(*args, **kwargs)
return super(LuxDataFrame, self).describe(*args, **kwargs)