@@ -21,13 +21,17 @@ type Data
21
21
22
22
t self = self.data.at 0
23
23
t2 self = self.data.at 1
24
+ t3_with_nulls self = self.data.at 2
25
+ t4_with_space self = self.data.at 3
24
26
25
27
setup = Data.Value <|
26
28
connection = Database.connect (SQLite.In_Memory)
27
29
in_mem = Table.new [["A", ['a', 'a', 'a']], ["B", [2, 2, 3]], ["C", [3, 5, 6]]]
28
30
t = in_mem.select_into_database_table connection "T" primary_key=Nothing temporary=True
29
31
t2 = Table.new [["A", [1, 2, 3]], ["B", [4, 5, 6]], ["C", [7, 8, 9]]]
30
- [t, t2]
32
+ t3_with_nulls = Table.new [["A", [1, Nothing, 3]], ["B", [4, Nothing, Nothing]], ["C", [7, Nothing, Nothing]]]
33
+ t4_with_space = Table.new [["A", ['hello', ' leading space', 'trailing space ']], ["B", ['a', 'b', 'c']], ["C", [7, 8, 9]]]
34
+ [t, t2, t3_with_nulls, t4_with_space]
31
35
32
36
33
37
type Foo
@@ -43,48 +47,51 @@ type Foo_Link
43
47
to_js_object self = JS_Object.from_pairs [["x", self.x], ["links", ["a", "b", "c"]]]
44
48
45
49
add_specs suite_builder =
46
- make_json header data all_rows value_type has_index_col get_child_node =
50
+ make_json header data all_rows value_type has_index_col get_child_node number_of_nothing number_of_whitespace =
47
51
p_header = ["header", header]
48
52
p_data = ["data", data]
49
53
p_all_rows = ["all_rows_count", all_rows]
50
54
p_value_type = ["value_type", value_type]
51
55
p_has_index_col = ["has_index_col", has_index_col]
52
56
p_get_child_node = ["get_child_node_action", get_child_node]
53
- pairs = [p_header, p_value_type, p_data, p_all_rows, p_has_index_col, p_get_child_node, ["type", "Table"]]
57
+ p_number_of_nothing = ["number_of_nothing", number_of_nothing]
58
+ p_number_of_whitespace = ["number_of_whitespace", number_of_whitespace]
59
+ data_quality_pairs = JS_Object.from_pairs [p_number_of_nothing, p_number_of_whitespace]
60
+ pairs = [p_header, p_value_type, p_data, p_all_rows, p_has_index_col, p_get_child_node, ["data_quality_pairs", data_quality_pairs], ["type", "Table"]]
54
61
JS_Object.from_pairs pairs . to_text
55
-
62
+
56
63
suite_builder.group "Table Visualization" group_builder->
57
64
data = Data.setup
58
65
59
66
group_builder.specify "should visualize database tables" <|
60
67
vis = Visualization.prepare_visualization data.t 1
61
68
value_type_int = JS_Object.from_pairs [["type", "Value_Type"], ["constructor", "Integer"], ["display_text", "Integer (64 bits)"], ["bits", 64]]
62
69
value_type_char = JS_Object.from_pairs [["type", "Value_Type"], ["constructor", "Char"], ["display_text", "Char (variable length, max_size=unlimited)"], ["size", Nothing], ["variable_length", True]]
63
- json = make_json header=["A", "B", "C"] data=[['a'], [2], [3]] all_rows=3 value_type=[value_type_char, value_type_int, value_type_int] has_index_col=True get_child_node="get_row"
70
+ json = make_json header=["A", "B", "C"] data=[['a'], [2], [3]] all_rows=3 value_type=[value_type_char, value_type_int, value_type_int] has_index_col=True get_child_node="get_row" number_of_nothing=Nothing number_of_whitespace=Nothing
64
71
vis . should_equal json
65
72
66
73
group_builder.specify "should visualize database columns" <|
67
74
vis = Visualization.prepare_visualization (data.t.at "A") 2
68
75
value_type_char = JS_Object.from_pairs [["type", "Value_Type"], ["constructor", "Char"], ["display_text", "Char (variable length, max_size=unlimited)"], ["size", Nothing], ["variable_length", True]]
69
76
value_type_float = JS_Object.from_pairs [["type", "Value_Type"], ["constructor", "Float"], ["display_text", "Float (64 bits)"], ["bits", 64]]
70
- json = make_json header=["A"] data=[['a', 'a']] all_rows=3 value_type=[value_type_char] has_index_col=True get_child_node="get_row"
77
+ json = make_json header=["A"] data=[['a', 'a']] all_rows=3 value_type=[value_type_char] has_index_col=True get_child_node="get_row" number_of_nothing=Nothing number_of_whitespace=Nothing
71
78
vis . should_equal json
72
79
73
80
g = data.t.aggregate ["A", "B"] [Aggregate_Column.Average "C"] . at "Average C"
74
81
vis2 = Visualization.prepare_visualization g 1
75
- json2 = make_json header=["Average C"] data=[[4.0]] all_rows=2 value_type=[value_type_float] has_index_col=True get_child_node="get_row"
82
+ json2 = make_json header=["Average C"] data=[[4.0]] all_rows=2 value_type=[value_type_float] has_index_col=True get_child_node="get_row" number_of_nothing=Nothing number_of_whitespace=Nothing
76
83
vis2 . should_equal json2
77
84
78
85
group_builder.specify "should visualize dataframe tables" <|
79
86
vis = Visualization.prepare_visualization data.t2 1
80
87
value_type_int = JS_Object.from_pairs [["type", "Value_Type"], ["constructor", "Integer"], ["display_text", "Integer (64 bits)"], ["bits", 64]]
81
- json = make_json header=["A", "B", "C"] data=[[1], [4], [7]] all_rows=3 value_type=[value_type_int, value_type_int, value_type_int] has_index_col=True get_child_node="get_row"
88
+ json = make_json header=["A", "B", "C"] data=[[1], [4], [7]] all_rows=3 value_type=[value_type_int, value_type_int, value_type_int] has_index_col=True get_child_node="get_row" number_of_nothing=[0,0,0] number_of_whitespace=[Nothing, Nothing, Nothing]
82
89
vis . should_equal json
83
90
84
91
group_builder.specify "should visualize dataframe columns" <|
85
92
vis = Visualization.prepare_visualization (data.t2.at "A") 2
86
93
value_type_int = JS_Object.from_pairs [["type", "Value_Type"], ["constructor", "Integer"], ["display_text", "Integer (64 bits)"], ["bits", 64]]
87
- json = make_json header=["A"] data=[[1, 2]] all_rows=3 value_type=[value_type_int] has_index_col=True get_child_node="get_row"
94
+ json = make_json header=["A"] data=[[1, 2]] all_rows=3 value_type=[value_type_int] has_index_col=True get_child_node="get_row" number_of_nothing=[0] number_of_whitespace=[Nothing]
88
95
vis . should_equal json
89
96
90
97
group_builder.specify "should handle Vectors" <|
@@ -124,8 +131,20 @@ add_specs suite_builder =
124
131
Visualization.prepare_visualization Value_Type.Char . should_equal (make_json Value_Type.Char)
125
132
Visualization.prepare_visualization Value_Type.Unsupported_Data_Type . should_equal (make_json Value_Type.Unsupported_Data_Type)
126
133
134
+ group_builder.specify "should indicate number of Nothing/Nulls" <|
135
+ vis = Visualization.prepare_visualization data.t3_with_nulls 3
136
+ value_type_int = JS_Object.from_pairs [["type", "Value_Type"], ["constructor", "Integer"], ["display_text", "Integer (64 bits)"], ["bits", 64]]
137
+ json = make_json header=["A", "B", "C"] data=[[1,Nothing,3],[4,Nothing,Nothing],[7,Nothing,Nothing]] all_rows=3 value_type=[value_type_int, value_type_int, value_type_int] has_index_col=True get_child_node="get_row" number_of_nothing=[1, 2, 2] number_of_whitespace=[Nothing, Nothing, Nothing]
138
+ vis . should_equal json
139
+
140
+ group_builder.specify "should indicate number of leading/trailing whitespace" <|
141
+ vis = Visualization.prepare_visualization data.t4_with_space 3
142
+ value_type_char = JS_Object.from_pairs [["type", "Value_Type"], ["constructor", "Char"], ["display_text", "Char (variable length, max_size=unlimited)"], ["size", Nothing], ["variable_length", True]]
143
+ value_type_int = JS_Object.from_pairs [["type", "Value_Type"], ["constructor", "Integer"], ["display_text", "Integer (64 bits)"], ["bits", 64]]
144
+ json = make_json header=["A", "B", "C"] data=[['hello', ' leading space', 'trailing space '],['a', 'b', 'c'],[7, 8, 9]] all_rows=3 value_type=[value_type_char, value_type_char, value_type_int] has_index_col=True get_child_node="get_row" number_of_nothing=[0, 0, 0] number_of_whitespace=[2, 0, Nothing]
145
+ vis . should_equal json
146
+
127
147
main filter=Nothing =
128
148
suite = Test.build suite_builder->
129
149
add_specs suite_builder
130
150
suite.run_with_filter filter
131
-
0 commit comments