Skip to content

Commit

Permalink
changes to test logic, minor string format for warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dorisjlee committed Jan 9, 2021
1 parent 2d7edf8 commit cc8e3ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lux/executor/PandasExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ def execute_aggregate(vis: Vis, isFiltered=True):
vis._vis_data = vis._vis_data.sort_values(by=groupby_attr.attribute, ascending=True)
except TypeError:
warnings.warn(
f"""\nLux detects that the attribute '{groupby_attr.attribute}' maybe of mixed type.
\n The following visualizations use
\n\tdf['{groupby_attr.attribute}'] = df['{groupby_attr.attribute}'].astype(str)\n"""
f"\nLux detects that the attribute '{groupby_attr.attribute}' maybe contain mixed type."
+ f"\nTo visualize this attribute, you may want to convert the '{groupby_attr.attribute}' into a uniform type as follows:"
+ f"\n\tdf['{groupby_attr.attribute}'] = df['{groupby_attr.attribute}'].astype(str)"
)
vis._vis_data[groupby_attr.attribute] = vis._vis_data[groupby_attr.attribute].astype(str)
vis._vis_data = vis._vis_data.sort_values(by=groupby_attr.attribute, ascending=True)
Expand Down
4 changes: 1 addition & 3 deletions tests/test_pandas_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,6 @@ def test_read_sas(global_var):
def test_read_multi_dtype(global_var):
url = "https://github.com/lux-org/lux-datasets/blob/master/data/car-data.xls?raw=true"
df = pd.read_excel(url)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
with pytest.warns(UserWarning, match="mixed type") as w:
df._repr_html_()
assert len(w) != 0, "warnings not generated"
assert "df['Car Type'] = df['Car Type'].astype(str)" in str(w[-1].message)

0 comments on commit cc8e3ee

Please sign in to comment.