From 5ac77948680b06b7e202ba86cd94c7abf8a9a0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Fri, 21 Apr 2023 14:11:00 +0200 Subject: [PATCH] more tests, adapt some stuff --- .../lib/Standard/Table/0.0.0-dev/src/Data/Table.enso | 3 ++- .../0.0.0-dev/src/Internal/Aggregate_Column_Helper.enso | 2 +- .../src/Common_Table_Operations/Aggregate_Spec.enso | 2 +- .../src/Common_Table_Operations/Cross_Tab_Spec.enso | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso index fbba4cf27c81e..4cd8bad9d0c60 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso @@ -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 <| diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Aggregate_Column_Helper.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Aggregate_Column_Helper.enso index ff1af94abc1f1..122f5965e25ab 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Aggregate_Column_Helper.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Aggregate_Column_Helper.enso @@ -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. diff --git a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso index 83cff4f6228f3..95a75f0b7c52a 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -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) <| diff --git a/test/Table_Tests/src/Common_Table_Operations/Cross_Tab_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Cross_Tab_Spec.enso index 311352fb8c074..1ef96094f4108 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Cross_Tab_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Cross_Tab_Spec.enso @@ -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"