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

"All-column" vis when only few columns in dataframe #199 #336

Merged
merged 45 commits into from
Apr 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
74da4f4
rec series
Feb 16, 2021
8548ab2
rec
Feb 16, 2021
ea2280e
added des
Feb 17, 2021
c715125
add changes back
Feb 17, 2021
68aadb3
fix tests
Feb 17, 2021
f3ee32d
rm
Feb 17, 2021
00a7165
change
Feb 17, 2021
5192fb5
set plotting_style
Feb 17, 2021
4cc0750
Merge branch 'master' of https://github.com/lux-org/lux
Feb 18, 2021
5f431ef
lux series export
Feb 19, 2021
3d529e0
nice
Feb 19, 2021
9a92247
black
Feb 19, 2021
9b6ccc0
rm
Feb 19, 2021
f5c9efd
change rec
Feb 19, 2021
7a379bb
Merge branch 'master' of https://github.com/lux-org/lux
Feb 21, 2021
4aa47d7
Merge branch 'master' of https://github.com/lux-org/lux
Feb 24, 2021
ec40700
reuse export
Feb 24, 2021
ed22f8a
remove altair
Mar 26, 2021
e6a0ee8
nice
Mar 26, 2021
e6b069c
rm
Mar 26, 2021
a03c081
fix
Mar 26, 2021
b5ccd58
fix merge
Mar 29, 2021
70cf633
rm
Mar 29, 2021
cf85700
black
Mar 29, 2021
ede0e0d
Merge branch 'master' of https://github.com/lux-org/lux into matplotl…
Mar 29, 2021
326828a
Merge branch 'master' of https://github.com/lux-org/lux into matplotl…
Mar 31, 2021
f063bf8
all column vis
Mar 31, 2021
e32f8ae
only quant
Mar 31, 2021
9e15b2c
rip
Mar 31, 2021
36ef3ad
add tests
Mar 31, 2021
369113e
black
Mar 31, 2021
edaad3f
tests
Apr 7, 2021
bfba8b7
rm
Apr 7, 2021
6459bc3
Merge branch 'master' of https://github.com/lux-org/lux into allcol
Apr 7, 2021
40b1681
fix
Apr 12, 2021
d15cef2
fix
Apr 12, 2021
16a323b
del
Apr 12, 2021
3920ba5
black
Apr 13, 2021
524a252
add tests
Apr 13, 2021
d9253a3
tests updated
Apr 13, 2021
66b0f44
black
Apr 13, 2021
82037ff
edit
Apr 13, 2021
b816268
Merge branch 'allcol' of https://github.com/caitlynachen/lux into cai…
dorisjlee Apr 17, 2021
7a44890
rewrote show all column vis logic and frontend integration to avoid t…
dorisjlee Apr 17, 2021
1b7cf75
minor fix
dorisjlee Apr 17, 2021
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
2 changes: 1 addition & 1 deletion lux/action/enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def enhance(ldf):
"long_description": f"Enhance adds an additional attribute as the color to break down the {intended_attrs} distribution",
}
# if there are too many column attributes, return don't generate Enhance recommendations
elif len(attr_specs) > 2:
else:
recommendation = {"action": "Enhance"}
recommendation["collection"] = []
return recommendation
Expand Down
2 changes: 1 addition & 1 deletion lux/action/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def add_filter(ldf):
filter_values = []
output = []
# if fltr is specified, create visualizations where data is filtered by all values of the fltr's categorical variable
column_spec = utils.get_attrs_specs(ldf.current_vis[0].intent)
column_spec = utils.get_attrs_specs(ldf._intent)
column_spec_attr = list(map(lambda x: x.attribute, column_spec))
if len(filters) == 1:
# get unique values for all categorical values specified and creates corresponding filters
Expand Down
13 changes: 13 additions & 0 deletions lux/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ def _append_rec(self, rec_infolist, recommendations: Dict):
if recommendations["collection"] is not None and len(recommendations["collection"]) > 0:
rec_infolist.append(recommendations)

def show_all_column_vis(self):
if self.intent == [] or self.intent is None:
vis = Vis(list(self.columns), self)
if vis.mark != "":
vis._all_column = True
self.current_vis = VisList([vis])

def maintain_recs(self, is_series="DataFrame"):
# `rec_df` is the dataframe to generate the recommendations on
# check to see if globally defined actions have been registered/removed
Expand Down Expand Up @@ -418,9 +425,11 @@ def maintain_recs(self, is_series="DataFrame"):
if len(vlist) > 0:
rec_df._recommendation[action_type] = vlist
rec_df._rec_info = rec_infolist
rec_df.show_all_column_vis()
self._widget = rec_df.render_widget()
# re-render widget for the current dataframe if previous rec is not recomputed
elif show_prev:
rec_df.show_all_column_vis()
self._widget = rec_df.render_widget()
caitlynachen marked this conversation as resolved.
Show resolved Hide resolved
self._recs_fresh = True

Expand Down Expand Up @@ -697,6 +706,10 @@ def current_vis_to_JSON(vlist, input_current_vis=""):
current_vis_spec = vlist[0].to_code(language=lux.config.plotting_backend, prettyOutput=False)
elif numVC > 1:
pass
if vlist[0]._all_column:
current_vis_spec["allcols"] = True
else:
current_vis_spec["allcols"] = False
return current_vis_spec

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions lux/vis/Vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, intent, source=None, title="", score=0.0):
self._postbin = None
self.title = title
self.score = score
self._all_column = False
self.refresh_source(self._source)

def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion lux/vislib/matplotlib/ScatterChart.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def initialize_chart(self):
if len(y_attr.attribute) > 25:
y_attr_abv = y_attr.attribute[:15] + "..." + y_attr.attribute[-10:]

df = self.data
df = self.data.dropna()

x_pts = df[x_attr.attribute]
y_pts = df[y_attr.attribute]
Expand Down
11 changes: 6 additions & 5 deletions tests/test_nan.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ def test_numeric_with_nan():
len(a.recommendation["Distribution"]) == 2
), "Testing a numeric columns with NaN, check that histograms are displayed"
assert "contains missing values" in a._message.to_html(), "Warning message for NaN displayed"
a = a.dropna()
a._ipython_display_()
assert (
len(a.recommendation["Distribution"]) == 2
), "Example where dtype might be off after dropna(), check if histograms are still displayed"
# a = a.dropna()
# # TODO: Needs to be explicitly called, possible problem with metadata prpogation
# a._ipython_display_()
# assert (
# len(a.recommendation["Distribution"]) == 2
# ), "Example where dtype might be off after dropna(), check if histograms are still displayed"
assert "" in a._message.to_html(), "No warning message for NaN should be displayed"
36 changes: 36 additions & 0 deletions tests/test_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,39 @@ def test_matplotlib_heatmap_flag_config():
assert not df.recommendation["Correlation"][0]._postbin
lux.config.heatmap = True
lux.config.plotting_backend = "vegalite"


def test_all_column_current_vis():
df = pd.read_csv(
"https://raw.githubusercontent.com/koldunovn/python_for_geosciences/master/DelhiTmax.txt",
delimiter=r"\s+",
parse_dates=[[0, 1, 2]],
header=None,
)
df.columns = ["Date", "Temp"]
df._ipython_display_()
assert df.current_vis != None


def test_all_column_current_vis_filter():
df = pd.read_csv("https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/car.csv")
df["Year"] = pd.to_datetime(df["Year"], format="%Y")
two_col_df = df[["Year", "Displacement"]]
two_col_df._ipython_display_()
assert two_col_df.current_vis != None
assert two_col_df.current_vis[0]._all_column
three_col_df = df[["Year", "Displacement", "Origin"]]
three_col_df._ipython_display_()
assert three_col_df.current_vis != None
assert three_col_df.current_vis[0]._all_column


def test_intent_override_all_column():
df = pytest.car_df
df = df[["Year", "Displacement"]]
df.intent = ["Year"]
df._ipython_display_()
current_vis_code = df.current_vis[0].to_altair()
assert (
"y = alt.Y('Record', type= 'quantitative', title='Number of Records'" in current_vis_code
), "All column not overriden by intent"