Skip to content

Commit

Permalink
checkpoint for bug repro
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Mar 25, 2021
1 parent 0baaceb commit e6d6289
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions test/Visualization_Tests/src/Table_Spec.enso
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from Standard.Base import all

from Standard.Database import all
import Standard.Database.Data.Table as Database_Table
import Standard.Table.Data.Table as Dataframe_Table
import Standard.Visualization.Table.Visualization as Visualization
import Standard.Test

Expand All @@ -15,12 +17,64 @@ visualization_spec connection =
t.insert ['a', 2, 3]
t.insert ['a', 2, 5]
t.insert ['a', 3, 6]

make_json header data all_rows ixes_header ixes =
p_header = ["header", header]
p_data = ["data", data]
p_all_rows = ["all_rows_count", all_rows]
p_ixes = ["indices", ixes]
p_ixes_header = ["indices_header", ixes_header]
pairs = [p_header, p_data, p_all_rows, p_ixes, p_ixes_header]
Json.from_pairs pairs . to_text

Test.group "Table Visualization" <|
Test.specify "should wrap internal errors" <|
Nothing
bad_table = Database_Table.Table Nothing Nothing Nothing Nothing
vis = Visualization.prepare_visualization bad_table 2
json = Json.from_pairs [["error", "FOO"]]
vis . should_equal json.to_text

Test.specify "should visualize database tables" <|
Nothing
vis = Visualization.prepare_visualization t 1
json = make_json header=["A", "B", "C"] data=[['a'], [2], [3]] all_rows=3 ixes_header=[] ixes=[]
vis . should_equal json

t2 = t.set_index "A"
vis2 = Visualization.prepare_visualization t2 1
json2 = make_json header=["B", "C"] data=[[2], [3]] all_rows=3 ixes_header=["A"] ixes=[['a']]
vis2 . should_equal json2

Test.specify "should visualize database columns" <|
vis = Visualization.prepare_visualization (t.at "A") 2
json = make_json header=["A"] data=[['a', 'a']] all_rows=3 ixes_header=[] ixes=[]
vis . should_equal json

g = t.group by=["A", "B"] . at "C" . mean
vis2 = Visualization.prepare_visualization g 1
json2 = make_json header=["C_mean"] data=[[4]] all_rows=2 ixes_header=["A", "B"] ixes=[['a'], [2]]
vis2 . should_equal json2

Test.specify "should visualize dataframe tables" <|
t = Dataframe_Table.new [["A", [1, 2, 3]], ["B", [4, 5, 6]], ["C", [7, 8, 9]]]
vis = Visualization.prepare_visualization t 1
json = make_json header=["A", "B", "C"] data=[[1], [4], [7]] all_rows=3 ixes_header=[""] ixes=[[0]]
vis . should_equal json

t2 = t.set_index "A"
vis2 = Visualization.prepare_visualization t2 1
json2 = make_json header=["B", "C"] data=[[4], [7]] all_rows=3 ixes_header=["A"] ixes=[[1]]
vis2 . should_equal json2

Test.specify "should visualize dataframe columns" <|
t = Dataframe_Table.new [["A", [1, 2, 3]], ["B", [4, 5, 6]], ["C", [7, 8, 9]]]
vis = Visualization.prepare_visualization (t.at "A") 2
json = make_json header=["A"] data=[['a', 'a']] all_rows=3 ixes_header=[""] ixes=[[0, 1]]
vis . should_equal json

g = t.group by=["A"] . at "C" . mean
vis2 = Visualization.prepare_visualization g 1
json2 = make_json header=["C_mean"] data=[[7]] all_rows=3 ixes_header=["A"] ixes=[[1]]
vis2 . should_equal json2

Test.specify "should handle Vectors" <|
vis = Visualization.prepare_visualization [1, 2, 3] 2
Expand Down

0 comments on commit e6d6289

Please sign in to comment.