diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Dictionary.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Dictionary.enso index f9bccd322f5d..e85535e75e40 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Dictionary.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Dictionary.enso @@ -1,4 +1,5 @@ import project.Any.Any +import project.Data.Numbers.Float import project.Data.Numbers.Integer import project.Data.Pair.Pair import project.Data.Text.Text @@ -11,8 +12,10 @@ import project.Meta import project.Metadata.Widget import project.Nothing.Nothing import project.Panic.Panic +import project.Warning.Warning from project.Data.Boolean import Boolean, False, True from project.Data.Text.Extensions import all +from project.Errors.Common import Floating_Point_Equality from project.Metadata.Choice import Option from project.Metadata.Widget import Single_Choice, Vector_Editor from project.Widget_Helpers import make_all_selector @@ -155,6 +158,10 @@ type Dictionary key value - key: The key to insert the value for. - value: The value to associate with the `key`. + ! Error Conditions + - If a floating-point value is used as a key, a + `Floating_Point_Equality` warning is attached. + > Example Insert the value "seven" into the dictionary for the key 7. @@ -163,9 +170,14 @@ type Dictionary key value example_insert = Examples.dictionary.insert 7 "seven" @key (make_all_selector ..Always) @value (make_all_selector ..Always) - insert : Any -> Any -> Dictionary - insert self key=(Missing_Argument.throw "key") value=(Missing_Argument.throw "value") = - self.insert_builtin key value + insert : Any -> Any -> Boolean -> Dictionary + insert self key=(Missing_Argument.throw "key") value=(Missing_Argument.throw "value") no_warning:Boolean=False = + new_dict = self.insert_builtin key value + case key of + _ : Float -> + if no_warning then new_dict else + Warning.attach (Floating_Point_Equality.Used_As_Dictionary_Key key) new_dict + _ -> new_dict ## GROUP Selections ICON table_clean diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Errors/Common.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Errors/Common.enso index dcd08b6278f6..4ebbe9f9251a 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Errors/Common.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Errors/Common.enso @@ -1,3 +1,4 @@ +import project.Data.Numbers.Float import project.Data.Numbers.Integer import project.Data.Text.Extensions import project.Data.Text.Text @@ -553,7 +554,7 @@ type Out_Of_Range ## PRIVATE to_text : Text to_text self = - extra = if self.message.is_nothing then "" else ": "+self.message.to_text + extra = if self.message.is_nothing then "" else " (message = "+self.message.to_text+")" "(Out_Of_Range (value = "+self.value.to_text+")" + extra + ")" ## Indiciates that the response from a remote endpoint is over the size limit. @@ -577,3 +578,31 @@ type Response_Too_Large Convert the Java exception to an Enso dataflow error. handle_java_exception ~action = Panic.catch ResponseTooLargeException action (cause-> Error.throw (Response_Too_Large.Error cause.payload.getLimit)) + +## Indicates that some operation relies on equality on floating-point values, + which is not recommended. +type Floating_Point_Equality + ## PRIVATE + Represents a general floating-point equality error, such as a direct comparison. + Error (location:Text) + + ## PRIVATE + Represents the use of a floating-point value as a `Dictionary` key. + Used_As_Dictionary_Key value:Float + + ## PRIVATE + Create a human-readable version of the error. + to_display_text : Text + to_display_text self = case self of + Floating_Point_Equality.Error location -> + "Relying on equality of floating-point numbers is not recommended (within "+location+")." + Floating_Point_Equality.Used_As_Dictionary_Key value -> + "Float used as dictionary key: "+value.to_text + + ## PRIVATE + to_text : Text + to_text self = case self of + Floating_Point_Equality.Error location -> + "(Error (location = "+location+"))" + Floating_Point_Equality.Used_As_Dictionary_Key value -> + "(Used_As_Dictionary_Key (value = "+value.to_text+"))" diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Array_Like_Helpers.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Array_Like_Helpers.enso index 416be3d4a512..131d1de9fd9f 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Array_Like_Helpers.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Array_Like_Helpers.enso @@ -142,7 +142,7 @@ distinct vector on = key = on item if (existing.get key False) then existing else builder.append item - existing.insert key True + existing.insert key True no_warning=True duplicates vector on = Vector.build builder-> counts = vector.fold Dictionary.empty current-> item-> diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/DB_Column.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/DB_Column.enso index 250f1a454803..a3afbc1c2494 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/DB_Column.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/DB_Column.enso @@ -1,6 +1,7 @@ from Standard.Base import all import Standard.Base.Data.Read.Many_Files_List.Many_Files_List import Standard.Base.Errors.Common.Index_Out_Of_Bounds +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Illegal_Argument.Illegal_Argument import Standard.Base.Errors.Illegal_State.Illegal_State import Standard.Base.Internal.Rounding_Helpers @@ -15,7 +16,7 @@ import Standard.Table.Internal.Widget_Helpers import Standard.Table.Rows_To_Read.Rows_To_Read from Standard.Table import Auto, Column, Data_Formatter, Previous_Value, Sort_Column, Table, Value_Type from Standard.Table.Column import default_date_period -from Standard.Table.Errors import Conversion_Failure, Floating_Point_Equality, Inexact_Type_Coercion, Invalid_Value_Type +from Standard.Table.Errors import Conversion_Failure, Inexact_Type_Coercion, Invalid_Value_Type from Standard.Table.Internal.Cast_Helpers import check_cast_compatibility import project.Connection.Connection.Connection diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/DB_Table.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/DB_Table.enso index 6108839ad937..c2de5b654654 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/DB_Table.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/DB_Table.enso @@ -5,6 +5,7 @@ import Standard.Base.Data.Read.Many_Files_List.Many_Files_List import Standard.Base.Data.Time.Errors.Date_Time_Format_Parse_Error import Standard.Base.Data.Vector.Builder import Standard.Base.Errors.Common.Additional_Warnings +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.Index_Out_Of_Bounds import Standard.Base.Errors.Common.Type_Error diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Aggregate_Helper.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Aggregate_Helper.enso index bdbdba665322..b13515f13277 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Aggregate_Helper.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Aggregate_Helper.enso @@ -1,14 +1,14 @@ from Standard.Base import all -import Standard.Base.Errors.Common.No_Such_Method import Standard.Base.Errors.Deprecated.Deprecated import Standard.Base.Errors.Illegal_Argument.Illegal_Argument +from Standard.Base.Errors.Common import Floating_Point_Equality, No_Such_Method import Standard.Table.Internal.Aggregate_Column_Helper import Standard.Table.Internal.Aggregate_Column_Helper.Internal_Order_By_Column_Reference import Standard.Table.Internal.Problem_Builder.Problem_Builder from Standard.Table import Aggregate_Column from Standard.Table.Aggregate_Column.Aggregate_Column import all -from Standard.Table.Errors import Floating_Point_Equality, No_Output_Columns +from Standard.Table.Errors import No_Output_Columns import project.DB_Table.DB_Table import project.Dialect.Dialect diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Common/Database_Distinct_Helper.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Common/Database_Distinct_Helper.enso index 4d4e06d1a080..11c924863b6d 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Common/Database_Distinct_Helper.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Common/Database_Distinct_Helper.enso @@ -1,6 +1,5 @@ from Standard.Base import all - -from Standard.Table.Errors import Floating_Point_Equality +import Standard.Base.Errors.Common.Floating_Point_Equality import project.Internal.Helpers import project.Internal.IR.SQL_Expression.SQL_Expression diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Common/Database_Join_Helper.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Common/Database_Join_Helper.enso index 78ca8456285b..db09b65cfd0b 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Common/Database_Join_Helper.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Common/Database_Join_Helper.enso @@ -1,10 +1,10 @@ from Standard.Base import all import Standard.Base.Errors.Illegal_State.Illegal_State +from Standard.Base.Errors.Common import Floating_Point_Equality import Standard.Table.Internal.Join_Helpers import Standard.Table.Internal.Unique_Name_Strategy.Unique_Name_Strategy from Standard.Table import Join_Kind -from Standard.Table.Errors import Floating_Point_Equality import project.Connection.Connection.Connection import project.DB_Table.DB_Table diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Column.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Column.enso index 5d7822bd68cd..663a1236f9ce 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Column.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Column.enso @@ -3,6 +3,7 @@ import Standard.Base.Data.Array_Proxy.Array_Proxy import Standard.Base.Data.Read.Many_Files_List.Many_Files_List import Standard.Base.Data.Vector.No_Wrap import Standard.Base.Errors.Common.Arithmetic_Error +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.Index_Out_Of_Bounds import Standard.Base.Errors.Common.No_Such_Method @@ -31,7 +32,7 @@ import project.Rows_To_Read.Rows_To_Read import project.Table.Table import project.Value_Type.Auto import project.Value_Type.Value_Type -from project.Errors import Conversion_Failure, Floating_Point_Equality, Inexact_Type_Coercion, Invalid_Column_Names, Invalid_Value_Type, No_Index_Set_Error +from project.Errors import Conversion_Failure, Inexact_Type_Coercion, Invalid_Column_Names, Invalid_Value_Type, No_Index_Set_Error from project.Internal.Column_Format import all from project.Internal.Java_Exports import make_date_builder_adapter, make_string_builder from project.Internal.Storage import enso_to_java, java_to_enso diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Errors.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Errors.enso index ff0455ecc60e..d7641bf01c6c 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Errors.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Errors.enso @@ -169,19 +169,6 @@ type Ignored_Nothing_Values to_display_text self = "The column "+self.column+" contained Nothing values in rows " + self.rows.short_display_text + " which were ignored." -## Indicates that some operation relies on equality on floating-point values, - which is not recommended. -type Floating_Point_Equality - ## PRIVATE - Error (location:Text) - - ## PRIVATE - - Create a human-readable version of the error. - to_display_text : Text - to_display_text self = - "Relying on equality of floating-point numbers is not recommended (within "+self.location+")." - ## Indicates that a text value with a delimiter was included in a concatenation without any quote character type Unquoted_Delimiter diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Java_Problems.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Java_Problems.enso index 8c244bf529a2..c2821c8731e8 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Java_Problems.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Java_Problems.enso @@ -2,6 +2,7 @@ from Standard.Base import all import Standard.Base.Data.Vector.No_Wrap import Standard.Base.Errors.Common.Additional_Warnings import Standard.Base.Errors.Common.Arithmetic_Error +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Illegal_Argument.Illegal_Argument import project.Internal.Storage diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Lookup_Helpers.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Lookup_Helpers.enso index 8ec79d4fee96..73e03b10bc85 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Lookup_Helpers.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Lookup_Helpers.enso @@ -1,12 +1,13 @@ from Standard.Base import all import Standard.Base.Data.Vector.Builder import Standard.Base.Data.Vector.No_Wrap +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Illegal_Argument.Illegal_Argument import project.Internal.Storage import project.Internal.Value_Type_Helpers import project.Value_Type.Value_Type -from project.Errors import Floating_Point_Equality, Missing_Input_Columns, No_Common_Type, No_Output_Columns, Unexpected_Extra_Columns +from project.Errors import Missing_Input_Columns, No_Common_Type, No_Output_Columns, Unexpected_Extra_Columns polyglot java import org.enso.table.data.table.join.lookup.LookupColumnDescription diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Multi_Value_Key.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Multi_Value_Key.enso index 967ce851bf36..d4a34f9ba671 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Multi_Value_Key.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Multi_Value_Key.enso @@ -1,10 +1,10 @@ from Standard.Base import all import Standard.Base.Data.Array_Proxy.Array_Proxy +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Illegal_State.Illegal_State import project.Column.Column import project.Value_Type.Value_Type -from project.Errors import Floating_Point_Equality ## PRIVATE An Enso implementation mirroring `UnorderedMultiValueKey` from the Java diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso index 718ebc3eb1da..c694b60427e1 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso @@ -5,6 +5,7 @@ import Standard.Base.Data.Read.Many_Files_List.Many_Files_List import Standard.Base.Data.Time.Errors.Date_Time_Format_Parse_Error import Standard.Base.Data.Vector.No_Wrap import Standard.Base.Errors.Common.Additional_Warnings +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.Index_Out_Of_Bounds import Standard.Base.Errors.Common.No_Such_Method diff --git a/test/Base_Tests/src/Data/Dictionary_Spec.enso b/test/Base_Tests/src/Data/Dictionary_Spec.enso index 1686de4620fd..9ceb807dbe69 100644 --- a/test/Base_Tests/src/Data/Dictionary_Spec.enso +++ b/test/Base_Tests/src/Data/Dictionary_Spec.enso @@ -1,6 +1,7 @@ from Standard.Base import all import Standard.Base.Errors.Illegal_Argument.Illegal_Argument import Standard.Base.Errors.No_Such_Key.No_Such_Key +from Standard.Base.Errors.Common import Floating_Point_Equality from Standard.Test import all @@ -269,6 +270,16 @@ add_specs suite_builder = m.at 200 . should_equal 3 m.at Nothing . should_equal 1 + group_builder.specify "should attach a warning when a Float is used as a key" <| + m = Dictionary.empty . insert 1.2 3 + m.at 1.2 . should_equal 3 + Problems.expect_only_warning Floating_Point_Equality m + + group_builder.specify "should attach a warning when a Float is used as a key (using from_vector)" <| + m = Dictionary.from_vector [[2, 3], [1.2, 3], [4, 5]] + m.at 1.2 . should_equal 3 + Problems.expect_only_warning Floating_Point_Equality m + suite_builder.group "Polyglot keys and values" group_builder-> group_builder.specify "should support polyglot keys" pending=pending_js_missing <| dict = Dictionary.singleton (js_str "A") 42 diff --git a/test/Benchmarks/src/Map/Hash_Map.enso b/test/Benchmarks/src/Map/Hash_Map.enso index 743336cb3fb0..c194f2cda272 100644 --- a/test/Benchmarks/src/Map/Hash_Map.enso +++ b/test/Benchmarks/src/Map/Hash_Map.enso @@ -9,13 +9,16 @@ polyglot java import org.enso.benchmark_helpers.JavaHashMapWrapper options = Bench.options . set_warmup (Bench.phase_conf 2 2) . set_measure (Bench.phase_conf 2 3) type Data - Value ~ints + Value ~dense_ints ~sparse_ints create n = - create_ints = + create_dense_ints = Vector.new n _-> Random.integer 0 ((n.div 100) - 1) - Data.Value create_ints + create_sparse_ints = + Vector.new n _-> + Random.integer 0 (n - 1) + Data.Value create_dense_ints create_sparse_ints type Scenario Instance map_constructor @@ -43,15 +46,23 @@ collect_benches = Bench.build builder-> builder.group ("Enso_Hash_Map_" + n.to_text) options group_builder-> # Scenario similar to what is done in distinct + # 'Sparse' ints have fewer duplicates and cause more inserts and fewer updates to happen. + group_builder.specify "Enso_Sparse_Incremental" <| + Scenario.Instance (_ -> Dictionary.empty) . run_distinct data.sparse_ints + group_builder.specify "Java_Sparse_Incremental" <| + Scenario.Instance (_ -> JavaHashMapWrapper.new) . run_distinct data.sparse_ints + + # Scenario similar to what is done in distinct + # 'Dense' ints have more duplicates and cause fewer inserts and more updates to happen. group_builder.specify "Enso_Incremental" <| - Scenario.Instance (_ -> Dictionary.empty) . run_distinct data.ints + Scenario.Instance (_ -> Dictionary.empty) . run_distinct data.dense_ints group_builder.specify "Java_Incremental" <| - Scenario.Instance (_ -> JavaHashMapWrapper.new) . run_distinct data.ints + Scenario.Instance (_ -> JavaHashMapWrapper.new) . run_distinct data.dense_ints # A scenario similar to what is done in add_row_number with grouping group_builder.specify "Enso_Replacement" <| - Scenario.Instance (_ -> Dictionary.empty) . run_count_keys data.ints + Scenario.Instance (_ -> Dictionary.empty) . run_count_keys data.dense_ints group_builder.specify "Java_Replacement" <| - Scenario.Instance (_ -> JavaHashMapWrapper.new) . run_count_keys data.ints + Scenario.Instance (_ -> JavaHashMapWrapper.new) . run_count_keys data.dense_ints main = collect_benches . run_main diff --git a/test/Benchmarks/src/Vector/Distinct.enso b/test/Benchmarks/src/Vector/Distinct.enso index d6cf1077eda3..725171fcc55b 100644 --- a/test/Benchmarks/src/Vector/Distinct.enso +++ b/test/Benchmarks/src/Vector/Distinct.enso @@ -9,25 +9,31 @@ options = Bench.options . set_warmup (Bench.phase_conf 1 3) . set_measure (Bench type Data - Value ~random_vec ~uniform_vec ~random_text_vec ~uniform_text_vec + Value ~random_integer_vec ~uniform_integer_vec ~random_float_vec ~uniform_float_vec ~random_text_vec ~uniform_text_vec create = - Data.Value create_random_vec create_uniform_vec create_random_text_vec create_uniform_text_vec + Data.Value create_random_integer_vec create_uniform_integer_vec create_random_float_vec create_uniform_float_vec create_random_text_vec create_uniform_text_vec -create_random_vec = Utils.make_random_vec 100000 +create_random_integer_vec = Utils.make_random_integer_vec 100000 -create_uniform_vec = Vector.fill 100000 1 +create_random_float_vec = Utils.make_random_float_vec 100000 + + +create_uniform_integer_vec = Vector.fill 100000 1 + + +create_uniform_float_vec = Vector.fill 100000 1.2 create_random_text_vec = - random_vec = create_random_vec + random_vec = create_random_float_vec random_vec.map .to_text create_uniform_text_vec = - uniform_vec = create_uniform_vec + uniform_vec = create_uniform_integer_vec uniform_vec.map .to_text @@ -36,9 +42,13 @@ collect_benches = Bench.build builder-> builder.group "Vector_Distinct" options group_builder-> group_builder.specify "Random_Integer_Vector_Distinct_v2" <| - data.random_vec.distinct + data.random_integer_vec.distinct group_builder.specify "Uniform_Integer_Vector_Distinct" <| - data.uniform_vec.distinct + data.uniform_integer_vec.distinct + group_builder.specify "Random_Float_Vector_Distinct_v2" <| + data.random_float_vec.distinct + group_builder.specify "Uniform_Float_Vector_Distinct" <| + data.uniform_float_vec.distinct group_builder.specify "Random_Text_Vector_Distinct_v2" <| data.random_text_vec.distinct group_builder.specify "Uniform_Text_Vector_Distinct" <| diff --git a/test/Benchmarks/src/Vector/Operations.enso b/test/Benchmarks/src/Vector/Operations.enso index 9d0a8f214c4e..58f9404add90 100644 --- a/test/Benchmarks/src/Vector/Operations.enso +++ b/test/Benchmarks/src/Vector/Operations.enso @@ -14,8 +14,8 @@ options = Bench.options . set_warmup (Bench.phase_conf 5 5) . set_measure (Bench collect_benches = Bench.build builder-> vector_size = 1000000 - random_vec = Utils.make_random_vec vector_size - random_vec_2 = Utils.make_random_vec 100000 + random_vec = Utils.make_random_float_vec vector_size + random_vec_2 = Utils.make_random_float_vec 100000 random_gen = Java_Random.new 123456 stateful_fun x = s = State.get Number diff --git a/test/Benchmarks/src/Vector/Sort.enso b/test/Benchmarks/src/Vector/Sort.enso index adf4ea088417..e659e35e0d9b 100644 --- a/test/Benchmarks/src/Vector/Sort.enso +++ b/test/Benchmarks/src/Vector/Sort.enso @@ -70,8 +70,8 @@ type Data create vec_size = f1 s = Data.make_sorted_vec s f2 s = make_partially_sorted_vec s - f3 s = Data.make_random_vec s - f4 s = (Data.make_random_vec s).map (v -> Int.Value v) + f3 s = Data.make_random_float_vec s + f4 s = (Data.make_random_float_vec s).map (v -> Int.Value v) f5 s = Utils.make_random_rational_vec s f6 s = f5 s . map (x-> x.to_float . floor + 2) Data.Value (f1 vec_size) (f2 vec_size) (f3 vec_size) (f4 vec_size) (f5 vec_size) (f6 vec_size) @@ -79,8 +79,8 @@ type Data make_sorted_vec vec_size = make_sorted_ascending_vec vec_size - make_random_vec vec_size = - Utils.make_random_vec vec_size + make_random_float_vec vec_size = + Utils.make_random_float_vec vec_size collect_benches = Bench.build builder-> diff --git a/test/Benchmarks/src/Vector/Utils.enso b/test/Benchmarks/src/Vector/Utils.enso index 2bbacfd0a73a..6c77686d6a05 100644 --- a/test/Benchmarks/src/Vector/Utils.enso +++ b/test/Benchmarks/src/Vector/Utils.enso @@ -2,11 +2,16 @@ from Standard.Base import all polyglot java import java.util.Random as Java_Random -make_random_vec : Integer -> Vector -make_random_vec n = +make_random_float_vec : Integer -> Vector +make_random_float_vec n = random_gen = Java_Random.new n Vector.new n (_-> random_gen.nextDouble) +make_random_integer_vec : Integer -> Vector +make_random_integer_vec n = + random_gen = Java_Random.new n + Vector.new n (_-> random_gen.nextInt) + make_random_rational_vec n = random_gen = Java_Random.new n Vector.new n _-> diff --git a/test/Table_Tests/src/Common_Table_Operations/Add_Row_Number_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Add_Row_Number_Spec.enso index 5889ec920c65..6f8122bcaec4 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Add_Row_Number_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Add_Row_Number_Spec.enso @@ -1,4 +1,5 @@ from Standard.Base import all +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Illegal_Argument.Illegal_Argument import Standard.Database.Extensions.Upload_Database_Table @@ -7,7 +8,7 @@ import Standard.Database.Feature.Feature from Standard.Database.Errors import all from Standard.Table import Sort_Column, Aggregate_Column -from Standard.Table.Errors import Missing_Input_Columns, Duplicate_Output_Column_Names, Floating_Point_Equality +from Standard.Table.Errors import Missing_Input_Columns, Duplicate_Output_Column_Names from Standard.Test import all 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 8b57b1571370..fc2eca968c14 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Aggregate_Spec.enso @@ -1,4 +1,5 @@ from Standard.Base import all +import Standard.Base.Errors.Common.Floating_Point_Equality from Standard.Table import Table, Sort_Column, expr from Standard.Table.Aggregate_Column.Aggregate_Column import all diff --git a/test/Table_Tests/src/Common_Table_Operations/Column_Operations_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Column_Operations_Spec.enso index aa66f3074dc5..aa740ccad78e 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Column_Operations_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Column_Operations_Spec.enso @@ -1,6 +1,7 @@ from Standard.Base import all import Standard.Base.Errors.Common.Arithmetic_Error +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.Type_Error import Standard.Base.Errors.Illegal_Argument.Illegal_Argument 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 697c9f9e22ca..c0d17b70a245 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 @@ -1,4 +1,5 @@ from Standard.Base import all +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Illegal_Argument.Illegal_Argument from Standard.Table import Aggregate_Column, expr diff --git a/test/Table_Tests/src/Common_Table_Operations/Distinct_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Distinct_Spec.enso index 71a51391c701..6f27f4f0dac8 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Distinct_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Distinct_Spec.enso @@ -1,4 +1,5 @@ from Standard.Base import all +import Standard.Base.Errors.Common.Floating_Point_Equality from Standard.Table import Sort_Column from Standard.Table.Errors import all diff --git a/test/Table_Tests/src/Common_Table_Operations/Expression_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Expression_Spec.enso index 5b22dace61d8..33ae74d4a4fa 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Expression_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Expression_Spec.enso @@ -1,5 +1,6 @@ from Standard.Base import all import Standard.Base.Errors.Common.Arithmetic_Error +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Illegal_State.Illegal_State import Standard.Base.Errors.Illegal_Argument.Illegal_Argument diff --git a/test/Table_Tests/src/Common_Table_Operations/Filter_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Filter_Spec.enso index 778d4f623054..3181ecccbd97 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Filter_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Filter_Spec.enso @@ -1,5 +1,6 @@ from Standard.Base import all import Standard.Base.Errors.Common.Arithmetic_Error +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Common.Index_Out_Of_Bounds import Standard.Base.Errors.Common.Missing_Argument import Standard.Base.Errors.Common.Type_Error diff --git a/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso index 42a79b4ab06c..8def0e0ea55b 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso @@ -1,4 +1,5 @@ from Standard.Base import all +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Illegal_Argument.Illegal_Argument import Standard.Base.Errors.Illegal_State.Illegal_State diff --git a/test/Table_Tests/src/Common_Table_Operations/Join/Lookup_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Join/Lookup_Spec.enso index 3143a2b355e0..6bc2e152bbcf 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Join/Lookup_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Join/Lookup_Spec.enso @@ -1,4 +1,5 @@ from Standard.Base import all +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Illegal_Argument.Illegal_Argument from Standard.Table import all diff --git a/test/Table_Tests/src/In_Memory/Table_Spec.enso b/test/Table_Tests/src/In_Memory/Table_Spec.enso index fecd48c0ff0c..b6ae2ec7c7d2 100644 --- a/test/Table_Tests/src/In_Memory/Table_Spec.enso +++ b/test/Table_Tests/src/In_Memory/Table_Spec.enso @@ -1,5 +1,6 @@ from Standard.Base import all import Standard.Base.Data.Vector.Map_Error +import Standard.Base.Errors.Common.Floating_Point_Equality import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.Index_Out_Of_Bounds import Standard.Base.Errors.Common.Type_Error @@ -7,7 +8,7 @@ import Standard.Base.Errors.Illegal_Argument.Illegal_Argument import Standard.Base.Runtime.Debug from Standard.Table import Table, Column, Sort_Column, Aggregate_Column, Blank_Selector, Value_Type -from Standard.Table.Errors import Invalid_Column_Names, Duplicate_Output_Column_Names, No_Input_Columns_Selected, Missing_Input_Columns, No_Such_Column, Floating_Point_Equality, Invalid_Value_Type, Row_Count_Mismatch +from Standard.Table.Errors import Invalid_Column_Names, Duplicate_Output_Column_Names, No_Input_Columns_Selected, Missing_Input_Columns, No_Such_Column, Invalid_Value_Type, Row_Count_Mismatch import Standard.Visualization