Skip to content

Commit

Permalink
more tests, adapt some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Apr 21, 2023
1 parent d13e799 commit 5ac7794
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,8 @@ type Table
name_mapper = if matched_name.is_empty then Aggregate_Column_Helper.default_aggregate_column_name else
if validated_values.length == 1 then (_ -> "") else
all_same = Aggregate_Column_Helper.all_same_column validated_values
c -> Aggregate_Column_Helper.default_aggregate_column_name c all_same
include_column_name = all_same.not
c -> Aggregate_Column_Helper.default_aggregate_column_name c include_column_name

data_columns = validated_values.map c->
col_name = c.new_name.if_nothing <|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ default_aggregate_column_name aggregate_column include_column=True =
_ ->
prefix = Meta.get_simple_type_name aggregate_column . replace "_" " "
c = aggregate_column.column
prefix + " " + (if include_column then c.name else "")
prefix + (if include_column then " " + c.name else "")

## PRIVATE
Utility function to check if all aggregates are operating on the same source column.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ spec setup =
t2.at "Count Not Empty Text" . value_type . is_integer . should_be_true
t2.at "Sum Int" . value_type . is_numeric . should_be_true
t2.at "Sum Float" . value_type . is_floating_point . should_be_true
t2.at "Average Int" . value_type . is_floating_point . should_be_true
t2.at "Average Int" . value_type . is_numeric . should_be_true
t2.at "Concatenate Text" . value_type . is_text . should_be_true

Test.group prefix+"Table.aggregate should raise warnings when there are issues computing aggregation" pending=(resolve_pending test_selection.aggregation_problems) <|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ spec setup =

Test.specify "should allow multiple values aggregates" <|
t1 = table.cross_tab values=[Count, Sum "Value"]
t1.column_names . should_equal ["x Count", "x Sum Value", "y Count", "y Sum Value", "z Count", "z Sum Value"]
t1.column_names . should_equal ["x Count", "x Sum", "y Count", "y Sum", "z Count", "z Sum"]
t1.row_count . should_equal 1
t1.at "x Count" . to_vector . should_equal [4]
t1.at "x Sum Value" . to_vector . should_equal [10]
t1.at "x Sum" . to_vector . should_equal [10]
t1.at "y Count" . to_vector . should_equal [3]
t1.at "y Sum Value" . to_vector . should_equal [18]
t1.at "y Sum" . to_vector . should_equal [18]
t1.at "z Count" . to_vector . should_equal [2]
t1.at "z Sum Value" . to_vector . should_equal [17]
t1.at "z Sum" . to_vector . should_equal [17]

Test.specify "should fail if name_field is not found" <|
err1 = table.cross_tab [] "Name"
Expand Down

0 comments on commit 5ac7794

Please sign in to comment.