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

Updating SQL Executor Test Suite #196

Merged
merged 133 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
308d99c
Merging Recent SQL Executor changes
19thyneb Oct 15, 2020
daa9a0d
Fix to Validator
19thyneb Oct 16, 2020
804b0dc
Fix Bug with Widget Rendering
19thyneb Oct 17, 2020
676f3e0
Added Number of Observations to MetaData, Fixed Interestingness issue…
19thyneb Oct 19, 2020
8763df9
Re-added Licensing Headers
19thyneb Oct 19, 2020
c2b0b46
Adding Recent frame.py changes
19thyneb Oct 19, 2020
1b08461
Adjusted SQL Executor Tests
19thyneb Oct 19, 2020
38c5e7e
Update Frame with new Action Registering
19thyneb Oct 22, 2020
14d2f90
Resolving Conflicts in frame.py
19thyneb Oct 22, 2020
78d8e10
Merge branch 'sql-engine' into Database-Executor
thyneb19 Oct 22, 2020
d783b4c
Commenting out local SQL Executor tests
19thyneb Oct 22, 2020
c03e001
Merge branch 'Database-Executor' of https://github.com/thyneb19/lux i…
19thyneb Oct 22, 2020
8f0e643
Update correlation.py
dorisjlee Oct 22, 2020
d365d52
Update frame.py
dorisjlee Oct 22, 2020
74ed59c
bugfix: "number of remaining bars" text overcounts for colored bar ch…
dorisjlee Oct 22, 2020
7da2992
Fixing Code Format
19thyneb Oct 22, 2020
f1b7c8b
Cleaning up Pandas Executor imports
19thyneb Oct 22, 2020
d97f0e4
Fix Validation Bug
19thyneb Oct 22, 2020
582b370
Changed metadata variable name
19thyneb Oct 23, 2020
16ded3a
Adding support for setting intent on front end (#112)
cjachekang Oct 23, 2020
554c71f
Merge remote-tracking branch 'upstream/sql-engine' into Database-Exec…
19thyneb Oct 23, 2020
b825c51
Make default_display a global setting (#121)
caitlynachen Oct 25, 2020
d65687a
Added script to generate Postgresql database
19thyneb Oct 25, 2020
7243b2f
Update upload_car_data.py
19thyneb Oct 25, 2020
2add76f
Updated script name in travis.yml
19thyneb Oct 25, 2020
cf74beb
Removed unnecessary import from travis.yml
19thyneb Oct 25, 2020
14d52b8
Added psycopg2 to requirements.txt
19thyneb Oct 25, 2020
379517d
Creating Postgres test database in travis
19thyneb Oct 25, 2020
a72f236
Fixed directory issue
19thyneb Oct 25, 2020
e947fd6
Updated SQL Executor Tests
19thyneb Oct 26, 2020
0fb9421
Update requirements.txt (#128)
dorisjlee Oct 29, 2020
a06d968
replaced _exportedVisIdxs --> _selectedVisIdxs
dorisjlee Oct 29, 2020
f740e89
bugfix: plot config error when current_vis is None
dorisjlee Oct 30, 2020
1234009
Added sql_executor example notebook, minor bug fix
19thyneb Oct 31, 2020
6a20c47
Add LuxSeries Implementation (#122)
westernguy2 Nov 2, 2020
f986c76
add black to travis (#127)
jinimukh Nov 2, 2020
4eb2bb1
fix doc failing from black format
dorisjlee Nov 2, 2020
a5eff98
Cleaned SQL Executor Example Notebook
19thyneb Nov 2, 2020
5e18fd8
Update custom action reference to executor
19thyneb Nov 2, 2020
9311224
Updated Interestingness Tests (#133)
thyneb19 Nov 4, 2020
cb4c90f
fix broken link in docs
dorisjlee Nov 4, 2020
8029ac1
Updated Tests, Added benchmarking for SQL Executor
19thyneb Nov 6, 2020
bca1f0c
Merge remote-tracking branch 'upstream/master' into Database-Executor
19thyneb Nov 7, 2020
4046579
Merge with upstream branch, added preliminary benchmarking code
19thyneb Nov 7, 2020
9897d0e
Better warning message for Vis and VisList (#135)
cjachekang Nov 9, 2020
af0043a
Pandas rewrite Performance optimizations (#136)
dorisjlee Nov 11, 2020
907f215
Added 2D Binning functionality to SQL Executor
19thyneb Nov 15, 2020
603e3d7
Update README.md
dorisjlee Nov 15, 2020
852c6a1
Updated temporal detection and tests (#139)
jrdzha Nov 16, 2020
ea20833
Fix Inline comments breaking to new lines (#137)
jinimukh Nov 16, 2020
7430e01
Improve warning message when values specified as attributes (#143)
dorisjlee Nov 17, 2020
f5be470
Better warning message for Vis and VisList (#146)
cjachekang Nov 18, 2020
da79415
Updated docs for JupyterLab (#148)
cjachekang Nov 19, 2020
21e20cf
Global shared variable in test (#144) (#149)
piyushg9794 Nov 19, 2020
2b24129
Merge remote-tracking branch 'upstream/master' into Database-Executor
19thyneb Nov 19, 2020
21ba332
Updated 2D Binning Functionality
19thyneb Nov 19, 2020
d8e3a7c
documentation for custom actions (#134)
caitlynachen Nov 20, 2020
d2a19da
Patch failing test (#134)
dorisjlee Nov 21, 2020
5f8c200
Patch failing test (#134)
dorisjlee Nov 21, 2020
f7fe32d
Patch failing test (#134)
dorisjlee Nov 21, 2020
b7ac30c
Added Heatmap generation to SQL Executor, Bug fix in PandasExecutor
19thyneb Nov 22, 2020
ad32db7
Updated Code Formatting with Black
19thyneb Nov 22, 2020
8948538
Merge branch 'sql-engine' into Database-Executor
thyneb19 Nov 22, 2020
6f032f2
Update Requirements to include psycopg2
19thyneb Nov 22, 2020
06dbf14
Merge branch 'Database-Executor' of https://github.com/thyneb19/lux i…
19thyneb Nov 22, 2020
aff131f
Update upload_car_data.py
19thyneb Nov 22, 2020
0ca0d98
Update Compiler tests to use correct test DB
19thyneb Nov 22, 2020
776489f
Removed Benchmarking Code
19thyneb Nov 22, 2020
7d00742
Fixing Black Formatting
19thyneb Nov 22, 2020
3543b12
Add Toggle button for LuxSeries (#153)
westernguy2 Nov 23, 2020
974079d
Reformat Warnings Labels (#151)
caitlynachen Nov 23, 2020
b1bb129
Make plot_config a global variable (#152)
jinimukh Nov 23, 2020
873629c
Patch documentation (#134)
dorisjlee Nov 23, 2020
8991206
code cleanup
dorisjlee Nov 25, 2020
7101df1
Moved Executor Parameters to Global Config
19thyneb Nov 25, 2020
4e3ecb7
Black formatting
19thyneb Nov 25, 2020
8e42fb8
Fix issue with read_json and add tests for different file types (#156)
westernguy2 Nov 26, 2020
3a8d9f9
Improved warning message stack trace for unexpected error (#145)
dorisjlee Nov 27, 2020
a48cdc7
Moved table_name parameter to frame.py. Removed executor_type parameter
19thyneb Nov 27, 2020
bccd61a
Fixed reference to table_name parameter
19thyneb Nov 28, 2020
770a30d
bug fix patching #146 (#159)
dorisjlee Nov 28, 2020
b3e33fa
Ensure that recommendation and current_vis properties are accessible …
dorisjlee Nov 28, 2020
8149e72
bugfix erased `name` dtype in LuxSeries (#140)
dorisjlee Nov 28, 2020
5794718
Adjusted Functions to Set SQL Connection
19thyneb Nov 29, 2020
fb61c27
Merge branch 'master' into Database-Executor
19thyneb Nov 29, 2020
43a70c1
Update Makefile and pyproject.toml (#160)
jinimukh Nov 29, 2020
0c6443a
Update README.md
dorisjlee Nov 29, 2020
727315b
Update SQLExecutor name parameter
19thyneb Nov 29, 2020
52e6be4
Merging master branch with sql engine. Moving executor parameters to …
19thyneb Nov 29, 2020
2cc5b10
Merge branch 'master' into Database-Executor
19thyneb Nov 29, 2020
10e9ea1
Merge remote-tracking branch 'upstream/master' into Database-Executor
19thyneb Nov 29, 2020
b3e1e88
Parameter Bug Fix
19thyneb Nov 29, 2020
d774a41
Reference Fix in Warning
19thyneb Nov 29, 2020
9747848
Black Formatting
19thyneb Nov 29, 2020
fbafb96
Merge branch 'sql-engine' into Database-Executor
19thyneb Nov 29, 2020
ecfb434
Black formatting
19thyneb Nov 29, 2020
1034e2b
bump version number and requirements
dorisjlee Nov 30, 2020
705cd05
PATCH v0.2.1.1
dorisjlee Nov 30, 2020
47ece2b
Merge remote-tracking branch 'upstream/master'
19thyneb Nov 30, 2020
3e68db3
Fix Executor Reference
19thyneb Nov 30, 2020
3a5473e
Update frame.py
dorisjlee Dec 2, 2020
68d1600
Moved set functions to global config
19thyneb Dec 2, 2020
b6a5e99
Cleaned up executor imports, Fixed issue in AltairRenderer
19thyneb Dec 3, 2020
9a1748c
Black formatting
19thyneb Dec 3, 2020
3b316d9
Moved Executor Parameters to Global Config (#157)
thyneb19 Dec 3, 2020
868156d
save_as_html feature (#170)
dorisjlee Dec 5, 2020
476f0ac
Updating documentation for lux-widget v0.1.2 release (#176)
cjachekang Dec 9, 2020
91f965f
Fix bug caused by `groupby.agg` on column with many unique values (#174)
westernguy2 Dec 9, 2020
dd3818a
Update save_as_html docs (#170)
dorisjlee Dec 10, 2020
227f150
Update README
dorisjlee Dec 10, 2020
b7635c0
Update README.md
dorisjlee Dec 19, 2020
cb22f5c
Merge remote-tracking branch 'upstream/master'
19thyneb Dec 20, 2020
5223a11
Fixed Index Issue in Pandas Executor
19thyneb Dec 20, 2020
e08460b
Making Lux more robust with missing values and NaN (#179) (#180)
dorisjlee Dec 21, 2020
96a38e7
bump version and requirement
dorisjlee Dec 21, 2020
ad89594
Added tests for set_index functions
19thyneb Dec 21, 2020
4718c05
Black formatting
19thyneb Dec 21, 2020
2a7d4b2
Merge remote-tracking branch 'upstream/master'
19thyneb Dec 22, 2020
269c062
Update Pandas Executor to handle NA values
19thyneb Dec 22, 2020
79b381a
Merge branch 'master' into Database-Executor
19thyneb Dec 27, 2020
fd93cd4
Update to Config, and Compiler/Interestingness Tests
19thyneb Dec 27, 2020
7324e29
Merge branch 'sql-engine' into Database-Executor
19thyneb Dec 27, 2020
674d828
Black formatting
19thyneb Dec 27, 2020
2931442
Update Requirements.txt
19thyneb Dec 27, 2020
7cc9626
Update SQL Executor Documentation
19thyneb Jan 4, 2021
1d517d8
Updated SQLExecutor Example Notebook
19thyneb Jan 4, 2021
f5a358c
Merge branch 'sql-engine' into Database-Executor
19thyneb Jan 4, 2021
3a27d76
Black Formatting
19thyneb Jan 4, 2021
1229809
Update to SQL Executor Tests
19thyneb Jan 4, 2021
c405f67
Update Travis file and SQL Executor Tests
19thyneb Jan 5, 2021
7eb665e
Merge branch 'sql-engine' into Database-Executor
thyneb19 Jan 5, 2021
86a35fa
Update .travis.yml
19thyneb Jan 5, 2021
d539b83
Merge branch 'Database-Executor' of https://github.com/thyneb19/lux i…
19thyneb Jan 5, 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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ before_script:
- psql -c "ALTER DATABASE postgres OWNER TO travis;"
- psql -c "DROP schema public cascade;" -U postgres
- psql -c "CREATE schema public;" -U postgres
- psql -c "CREATE DATABASE postgres_db;" -U postgres
# - psql -c "CREATE DATABASE postgres;" -U postgres
# command to upload data to test environment SQL database and run tests
script:
- python lux/data/upload_car_data.py
Expand Down
1 change: 0 additions & 1 deletion lux/data/upload_car_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
target_url = "https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/car.csv"
for line in urllib.request.urlopen(target_url):
decoded = line.decode("utf-8")
print(decoded.split(","))
if "Name,MilesPerGal,Cylinders" not in decoded:
cur.execute(
"INSERT INTO cars VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", decoded.split(",")
Expand Down
64 changes: 32 additions & 32 deletions tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def test_underspecified_no_vis(global_var, test_recs):
assert len(df.current_vis) == 0

# test for sql executor
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

test_recs(sql_df, no_vis_actions)
assert len(sql_df.current_vis) == 0
Expand All @@ -60,10 +60,10 @@ def test_underspecified_single_vis(global_var, test_recs):
assert attr.data_type == "quantitative"
df.clear_intent()

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
sql_df.set_intent([lux.Clause(attribute="milespergal"), lux.Clause(attribute="weight")])
test_recs(sql_df, one_vis_actions)
assert len(sql_df.current_vis) == 1
Expand Down Expand Up @@ -114,10 +114,10 @@ def test_set_intent_as_vis(global_var, test_recs):
df._repr_html_()
test_recs(df, ["Enhance", "Filter", "Generalize"])

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
sql_df._repr_html_()
vis = sql_df.recommendation["Correlation"][0]
sql_df.intent = vis
Expand Down Expand Up @@ -150,17 +150,17 @@ def test_parse(global_var):
vlst = VisList([lux.Clause("Origin=?"), lux.Clause("MilesPerGal")], df)
assert len(vlst) == 3

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
vlst = VisList([lux.Clause("origin=?"), lux.Clause(attribute="milespergal")], sql_df)
assert len(vlst) == 3

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
vlst = VisList([lux.Clause("origin=?"), lux.Clause("milespergal")], sql_df)
assert len(vlst) == 3

Expand All @@ -183,10 +183,10 @@ def test_underspecified_vis_collection_zval(global_var):
# vlst = VisList([lux.Clause(attribute = ["Origin","Cylinders"], filter_op="=",value="?"),lux.Clause(attribute = ["Horsepower"]),lux.Clause(attribute = "Weight")],df)
# assert len(vlst) == 8

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
vlst = VisList(
[
lux.Clause(attribute="origin", filter_op="=", value="?"),
Expand Down Expand Up @@ -224,10 +224,10 @@ def test_sort_bar(global_var):
assert vis.mark == "bar"
assert vis._inferred_intent[1].sort == "ascending"

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
vis = Vis(
[
lux.Clause(attribute="acceleration", data_model="measure", data_type="quantitative"),
Expand All @@ -238,10 +238,10 @@ def test_sort_bar(global_var):
assert vis.mark == "bar"
assert vis._inferred_intent[1].sort == ""

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
vis = Vis(
[
lux.Clause(attribute="acceleration", data_model="measure", data_type="quantitative"),
Expand Down Expand Up @@ -339,10 +339,10 @@ def test_autoencoding_scatter(global_var):
]
)

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
visList = VisList(
[lux.Clause(attribute="?"), lux.Clause(attribute="milespergal", channel="x")],
sql_df,
Expand Down Expand Up @@ -394,10 +394,10 @@ def test_autoencoding_scatter():
)

# test for sql executor
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
vis = Vis([lux.Clause(attribute="milespergal"), lux.Clause(attribute="weight")], sql_df)
check_attribute_on_channel(vis, "milespergal", "x")
check_attribute_on_channel(vis, "weight", "y")
Expand Down Expand Up @@ -449,10 +449,10 @@ def test_autoencoding_histogram(global_var):

# No channel specified
# test for sql executor
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
vis = Vis([lux.Clause(attribute="milespergal", channel="y")], sql_df)
check_attribute_on_channel(vis, "milespergal", "y")

Expand Down Expand Up @@ -502,10 +502,10 @@ def test_autoencoding_line_chart(global_var):
)

# test for sql executor
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
vis = Vis([lux.Clause(attribute="year"), lux.Clause(attribute="acceleration")], sql_df)
check_attribute_on_channel(vis, "year", "x")
check_attribute_on_channel(vis, "acceleration", "y")
Expand Down Expand Up @@ -558,10 +558,10 @@ def test_autoencoding_color_line_chart(global_var):
check_attribute_on_channel(vis, "Origin", "color")

# test for sql executor
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
intent = [
lux.Clause(attribute="year"),
lux.Clause(attribute="acceleration"),
Expand Down Expand Up @@ -599,10 +599,10 @@ def test_autoencoding_color_scatter_chart(global_var):
check_attribute_on_channel(vis, "Acceleration", "color")

# test for sql executor
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
vis = Vis(
[
lux.Clause(attribute="horsepower"),
Expand Down Expand Up @@ -653,10 +653,10 @@ def test_populate_options(global_var):
)

# test for sql executor
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
sql_df.set_intent([lux.Clause(attribute="?"), lux.Clause(attribute="milespergal")])
col_set = set()
for specOptions in Compiler.populate_wildcard_options(sql_df._intent, sql_df)["attributes"]:
Expand Down Expand Up @@ -696,10 +696,10 @@ def test_remove_all_invalid(global_var):
assert len(df.current_vis) == 0

# test for sql executor
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = pd.DataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")
# with pytest.warns(UserWarning,match="duplicate attribute specified in the intent"):
sql_df.set_intent(
[
Expand Down
44 changes: 22 additions & 22 deletions tests/test_sql_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@


def test_lazy_execution():
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

intent = [
lux.Clause(attribute="horsepower", aggregation="mean"),
Expand All @@ -40,10 +40,10 @@ def test_lazy_execution():


def test_selection():
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

intent = [
lux.Clause(attribute=["horsepower", "weight", "acceleration"]),
Expand All @@ -55,10 +55,10 @@ def test_selection():


def test_aggregation():
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

intent = [
lux.Clause(attribute="horsepower", aggregation="mean"),
Expand Down Expand Up @@ -89,10 +89,10 @@ def test_colored_bar_chart():
from lux.vis.Vis import Vis
from lux.vis.Vis import Clause

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

x_clause = Clause(attribute="milespergal", channel="x")
y_clause = Clause(attribute="origin", channel="y")
Expand All @@ -112,10 +112,10 @@ def test_colored_line_chart():
from lux.vis.Vis import Vis
from lux.vis.Vis import Clause

connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

x_clause = Clause(attribute="year", channel="x")
y_clause = Clause(attribute="milespergal", channel="y")
Expand All @@ -133,10 +133,10 @@ def test_colored_line_chart():


def test_filter():
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

intent = [
lux.Clause(attribute="horsepower"),
Expand All @@ -151,10 +151,10 @@ def test_filter():


def test_inequalityfilter():
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

vis = Vis(
[
Expand All @@ -179,31 +179,31 @@ def test_inequalityfilter():


def test_binning():
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

vis = Vis([lux.Clause(attribute="horsepower")], sql_df)
nbins = list(filter(lambda x: x.bin_size != 0, vis._inferred_intent))[0].bin_size
assert len(vis.data) == nbins


def test_record():
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

vis = Vis([lux.Clause(attribute="cylinders")], sql_df)
assert len(vis.data) == len(sql_df.unique_values["cylinders"])


def test_filter_aggregation_fillzero_aligned():
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

intent = [
lux.Clause(attribute="cylinders"),
Expand All @@ -217,10 +217,10 @@ def test_filter_aggregation_fillzero_aligned():


def test_exclude_attribute():
connection = psycopg2.connect("host=localhost dbname=postgres_db user=postgres password=lux")
connection = psycopg2.connect("host=localhost dbname=postgres user=postgres password=lux")
sql_df = lux.LuxDataFrame()
lux.config.set_SQL_connection(connection)
sql_df.set_SQL_table("car")
sql_df.set_SQL_table("cars")

intent = [lux.Clause("?", exclude=["name", "year"]), lux.Clause("horsepower")]
vislist = VisList(intent, sql_df)
Expand Down