@@ -74,6 +74,16 @@ add_group_number_specs suite_builder setup =
7474 g7 = t.add_group_number (..Equal_Count 2 order_by='z') "g"
7575 g7.at 'g' . to_vector . should_equal [0, 1, 1, 0, 0]
7676
77+ g8 = t.add_group_number (..Equal_Count 1) "g"
78+ g8.at 'g' . to_vector . should_equal [0, 0, 0, 0, 0]
79+
80+ g9 = t.add_group_number (..Equal_Count 1 order_by=['x']) "g"
81+ g9.at 'g' . to_vector . should_equal [0, 0, 0, 0, 0]
82+
83+ g10 = t.add_group_number (..Equal_Count 1 order_by=['y']) "g"
84+ g10.at 'g' . to_vector . should_equal [0, 0, 0, 0, 0]
85+
86+
7787 group_builder.specify "should add group number by unique values" <|
7888 t = table_builder_from_rows ['x', 'y', 'z'] [[1, 0, 2], [0, 1, 0], [1, 2, 0], [0, 1, 1], [1, 0, 1], [1, 2, 1]]
7989
@@ -97,6 +107,16 @@ add_group_number_specs suite_builder setup =
97107
98108 t.add_group_number ..Unique "g" . should_fail_with Missing_Argument
99109
110+ group_builder.specify "must specify nonempty group_by with Unique" <|
111+ t = table_builder_from_rows ['x', 'y', 'z'] [[1, 0, 2], [0, 1, 0], [1, 2, 0], [0, 1, 1], [1, 0, 1], [1, 2, 1]]
112+
113+ t.add_group_number (..Unique on=[]) "g" . should_fail_with Illegal_Argument
114+
115+ group_builder.specify "must specify one or more groups with Equal_Count" <|
116+ t = table_builder [['x', [1, 2, 3, 4, 5]], ['y', [5, 4, 3, 2, 1]], ['z', [1, 5, 4, 2, 3]]]
117+ t.add_group_number (..Equal_Count 0) "g" . should_fail_with Illegal_Argument
118+ t.add_group_number (..Equal_Count -1) "g" . should_fail_with Illegal_Argument
119+
100120 group_builder.specify "should report floating point equality warning when grouping on float columns" <|
101121 t = table_builder_from_rows ['x', 'y', 'z'] [[1.0, 0.0, 2.0], [0.0, 1.0, 0.0], [1.0, 2.0, 0.0], [0.0, 1.0, 1.0], [1.0, 0.0, 1.0], [1.0, 2.0, 1.0]]
102122 g0 = t.add_group_number (..Unique on=['x', 'y']) "g"
@@ -124,8 +144,9 @@ add_group_number_specs suite_builder setup =
124144 t2.catch.to_display_text . should_contain "The row number has exceeded the 64-bit integer range"
125145
126146 group_builder.specify "should rename existing column upon a name clash, and attach a warning" <|
127- t = table_builder_from_rows ['x', 'y', 'z'] [[1, 0, 2 ], [0, 1, 0 ], [1, 2, 0 ], [0, 1, 1 ], [1, 0, 1 ], [1, 2, 1 ]]
147+ t = table_builder_from_rows ['x', 'y', 'z'] [['b', 'a', 'c' ], ['a', 'b', 'a' ], ['b', 'b', 'a' ], ['a', 'b', 'b' ], ['b', 'a', 'b' ], ['b', 'b', 'b' ]]
128148
129149 g0 = t.add_group_number (..Unique on=['x', 'y']) "y"
130- g0.at 'y 1' . to_vector . should_equal [0, 1, 2, 1, 0, 2]
150+ g0.at 'y' . to_vector . should_equal [0, 1, 2, 1, 0, 2]
151+ g0.at 'y 1' . to_vector . should_equal ['a', 'b', 'b', 'b', 'a', 'b']
131152 Problems.expect_warning Duplicate_Output_Column_Names g0
0 commit comments