From cbecd06f759455fda3785053e9adc2dbf1cf1dd2 Mon Sep 17 00:00:00 2001 From: Christopher Short Date: Fri, 28 Aug 2026 13:42:23 +0100 Subject: [PATCH 1/3] Add Round away from zero methods --- .../Query/RoundToCeilingAwayFromZero.cs | 100 ++++++++++++++++++ BHoM_Engine/Query/RoundToFloorAwayFromZero.cs | 100 ++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 BHoM_Engine/Query/RoundToCeilingAwayFromZero.cs create mode 100644 BHoM_Engine/Query/RoundToFloorAwayFromZero.cs diff --git a/BHoM_Engine/Query/RoundToCeilingAwayFromZero.cs b/BHoM_Engine/Query/RoundToCeilingAwayFromZero.cs new file mode 100644 index 000000000..5a77c1e64 --- /dev/null +++ b/BHoM_Engine/Query/RoundToCeilingAwayFromZero.cs @@ -0,0 +1,100 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using BH.oM.Base.Attributes; +using System; +using System.ComponentModel; + +namespace BH.Engine.Base +{ + public static partial class Query + { + /***************************************************/ + /**** Public Methods ****/ + /***************************************************/ + + [Description("Rounds a number using the given tolerance, always rounding the magnitude of the number away " + + "from zero to the next tolerance multiple, regardless of sign. Supports any fractional, integer, " + + "positive or negative numbers." + + "\nSome examples:" + + "\n\t RoundToCeiling(12, 20) ==> 20" + + "\n\t RoundToCeiling(121, 2) ==> 122" + + "\n\t RoundToCeiling(1.2345, 1.1) ==> 2.2" + + "\n\t RoundToCeiling(0.014, 0.01) ==> 0.02" + + "\n\t RoundToCeiling(-0.014, 0.01) ==> -0.02" + + "\n\t RoundToCeiling(0.015, 0.01) ==> 0.02" + + "\n\t RoundToCeiling(0.014, 0.02) ==> 0.02" + + "\nand so on.")] + [Input("number", "Number to be rounded.")] + [Input("tolerance", "Tolerance to use for rounding.")] + public static double RoundToCeilingAwayFromZero(this double number, double tolerance) + { + if (tolerance < 0) + { + BH.Engine.Base.Compute.RecordError("Tolerance cannot be less than 0."); + return default(double); + } + + // If the tolerance is the smallest possible double, or if the inputs are invalid, just return. + if (number == 0 || tolerance == 0 || Double.IsNaN(tolerance) || Double.IsNaN(number) || Double.IsInfinity(number) || Double.IsInfinity(tolerance)) + return number; + + double sign = number < 0 ? -1.0 : 1.0; + return sign * tolerance * Math.Ceiling(Math.Abs(number) / tolerance); + } + + /***************************************************/ + + [Description("Rounds an integer number using the given tolerance, rounding to ceiling to the nearest tolerance multiplier." + + "\nSome examples:" + + "\n\t RoundToCeiling(12, 20) ==> 20" + + "\n\t RoundToCeiling(121, 2) ==> 122" + + "\n\t RoundToCeiling(-35, 20) ==> -20" + + "\nand so on.")] + [Input("number", "Number to be rounded.")] + [Input("tolerance", "Tolerance to use for rounding.")] + public static int RoundToCeilingAwayFromZero(this int number, double tolerance) + { + if (tolerance < 0) + { + BH.Engine.Base.Compute.RecordError("Tolerance cannot be less than 0."); + return 0; + } + + // If the tolerance is the smallest possible double, or if the inputs are invalid, just return. + if (number == 0 || tolerance == double.MinValue || tolerance == 0 || Double.IsNaN(tolerance) || number == int.MinValue || number == int.MaxValue || Double.IsInfinity(tolerance)) + return number; + + if ((int)tolerance != tolerance) + { + BH.Engine.Base.Compute.RecordError("Tolerance needs to be an integer value."); + return 0; + } + + return (int)(Math.Ceiling(number / tolerance) * tolerance); + } + + /***************************************************/ + } +} + + diff --git a/BHoM_Engine/Query/RoundToFloorAwayFromZero.cs b/BHoM_Engine/Query/RoundToFloorAwayFromZero.cs new file mode 100644 index 000000000..bf8ca820e --- /dev/null +++ b/BHoM_Engine/Query/RoundToFloorAwayFromZero.cs @@ -0,0 +1,100 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2026, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using BH.oM.Base.Attributes; +using System; +using System.ComponentModel; + +namespace BH.Engine.Base +{ + public static partial class Query + { + /***************************************************/ + /**** Public Methods ****/ + /***************************************************/ + + [Description("Rounds a number using the given tolerance, always rounding the magnitude of the number toward " + + "zero to the previous tolerance multiple, regardless of sign. Supports any fractional, integer, " + + "positive or negative numbers." + + "\nSome examples:" + + "\n\t RoundToFloor(12, 20) ==> 0" + + "\n\t RoundToFloor(121, 2) ==> 120" + + "\n\t RoundToFloor(1.2345, 1.1) ==> 1.1" + + "\n\t RoundToFloor(0.014, 0.01) ==> 0.01" + + "\n\t RoundToFloor(-0.014, 0.01) ==> -0.01" + + "\n\t RoundToFloor(0.015, 0.01) ==> 0.01" + + "\n\t RoundToFloor(0.014, 0.02) ==> 0" + + "\nand so on.")] + [Input("number", "Number to be rounded.")] + [Input("tolerance", "Tolerance to use for rounding.")] + public static double RoundToFloorAwayFromZero(this double number, double tolerance) + { + if (tolerance < 0) + { + BH.Engine.Base.Compute.RecordError("Tolerance cannot be less than 0."); + return default(double); + } + + // If the tolerance is the smallest possible double, or if the inputs are invalid, just return. + if (number == 0 || tolerance == 0 || Double.IsNaN(tolerance) || Double.IsNaN(number) || Double.IsInfinity(number) || Double.IsInfinity(tolerance)) + return number; + + double sign = number < 0 ? -1.0 : 1.0; + return sign * tolerance * Math.Floor(Math.Abs(number) / tolerance); + } + + /***************************************************/ + + [Description("Rounds an integer number using the given tolerance, rounding to floor to the nearest tolerance multiplier." + + "\nSome examples:" + + "\n\t RoundToFloor(12, 20) ==> 0" + + "\n\t RoundToFloor(121, 2) ==> 120" + + "\n\t RoundToFloor(-35, 20) ==> -40" + + "\nand so on.")] + [Input("number", "Number to be rounded.")] + [Input("tolerance", "Tolerance to use for rounding.")] + public static int RoundToFloorAwayFromZero(this int number, double tolerance) + { + if (tolerance < 0) + { + BH.Engine.Base.Compute.RecordError("Tolerance cannot be less than 0."); + return 0; + } + + // If the tolerance is the smallest possible double, or if the inputs are invalid, just return. + if (number == 0 || tolerance == double.MinValue || tolerance == 0 || Double.IsNaN(tolerance) || number == int.MinValue || number == int.MaxValue || Double.IsInfinity(tolerance)) + return number; + + if ((int)tolerance != tolerance) + { + BH.Engine.Base.Compute.RecordError("Tolerance needs to be an integer value."); + return 0; + } + + return (int)(Math.Floor(number / tolerance) * tolerance); + } + + /***************************************************/ + } +} + + From 9cd4c89c0745bf1220612b3d949d973a6539512c Mon Sep 17 00:00:00 2001 From: Christopher Short Date: Fri, 28 Aug 2026 16:13:59 +0100 Subject: [PATCH 2/3] add unit tests --- .../Query/RoundToCeilingAwayFromZero.json | 1 + .../Query/RoundToFloorAwayFromZero.json | 1 + .../Query/RoundingTestsSummary.json | 99 +++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 .ci/Datasets/BHoM_Engine/Query/RoundToCeilingAwayFromZero.json create mode 100644 .ci/Datasets/BHoM_Engine/Query/RoundToFloorAwayFromZero.json create mode 100644 .ci/Datasets/BHoM_Engine/Query/RoundingTestsSummary.json diff --git a/.ci/Datasets/BHoM_Engine/Query/RoundToCeilingAwayFromZero.json b/.ci/Datasets/BHoM_Engine/Query/RoundToCeilingAwayFromZero.json new file mode 100644 index 000000000..f6f4075a5 --- /dev/null +++ b/.ci/Datasets/BHoM_Engine/Query/RoundToCeilingAwayFromZero.json @@ -0,0 +1 @@ +{ "_t" : "BH.oM.Data.Library.Dataset", "SourceInformation" : { "_t" : "BH.oM.Data.Library.Source", "SourceLink" : "", "Title" : "RoundToCeilingAwayFromZero", "Author" : "Christopher Short", "ItemReference" : "", "Version" : "", "Publisher" : "", "Schema" : "", "Language" : "", "Location" : "", "Copyright" : "", "Contributors" : "", "Confidence" : "Undefined", "BHoM_Guid" : "a5c7d2f1-8b3e-4d6c-9a2f-1e5b7d9c4a8f", "Name" : "" }, "TimeOfCreation" : { "$date" : 1730726648330 }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"8.0\" }", "MethodName" : "RoundToCeilingAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }"], "_bhomVersion" : "8.0" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12.0, 20.0], "Outputs" : [20.0], "BHoM_Guid" : "aa62d485-0030-4fc7-b7ef-ce6821a0a58a", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121.0, 2.0], "Outputs" : [122.0], "BHoM_Guid" : "37a3b245-6489-4012-8f62-cbd03845c38d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.2344999999999999, 1.1000000000000001], "Outputs" : [2.2000000000000002], "BHoM_Guid" : "17b49100-a3df-46d6-a1b5-90a62d230790", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.01], "Outputs" : [0.02], "BHoM_Guid" : "3525f048-780e-44f8-8a9f-db1c15be80e1", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.014, 0.01], "Outputs" : [-0.02], "BHoM_Guid" : "c9093cc1-dc43-4b4f-9ff0-6f39e47e6ab7", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014999999999999999, 0.01], "Outputs" : [0.02], "BHoM_Guid" : "23ab0987-ead7-45d3-b853-83b9f54c98fe", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.02], "Outputs" : [0.02], "BHoM_Guid" : "d47a2f0d-2631-46a6-a44c-29d044066f9d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.0], "Outputs" : [2.0], "BHoM_Guid" : "d8920b41-ce79-42d2-bc2e-cdea1a99d65e", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.33333333333333331], "Outputs" : [2.0], "BHoM_Guid" : "10343647-d2dc-4653-9a51-4dabb02babcc", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.66666666666666663], "Outputs" : [2.0], "BHoM_Guid" : "82c09cb4-8295-4d70-9233-17fb87420d1b", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.0], "Outputs" : [2.0], "BHoM_Guid" : "1d59d300-ad86-4c39-8f2a-4e521034c8bb", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.3333333333333333], "Outputs" : [2.6666666666666665], "BHoM_Guid" : "031ceb79-bb8d-435b-9343-85438282c163", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.6666666666666665], "Outputs" : [3.333333333333333], "BHoM_Guid" : "018e2707-319b-4437-8cff-5f5febc95b87", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3.5, 2.0], "Outputs" : [-4.0], "BHoM_Guid" : "2928c19e-0e9b-43d6-8c36-bed0b3aaa7d8", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3.0, 2.0], "Outputs" : [-4.0], "BHoM_Guid" : "20170544-154b-4236-8188-d112ecd36310", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2.5, 2.0], "Outputs" : [-4.0], "BHoM_Guid" : "1e4e7986-19f5-455d-bbae-e81c8c0b52e3", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2.0, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "73b1111a-bcf9-4226-889c-05b441f70259", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1.5, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "3fdb0e1a-fc37-4854-9da5-0b4040afe06f", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1.0, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "8d44c69f-8940-4b65-ba1b-eec99d3a7f01", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.5, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "37ef8f71-dfcc-476c-b4f9-33238cdffe93", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.0, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "54814c67-27e3-4a3a-a0fc-51f8b3bdcc0c", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.5, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "6393d53e-2053-4d90-80e8-bfcb7d789414", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.0, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "aed73a26-5c41-40a1-83e1-dfdd4fdf9a88", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.5, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "70654231-b691-4960-b762-4bcc6b5d9087", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "5e18b777-334a-4981-b9fe-a9af93c9db07", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.5, 2.0], "Outputs" : [4.0], "BHoM_Guid" : "264cc880-333d-4035-b38a-1de6013c77f6", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3.0, 2.0], "Outputs" : [4.0], "BHoM_Guid" : "96e8db14-de76-4b7e-b0a2-1c70de2f2142", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3.5, 2.0], "Outputs" : [4.0], "BHoM_Guid" : "a1d2a7ee-f055-488e-83d0-def317cd319e", "Name" : "" }], "BHoM_Guid" : "1a13e07c-5d41-49ac-ade4-be849399f867", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"8.0\" }", "MethodName" : "RoundToCeilingAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }"], "_bhomVersion" : "8.0" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12, 20.0], "Outputs" : [20], "BHoM_Guid" : "18826de7-1d25-4001-a8fc-d82f5b03917d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121, 2.0], "Outputs" : [122], "BHoM_Guid" : "3d70ef93-61b9-4082-a140-fd8f2bea30a8", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-35, 20.0], "Outputs" : [-40], "BHoM_Guid" : "c79c2657-b038-404b-8201-ffa183e09acd", "Name" : "" }], "BHoM_Guid" : "05d926ca-1843-4039-8424-58d389ac3700", "Name" : "" }], "BHoM_Guid" : "a5c7d2f1-8b3e-4d6c-9a2f-1e5b7d9c4a8e", "Name" : "RoundToCeilingAwayFromZero", "_bhomVersion" : "8.0" } diff --git a/.ci/Datasets/BHoM_Engine/Query/RoundToFloorAwayFromZero.json b/.ci/Datasets/BHoM_Engine/Query/RoundToFloorAwayFromZero.json new file mode 100644 index 000000000..8cf248c4a --- /dev/null +++ b/.ci/Datasets/BHoM_Engine/Query/RoundToFloorAwayFromZero.json @@ -0,0 +1 @@ +{ "_t" : "BH.oM.Data.Library.Dataset", "SourceInformation" : { "_t" : "BH.oM.Data.Library.Source", "SourceLink" : "", "Title" : "RoundToFloorAwayFromZero", "Author" : "Christopher Short", "ItemReference" : "", "Version" : "", "Publisher" : "", "Schema" : "", "Language" : "", "Location" : "", "Copyright" : "", "Contributors" : "", "Confidence" : "Undefined", "BHoM_Guid" : "b6d8e3f2-9c4f-5e7d-0b3f-2f6c8d0e5b9f", "Name" : "" }, "TimeOfCreation" : { "$date" : 1730726648330 }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"8.0\" }", "MethodName" : "RoundToFloorAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }"], "_bhomVersion" : "8.0" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12.0, 20.0], "Outputs" : [0.0], "BHoM_Guid" : "4313c050-b410-4bde-bc53-c9e71c2cb784", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121.0, 2.0], "Outputs" : [120.0], "BHoM_Guid" : "2f973b07-5996-48eb-83be-0717be358920", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.2344999999999999, 1.1000000000000001], "Outputs" : [1.1000000000000001], "BHoM_Guid" : "12c54dce-6265-45f8-aac9-417453e90e0d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.01], "Outputs" : [0.01], "BHoM_Guid" : "65000816-1226-4de2-8d6d-201019b20c3e", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.014, 0.01], "Outputs" : [-0.01], "BHoM_Guid" : "cca32a03-185f-4c97-bd09-8569a9545d21", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014999999999999999, 0.01], "Outputs" : [0.01], "BHoM_Guid" : "dce86e3f-a150-4afe-a908-613a3cecea50", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.02], "Outputs" : [0.0], "BHoM_Guid" : "cda056e5-557c-4122-afe2-183ba2ed3fc8", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.0], "Outputs" : [2.0], "BHoM_Guid" : "42bddc17-735d-436e-986d-6affdba4182f", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.33333333333333331], "Outputs" : [2.0], "BHoM_Guid" : "ed690c2e-b28f-47d9-b5f0-7868e32a7653", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.66666666666666663], "Outputs" : [2.0], "BHoM_Guid" : "048638f6-2b17-48f7-829f-fbaf08f333b4", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.0], "Outputs" : [2.0], "BHoM_Guid" : "98f69a5c-6156-47b3-b18f-b0f462f27652", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.3333333333333333], "Outputs" : [1.3333333333333333], "BHoM_Guid" : "ef3607ed-5f04-4030-8bc8-f3e5d810e8c7", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.6666666666666665], "Outputs" : [1.6666666666666665], "BHoM_Guid" : "e2fd38d6-0b26-4b18-8cd9-eaa9869c2df4", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3.5, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "a553019a-a0c9-4484-af54-615e07802fce", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3.0, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "2595b162-2313-43a2-8ab5-b35c470eb536", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2.5, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "df79ec31-481f-4ca5-97b8-1b659c063afc", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2.0, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "f496c1d7-5c1d-433f-b2b6-06e59d4e3e06", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1.5, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "cc6a0f8d-8097-4839-bf2c-f43ba1e3bc54", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1.0, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "41be4649-fe6c-4071-8996-34249ae9147e", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.5, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "c6ce4c8b-ae6d-4de7-a193-b8bcbf49eaab", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.0, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "12c21fcb-7451-4f8e-b895-cd0b3372807f", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.5, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "23a23eb9-f094-4391-a98e-596046adf977", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.0, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "54f537c8-0e35-42f0-9a03-bc4336ef6067", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.5, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "0ae39610-c8b2-4a17-a452-33ac06ac6ed6", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "06bb3c03-f965-4f31-8875-04c451ccbe5f", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.5, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "eac7ce61-848a-4c15-a294-42b3ce192ae3", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3.0, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "9bd290c0-dc81-4fcf-a788-640eb845c019", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3.5, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "149b368b-6a80-4a00-90f6-369286fbbbef", "Name" : "" }], "BHoM_Guid" : "f4776d46-c1c4-411b-88eb-978246c7de30", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"8.0\" }", "MethodName" : "RoundToFloorAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }"], "_bhomVersion" : "8.0" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12, 20.0], "Outputs" : [0], "BHoM_Guid" : "8bd24ec8-f7cc-4156-bb8e-cd3b9dde96e0", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121, 2.0], "Outputs" : [120], "BHoM_Guid" : "c32f7c9d-d6cd-4e4b-9082-c99b43f38465", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-35, 20.0], "Outputs" : [0], "BHoM_Guid" : "c216bce1-f8cf-446a-9fa3-c9f69fd98c50", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-5, 3.0], "Outputs" : [-3], "BHoM_Guid" : "7a757517-1a9f-4d92-9a9c-a739868eb2c6", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-4, 3.0], "Outputs" : [-3], "BHoM_Guid" : "689af816-eda9-4031-be6e-26b8da690e93", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3, 3.0], "Outputs" : [-3], "BHoM_Guid" : "2c4a5073-6b96-4e90-b1fc-55feb72a9fb2", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2, 3.0], "Outputs" : [0], "BHoM_Guid" : "431753e2-fe42-459e-abf5-40473eeb9479", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1, 3.0], "Outputs" : [0], "BHoM_Guid" : "9230a5aa-400e-4602-80cd-8e5a61758630", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0, 3.0], "Outputs" : [0], "BHoM_Guid" : "3296f81f-91b6-47c8-881d-151dc9ba4f37", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1, 3.0], "Outputs" : [0], "BHoM_Guid" : "f5bceca9-dfec-4ecb-88a9-e1ce525c3fbf", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2, 3.0], "Outputs" : [0], "BHoM_Guid" : "ab969185-d7a8-467d-8076-feda02a37b35", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3, 3.0], "Outputs" : [3], "BHoM_Guid" : "bfe12d20-f927-491b-9bcd-c3ea21e59279", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [4, 3.0], "Outputs" : [3], "BHoM_Guid" : "db67d6e1-f35c-4915-9d87-e4dd867a40e2", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [5, 3.0], "Outputs" : [3], "BHoM_Guid" : "cc8ad87e-4680-41e7-a1f6-633d470a6cf0", "Name" : "" }], "BHoM_Guid" : "b671a445-2603-4dc6-b570-6cc8ae779947", "Name" : "" }], "BHoM_Guid" : "b6d8e3f2-9c4f-5e7d-0b3f-2f6c8d0e5b9e", "Name" : "RoundToFloorAwayFromZero", "_bhomVersion" : "8.0" } diff --git a/.ci/Datasets/BHoM_Engine/Query/RoundingTestsSummary.json b/.ci/Datasets/BHoM_Engine/Query/RoundingTestsSummary.json new file mode 100644 index 000000000..3d76eb272 --- /dev/null +++ b/.ci/Datasets/BHoM_Engine/Query/RoundingTestsSummary.json @@ -0,0 +1,99 @@ +{ + "summary": "Test cases for RoundToCeilingAwayFromZero and RoundToFloorAwayFromZero methods", + "dateCreated": "2026-08-28", + "author": "Christopher Short", + "testSuites": [ + { + "methodName": "RoundToCeilingAwayFromZero", + "description": "Rounds the magnitude of the number away from zero to the nearest tolerance multiple, regardless of sign", + "doubleOverload": { + "description": "RoundToCeilingAwayFromZero(double number, double tolerance)", + "keyCharacteristics": [ + "Positive numbers: rounds up to nearest tolerance", + "Negative numbers: rounds down (away from zero) to nearest tolerance", + "Key difference from RoundToCeiling: negative handling", + "Zero tolerance or zero input: returns input unchanged" + ], + "testCases": [ + { "input": [12.0, 20.0], "expected": 20.0, "description": "Positive with large tolerance" }, + { "input": [121.0, 2.0], "expected": 122.0, "description": "Positive with small tolerance" }, + { "input": [1.2345, 1.1], "expected": 2.2, "description": "Positive fractional" }, + { "input": [0.014, 0.01], "expected": 0.02, "description": "Positive small value" }, + { "input": [-0.014, 0.01], "expected": -0.02, "description": "Negative small value (KEY: away from zero)" }, + { "input": [0.015, 0.01], "expected": 0.02, "description": "Rounding edge case" }, + { "input": [0.014, 0.02], "expected": 0.02, "description": "Tolerance larger than value" }, + { "input": [-3.5, 2.0], "expected": -4.0, "description": "Negative away from zero" }, + { "input": [-0.5, 2.0], "expected": -2.0, "description": "Negative small value away from zero" }, + { "input": [0.5, 2.0], "expected": 2.0, "description": "Positive small value" } + ] + }, + "intOverload": { + "description": "RoundToCeilingAwayFromZero(int number, double tolerance)", + "testCases": [ + { "input": [12, 20.0], "expected": 20, "description": "Positive with large tolerance" }, + { "input": [121, 2.0], "expected": 122, "description": "Positive with small tolerance" }, + { "input": [-35, 20.0], "expected": -40, "description": "Negative away from zero" } + ] + } + }, + { + "methodName": "RoundToFloorAwayFromZero", + "description": "Rounds the magnitude of the number toward zero to the previous tolerance multiple, regardless of sign", + "doubleOverload": { + "description": "RoundToFloorAwayFromZero(double number, double tolerance)", + "keyCharacteristics": [ + "Positive numbers: rounds down to nearest tolerance (like Floor)", + "Negative numbers: rounds up (toward zero) to nearest tolerance", + "Opposite behavior to RoundToCeilingAwayFromZero", + "Zero tolerance or zero input: returns input unchanged" + ], + "testCases": [ + { "input": [12.0, 20.0], "expected": 0.0, "description": "Positive with large tolerance" }, + { "input": [121.0, 2.0], "expected": 120.0, "description": "Positive with small tolerance" }, + { "input": [1.2345, 1.1], "expected": 1.1, "description": "Positive fractional" }, + { "input": [0.014, 0.01], "expected": 0.01, "description": "Positive small value" }, + { "input": [-0.014, 0.01], "expected": -0.01, "description": "Negative small value (KEY: toward zero)" }, + { "input": [0.015, 0.01], "expected": 0.01, "description": "Rounding edge case" }, + { "input": [0.014, 0.02], "expected": 0.0, "description": "Tolerance larger than value" }, + { "input": [-3.5, 2.0], "expected": -2.0, "description": "Negative toward zero" }, + { "input": [-0.5, 2.0], "expected": 0.0, "description": "Negative small value toward zero" }, + { "input": [0.5, 2.0], "expected": 0.0, "description": "Positive small value" } + ] + }, + "intOverload": { + "description": "RoundToFloorAwayFromZero(int number, double tolerance)", + "testCases": [ + { "input": [12, 20.0], "expected": 0, "description": "Positive with large tolerance" }, + { "input": [121, 2.0], "expected": 120, "description": "Positive with small tolerance" }, + { "input": [-35, 20.0], "expected": 0, "description": "Negative toward zero" }, + { "input": [-5, 3.0], "expected": -3, "description": "Negative toward zero with smaller tolerance" } + ] + } + } + ], + "keyDifferences": { + "RoundToCeilingAwayFromZero_vs_RoundToCeiling": [ + "RoundToCeiling(-0.014, 0.01) → -0.01 (toward positive/ceiling)", + "RoundToCeilingAwayFromZero(-0.014, 0.01) → -0.02 (away from zero)", + "RoundToCeiling(-3.5, 2.0) → -2.0 (toward positive)", + "RoundToCeilingAwayFromZero(-3.5, 2.0) → -4.0 (away from zero)" + ], + "RoundToFloorAwayFromZero_vs_RoundToFloor": [ + "RoundToFloor(-0.014, 0.01) → -0.02 (away from zero)", + "RoundToFloorAwayFromZero(-0.014, 0.01) → -0.01 (toward zero)", + "RoundToFloor(-3.5, 2.0) → -4.0 (away from zero)", + "RoundToFloorAwayFromZero(-3.5, 2.0) → -2.0 (toward zero)" + ] + }, + "comprehensiveTestCoverage": { + "included": [ + "All examples from method XML documentation", + "Both double and int overloads", + "Positive and negative values", + "Fractional tolerances (0.33, 0.67, 1.33, 1.67)", + "Whole number tolerances (1.0, 2.0, 3.0, 20.0)", + "Edge cases (zero input, zero tolerance, values smaller than tolerance)", + "Range of values (-35 to 121) to verify behavior consistency" + ] + } +} From e52406207dfe2a1967275c23eb57527046641725 Mon Sep 17 00:00:00 2001 From: Christopher Short Date: Tue, 1 Sep 2026 16:09:09 +0100 Subject: [PATCH 3/3] Update unittests --- .../Query/RoundToCeilingAwayFromZero.json | 2 +- .../Query/RoundToFloorAwayFromZero.json | 1 - .../Query/RoundToFloorTowardZero.json | 1 + .../Query/RoundingTestsSummary.json | 99 ------------------- .../Query/RoundToCeilingAwayFromZero.cs | 29 +++--- ...yFromZero.cs => RoundToFloorTowardZero.cs} | 61 ++++++------ 6 files changed, 49 insertions(+), 144 deletions(-) delete mode 100644 .ci/Datasets/BHoM_Engine/Query/RoundToFloorAwayFromZero.json create mode 100644 .ci/Datasets/BHoM_Engine/Query/RoundToFloorTowardZero.json delete mode 100644 .ci/Datasets/BHoM_Engine/Query/RoundingTestsSummary.json rename BHoM_Engine/Query/{RoundToFloorAwayFromZero.cs => RoundToFloorTowardZero.cs} (67%) diff --git a/.ci/Datasets/BHoM_Engine/Query/RoundToCeilingAwayFromZero.json b/.ci/Datasets/BHoM_Engine/Query/RoundToCeilingAwayFromZero.json index f6f4075a5..19b803006 100644 --- a/.ci/Datasets/BHoM_Engine/Query/RoundToCeilingAwayFromZero.json +++ b/.ci/Datasets/BHoM_Engine/Query/RoundToCeilingAwayFromZero.json @@ -1 +1 @@ -{ "_t" : "BH.oM.Data.Library.Dataset", "SourceInformation" : { "_t" : "BH.oM.Data.Library.Source", "SourceLink" : "", "Title" : "RoundToCeilingAwayFromZero", "Author" : "Christopher Short", "ItemReference" : "", "Version" : "", "Publisher" : "", "Schema" : "", "Language" : "", "Location" : "", "Copyright" : "", "Contributors" : "", "Confidence" : "Undefined", "BHoM_Guid" : "a5c7d2f1-8b3e-4d6c-9a2f-1e5b7d9c4a8f", "Name" : "" }, "TimeOfCreation" : { "$date" : 1730726648330 }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"8.0\" }", "MethodName" : "RoundToCeilingAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }"], "_bhomVersion" : "8.0" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12.0, 20.0], "Outputs" : [20.0], "BHoM_Guid" : "aa62d485-0030-4fc7-b7ef-ce6821a0a58a", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121.0, 2.0], "Outputs" : [122.0], "BHoM_Guid" : "37a3b245-6489-4012-8f62-cbd03845c38d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.2344999999999999, 1.1000000000000001], "Outputs" : [2.2000000000000002], "BHoM_Guid" : "17b49100-a3df-46d6-a1b5-90a62d230790", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.01], "Outputs" : [0.02], "BHoM_Guid" : "3525f048-780e-44f8-8a9f-db1c15be80e1", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.014, 0.01], "Outputs" : [-0.02], "BHoM_Guid" : "c9093cc1-dc43-4b4f-9ff0-6f39e47e6ab7", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014999999999999999, 0.01], "Outputs" : [0.02], "BHoM_Guid" : "23ab0987-ead7-45d3-b853-83b9f54c98fe", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.02], "Outputs" : [0.02], "BHoM_Guid" : "d47a2f0d-2631-46a6-a44c-29d044066f9d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.0], "Outputs" : [2.0], "BHoM_Guid" : "d8920b41-ce79-42d2-bc2e-cdea1a99d65e", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.33333333333333331], "Outputs" : [2.0], "BHoM_Guid" : "10343647-d2dc-4653-9a51-4dabb02babcc", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.66666666666666663], "Outputs" : [2.0], "BHoM_Guid" : "82c09cb4-8295-4d70-9233-17fb87420d1b", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.0], "Outputs" : [2.0], "BHoM_Guid" : "1d59d300-ad86-4c39-8f2a-4e521034c8bb", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.3333333333333333], "Outputs" : [2.6666666666666665], "BHoM_Guid" : "031ceb79-bb8d-435b-9343-85438282c163", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.6666666666666665], "Outputs" : [3.333333333333333], "BHoM_Guid" : "018e2707-319b-4437-8cff-5f5febc95b87", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3.5, 2.0], "Outputs" : [-4.0], "BHoM_Guid" : "2928c19e-0e9b-43d6-8c36-bed0b3aaa7d8", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3.0, 2.0], "Outputs" : [-4.0], "BHoM_Guid" : "20170544-154b-4236-8188-d112ecd36310", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2.5, 2.0], "Outputs" : [-4.0], "BHoM_Guid" : "1e4e7986-19f5-455d-bbae-e81c8c0b52e3", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2.0, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "73b1111a-bcf9-4226-889c-05b441f70259", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1.5, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "3fdb0e1a-fc37-4854-9da5-0b4040afe06f", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1.0, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "8d44c69f-8940-4b65-ba1b-eec99d3a7f01", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.5, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "37ef8f71-dfcc-476c-b4f9-33238cdffe93", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.0, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "54814c67-27e3-4a3a-a0fc-51f8b3bdcc0c", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.5, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "6393d53e-2053-4d90-80e8-bfcb7d789414", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.0, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "aed73a26-5c41-40a1-83e1-dfdd4fdf9a88", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.5, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "70654231-b691-4960-b762-4bcc6b5d9087", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "5e18b777-334a-4981-b9fe-a9af93c9db07", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.5, 2.0], "Outputs" : [4.0], "BHoM_Guid" : "264cc880-333d-4035-b38a-1de6013c77f6", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3.0, 2.0], "Outputs" : [4.0], "BHoM_Guid" : "96e8db14-de76-4b7e-b0a2-1c70de2f2142", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3.5, 2.0], "Outputs" : [4.0], "BHoM_Guid" : "a1d2a7ee-f055-488e-83d0-def317cd319e", "Name" : "" }], "BHoM_Guid" : "1a13e07c-5d41-49ac-ade4-be849399f867", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"8.0\" }", "MethodName" : "RoundToCeilingAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }"], "_bhomVersion" : "8.0" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12, 20.0], "Outputs" : [20], "BHoM_Guid" : "18826de7-1d25-4001-a8fc-d82f5b03917d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121, 2.0], "Outputs" : [122], "BHoM_Guid" : "3d70ef93-61b9-4082-a140-fd8f2bea30a8", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-35, 20.0], "Outputs" : [-40], "BHoM_Guid" : "c79c2657-b038-404b-8201-ffa183e09acd", "Name" : "" }], "BHoM_Guid" : "05d926ca-1843-4039-8424-58d389ac3700", "Name" : "" }], "BHoM_Guid" : "a5c7d2f1-8b3e-4d6c-9a2f-1e5b7d9c4a8e", "Name" : "RoundToCeilingAwayFromZero", "_bhomVersion" : "8.0" } +{ "_t" : "BH.oM.Data.Library.Dataset", "SourceInformation" : { "_t" : "BH.oM.Data.Library.Source", "SourceLink" : "", "Title" : "RoundToCeilingAwayFromZero", "Author" : "Christopher Short", "ItemReference" : "", "Version" : "", "Publisher" : "", "Schema" : "", "Language" : "", "Location" : "", "Copyright" : "", "Contributors" : "", "Confidence" : "High", "BHoM_Guid" : "ff23d365-89f2-4a63-b068-6b04d524ef2d", "Name" : "" }, "TimeOfCreation" : { "$date" : 1788275279991 }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"9.3\" }", "MethodName" : "RoundToCeilingAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"9.3\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"9.3\" }"], "_bhomVersion" : "9.3" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12.0, 20.0], "Outputs" : [20.0], "BHoM_Guid" : "e2eb89b3-838e-4a30-a81b-6276ae1f075d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121.0, 2.0], "Outputs" : [122.0], "BHoM_Guid" : "0cb975c7-7f03-4740-b7fe-b8a6ead2f793", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.2344999999999999, 1.1000000000000001], "Outputs" : [2.2000000000000002], "BHoM_Guid" : "03cf27f5-bdfb-4776-8ea3-a2a5bef886f9", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.01], "Outputs" : [0.02], "BHoM_Guid" : "38293d95-2cf0-4df6-9632-ba9691ff08a7", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.014, 0.01], "Outputs" : [-0.02], "BHoM_Guid" : "56e8b7d8-ad07-4f66-80c0-431790fac8f0", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014999999999999999, 0.01], "Outputs" : [0.02], "BHoM_Guid" : "361bb62f-0a4c-42cb-9321-c33cefb3de67", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.02], "Outputs" : [0.02], "BHoM_Guid" : "913fb4f0-4c54-4f2d-ab2a-9d1307a16244", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-35.0, 20.0], "Outputs" : [-40.0], "BHoM_Guid" : "6868503b-10ef-4656-a1d7-aed2c9100d69", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [456.0, 50.0], "Outputs" : [500.0], "BHoM_Guid" : "8d36e799-1c0b-4f81-996c-39d592bea3ef", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.5, 0.10000000000000001], "Outputs" : [-0.5], "BHoM_Guid" : "8cb81b2c-3325-48c6-b7e4-9ce93c9000a3", "Name" : "" }], "BHoM_Guid" : "879ac8c3-1a75-4bbf-93a9-50fb0c740fab", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"9.3\" }", "MethodName" : "RoundToCeilingAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"9.3\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"9.3\" }"], "_bhomVersion" : "9.3" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12, 20.0], "Outputs" : [20], "BHoM_Guid" : "6876116e-d08b-422d-9120-25b2dcb24266", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121, 2.0], "Outputs" : [122], "BHoM_Guid" : "44c0a66b-ec8d-462e-821f-d4a4edfb53fc", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [35, 20.0], "Outputs" : [40], "BHoM_Guid" : "95f4621c-30da-4e6f-adc4-9303310619e5", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [14, 10.0], "Outputs" : [20], "BHoM_Guid" : "b417eacf-6134-4374-a19c-04d9cacdfc2a", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-14, 10.0], "Outputs" : [-20], "BHoM_Guid" : "93d51ef0-7248-4570-89b0-c1e93b4fd4b6", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [15, 10.0], "Outputs" : [20], "BHoM_Guid" : "60264f24-cbb8-4702-a8c7-36515c8803bd", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [14, 20.0], "Outputs" : [20], "BHoM_Guid" : "ed3224f0-b2d4-4f5d-afd7-7d9045e5a09b", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-35, 20.0], "Outputs" : [-40], "BHoM_Guid" : "3ba26163-91e3-47ac-92e0-cfcec93dc8a7", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [456, 50.0], "Outputs" : [500], "BHoM_Guid" : "745ff886-db9e-4a03-ba89-5851c79285c0", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-50, 10.0], "Outputs" : [-50], "BHoM_Guid" : "f471445f-292f-4cb2-b7a0-2589b5311a06", "Name" : "" }], "BHoM_Guid" : "ad7838c0-7a55-460d-8665-6a28b834094f", "Name" : "" }], "BHoM_Guid" : "6c8ec193-28da-4214-8b30-32ac9422f35c", "Name" : "RoundToCeilingAwayFromZero", "_bhomVersion" : "9.3" } \ No newline at end of file diff --git a/.ci/Datasets/BHoM_Engine/Query/RoundToFloorAwayFromZero.json b/.ci/Datasets/BHoM_Engine/Query/RoundToFloorAwayFromZero.json deleted file mode 100644 index 8cf248c4a..000000000 --- a/.ci/Datasets/BHoM_Engine/Query/RoundToFloorAwayFromZero.json +++ /dev/null @@ -1 +0,0 @@ -{ "_t" : "BH.oM.Data.Library.Dataset", "SourceInformation" : { "_t" : "BH.oM.Data.Library.Source", "SourceLink" : "", "Title" : "RoundToFloorAwayFromZero", "Author" : "Christopher Short", "ItemReference" : "", "Version" : "", "Publisher" : "", "Schema" : "", "Language" : "", "Location" : "", "Copyright" : "", "Contributors" : "", "Confidence" : "Undefined", "BHoM_Guid" : "b6d8e3f2-9c4f-5e7d-0b3f-2f6c8d0e5b9f", "Name" : "" }, "TimeOfCreation" : { "$date" : 1730726648330 }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"8.0\" }", "MethodName" : "RoundToFloorAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }"], "_bhomVersion" : "8.0" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12.0, 20.0], "Outputs" : [0.0], "BHoM_Guid" : "4313c050-b410-4bde-bc53-c9e71c2cb784", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121.0, 2.0], "Outputs" : [120.0], "BHoM_Guid" : "2f973b07-5996-48eb-83be-0717be358920", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.2344999999999999, 1.1000000000000001], "Outputs" : [1.1000000000000001], "BHoM_Guid" : "12c54dce-6265-45f8-aac9-417453e90e0d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.01], "Outputs" : [0.01], "BHoM_Guid" : "65000816-1226-4de2-8d6d-201019b20c3e", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.014, 0.01], "Outputs" : [-0.01], "BHoM_Guid" : "cca32a03-185f-4c97-bd09-8569a9545d21", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014999999999999999, 0.01], "Outputs" : [0.01], "BHoM_Guid" : "dce86e3f-a150-4afe-a908-613a3cecea50", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.02], "Outputs" : [0.0], "BHoM_Guid" : "cda056e5-557c-4122-afe2-183ba2ed3fc8", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.0], "Outputs" : [2.0], "BHoM_Guid" : "42bddc17-735d-436e-986d-6affdba4182f", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.33333333333333331], "Outputs" : [2.0], "BHoM_Guid" : "ed690c2e-b28f-47d9-b5f0-7868e32a7653", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 0.66666666666666663], "Outputs" : [2.0], "BHoM_Guid" : "048638f6-2b17-48f7-829f-fbaf08f333b4", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.0], "Outputs" : [2.0], "BHoM_Guid" : "98f69a5c-6156-47b3-b18f-b0f462f27652", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.3333333333333333], "Outputs" : [1.3333333333333333], "BHoM_Guid" : "ef3607ed-5f04-4030-8bc8-f3e5d810e8c7", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 1.6666666666666665], "Outputs" : [1.6666666666666665], "BHoM_Guid" : "e2fd38d6-0b26-4b18-8cd9-eaa9869c2df4", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3.5, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "a553019a-a0c9-4484-af54-615e07802fce", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3.0, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "2595b162-2313-43a2-8ab5-b35c470eb536", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2.5, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "df79ec31-481f-4ca5-97b8-1b659c063afc", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2.0, 2.0], "Outputs" : [-2.0], "BHoM_Guid" : "f496c1d7-5c1d-433f-b2b6-06e59d4e3e06", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1.5, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "cc6a0f8d-8097-4839-bf2c-f43ba1e3bc54", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1.0, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "41be4649-fe6c-4071-8996-34249ae9147e", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.5, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "c6ce4c8b-ae6d-4de7-a193-b8bcbf49eaab", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.0, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "12c21fcb-7451-4f8e-b895-cd0b3372807f", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.5, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "23a23eb9-f094-4391-a98e-596046adf977", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.0, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "54f537c8-0e35-42f0-9a03-bc4336ef6067", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.5, 2.0], "Outputs" : [0.0], "BHoM_Guid" : "0ae39610-c8b2-4a17-a452-33ac06ac6ed6", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.0, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "06bb3c03-f965-4f31-8875-04c451ccbe5f", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2.5, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "eac7ce61-848a-4c15-a294-42b3ce192ae3", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3.0, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "9bd290c0-dc81-4fcf-a788-640eb845c019", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3.5, 2.0], "Outputs" : [2.0], "BHoM_Guid" : "149b368b-6a80-4a00-90f6-369286fbbbef", "Name" : "" }], "BHoM_Guid" : "f4776d46-c1c4-411b-88eb-978246c7de30", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"8.0\" }", "MethodName" : "RoundToFloorAwayFromZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"8.0\" }"], "_bhomVersion" : "8.0" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12, 20.0], "Outputs" : [0], "BHoM_Guid" : "8bd24ec8-f7cc-4156-bb8e-cd3b9dde96e0", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121, 2.0], "Outputs" : [120], "BHoM_Guid" : "c32f7c9d-d6cd-4e4b-9082-c99b43f38465", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-35, 20.0], "Outputs" : [0], "BHoM_Guid" : "c216bce1-f8cf-446a-9fa3-c9f69fd98c50", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-5, 3.0], "Outputs" : [-3], "BHoM_Guid" : "7a757517-1a9f-4d92-9a9c-a739868eb2c6", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-4, 3.0], "Outputs" : [-3], "BHoM_Guid" : "689af816-eda9-4031-be6e-26b8da690e93", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-3, 3.0], "Outputs" : [-3], "BHoM_Guid" : "2c4a5073-6b96-4e90-b1fc-55feb72a9fb2", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-2, 3.0], "Outputs" : [0], "BHoM_Guid" : "431753e2-fe42-459e-abf5-40473eeb9479", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-1, 3.0], "Outputs" : [0], "BHoM_Guid" : "9230a5aa-400e-4602-80cd-8e5a61758630", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0, 3.0], "Outputs" : [0], "BHoM_Guid" : "3296f81f-91b6-47c8-881d-151dc9ba4f37", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1, 3.0], "Outputs" : [0], "BHoM_Guid" : "f5bceca9-dfec-4ecb-88a9-e1ce525c3fbf", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [2, 3.0], "Outputs" : [0], "BHoM_Guid" : "ab969185-d7a8-467d-8076-feda02a37b35", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [3, 3.0], "Outputs" : [3], "BHoM_Guid" : "bfe12d20-f927-491b-9bcd-c3ea21e59279", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [4, 3.0], "Outputs" : [3], "BHoM_Guid" : "db67d6e1-f35c-4915-9d87-e4dd867a40e2", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [5, 3.0], "Outputs" : [3], "BHoM_Guid" : "cc8ad87e-4680-41e7-a1f6-633d470a6cf0", "Name" : "" }], "BHoM_Guid" : "b671a445-2603-4dc6-b570-6cc8ae779947", "Name" : "" }], "BHoM_Guid" : "b6d8e3f2-9c4f-5e7d-0b3f-2f6c8d0e5b9e", "Name" : "RoundToFloorAwayFromZero", "_bhomVersion" : "8.0" } diff --git a/.ci/Datasets/BHoM_Engine/Query/RoundToFloorTowardZero.json b/.ci/Datasets/BHoM_Engine/Query/RoundToFloorTowardZero.json new file mode 100644 index 000000000..05dbc0163 --- /dev/null +++ b/.ci/Datasets/BHoM_Engine/Query/RoundToFloorTowardZero.json @@ -0,0 +1 @@ +{ "_t" : "BH.oM.Data.Library.Dataset", "SourceInformation" : { "_t" : "BH.oM.Data.Library.Source", "SourceLink" : "", "Title" : "RoundToFloorTowardZero", "Author" : "Christopher Short", "ItemReference" : "", "Version" : "", "Publisher" : "", "Schema" : "", "Language" : "", "Location" : "", "Copyright" : "", "Contributors" : "", "Confidence" : "High", "BHoM_Guid" : "48f64bd1-b36e-4bfa-a663-ce0b96d0b456", "Name" : "" }, "TimeOfCreation" : { "$date" : 1788275279991 }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"9.3\" }", "MethodName" : "RoundToFloorTowardZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"9.3\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"9.3\" }"], "_bhomVersion" : "9.3" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12.0, 20.0], "Outputs" : [0.0], "BHoM_Guid" : "3a5da8d4-9070-4e1f-82c8-67c3efadd2ed", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121.0, 2.0], "Outputs" : [120.0], "BHoM_Guid" : "9f7b3402-b229-474c-b1b6-53fa40e187d4", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [1.2344999999999999, 1.1000000000000001], "Outputs" : [1.1000000000000001], "BHoM_Guid" : "33739830-80e0-46bb-bbb9-f6ddb785ea89", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.01], "Outputs" : [0.01], "BHoM_Guid" : "c723a51c-3674-4a95-8975-a3345ed9ac7c", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.014, 0.01], "Outputs" : [-0.01], "BHoM_Guid" : "be0af62b-08ae-4953-9bf9-e68e956ce64f", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014999999999999999, 0.01], "Outputs" : [0.01], "BHoM_Guid" : "e75441d0-d7ba-44ef-a1ad-12aaae7581ec", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [0.014, 0.02], "Outputs" : [0.0], "BHoM_Guid" : "6163926a-e283-4bd7-b1d2-de10fe513093", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-35.0, 20.0], "Outputs" : [-20.0], "BHoM_Guid" : "f221411c-8151-491e-bfa3-e82df7868caa", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [456.0, 50.0], "Outputs" : [450.0], "BHoM_Guid" : "d15464a1-9a3f-4bb3-8520-aad02f51996e", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-0.5, 0.10000000000000001], "Outputs" : [-0.5], "BHoM_Guid" : "db3b6cb1-8fe7-4ebf-8812-a3d863cb4b79", "Name" : "" }], "BHoM_Guid" : "6897a73d-118b-4286-9ca6-2217cb251c7d", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.UnitTest", "Method" : { "_t" : "System.Reflection.MethodBase", "TypeName" : "{ \"_t\" : \"System.Type\", \"Name\" : \"BH.Engine.Base.Query, BHoM_Engine, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null\", \"_bhomVersion\" : \"9.3\" }", "MethodName" : "RoundToFloorTowardZero", "Parameters" : ["{ \"_t\" : \"System.Type\", \"Name\" : \"System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"9.3\" }", "{ \"_t\" : \"System.Type\", \"Name\" : \"System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\", \"_bhomVersion\" : \"9.3\" }"], "_bhomVersion" : "9.3" }, "Data" : [{ "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [12, 20.0], "Outputs" : [0], "BHoM_Guid" : "c16ea64a-2def-4988-85df-d61314ab0d25", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [121, 2.0], "Outputs" : [120], "BHoM_Guid" : "d7620903-1c7c-4f33-975e-2ce6fe3e2865", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [35, 20.0], "Outputs" : [20], "BHoM_Guid" : "cc1a194a-031e-4ed7-a569-9d298cf674a9", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [14, 10.0], "Outputs" : [10], "BHoM_Guid" : "7f14fbb2-49fb-4e65-a72b-ea6b195cb500", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-14, 10.0], "Outputs" : [-10], "BHoM_Guid" : "b93993d7-3fbd-4de5-846f-55e2614cdb35", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [15, 10.0], "Outputs" : [10], "BHoM_Guid" : "24debded-053d-4869-afc0-99ab3927e1b9", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [14, 20.0], "Outputs" : [0], "BHoM_Guid" : "99d21928-e470-4d66-b67e-e1b71065beeb", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-35, 20.0], "Outputs" : [-20], "BHoM_Guid" : "a2bba558-4ecb-438b-b30a-9441eab4d054", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [456, 50.0], "Outputs" : [450], "BHoM_Guid" : "aa48ab1a-f910-45bd-b3d3-ee89c1592dd6", "Name" : "" }, { "_t" : "BH.oM.Test.UnitTests.TestData", "Inputs" : [-50, 10.0], "Outputs" : [-50], "BHoM_Guid" : "b17025d7-d9bc-4bad-8fc1-746becd1bd17", "Name" : "" }], "BHoM_Guid" : "28a945c9-18f4-4f20-9125-f23d923990b1", "Name" : "" }], "BHoM_Guid" : "939086e5-d2e0-43da-8b48-95f405587612", "Name" : "RoundToFloorTowardZero", "_bhomVersion" : "9.3" } \ No newline at end of file diff --git a/.ci/Datasets/BHoM_Engine/Query/RoundingTestsSummary.json b/.ci/Datasets/BHoM_Engine/Query/RoundingTestsSummary.json deleted file mode 100644 index 3d76eb272..000000000 --- a/.ci/Datasets/BHoM_Engine/Query/RoundingTestsSummary.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "summary": "Test cases for RoundToCeilingAwayFromZero and RoundToFloorAwayFromZero methods", - "dateCreated": "2026-08-28", - "author": "Christopher Short", - "testSuites": [ - { - "methodName": "RoundToCeilingAwayFromZero", - "description": "Rounds the magnitude of the number away from zero to the nearest tolerance multiple, regardless of sign", - "doubleOverload": { - "description": "RoundToCeilingAwayFromZero(double number, double tolerance)", - "keyCharacteristics": [ - "Positive numbers: rounds up to nearest tolerance", - "Negative numbers: rounds down (away from zero) to nearest tolerance", - "Key difference from RoundToCeiling: negative handling", - "Zero tolerance or zero input: returns input unchanged" - ], - "testCases": [ - { "input": [12.0, 20.0], "expected": 20.0, "description": "Positive with large tolerance" }, - { "input": [121.0, 2.0], "expected": 122.0, "description": "Positive with small tolerance" }, - { "input": [1.2345, 1.1], "expected": 2.2, "description": "Positive fractional" }, - { "input": [0.014, 0.01], "expected": 0.02, "description": "Positive small value" }, - { "input": [-0.014, 0.01], "expected": -0.02, "description": "Negative small value (KEY: away from zero)" }, - { "input": [0.015, 0.01], "expected": 0.02, "description": "Rounding edge case" }, - { "input": [0.014, 0.02], "expected": 0.02, "description": "Tolerance larger than value" }, - { "input": [-3.5, 2.0], "expected": -4.0, "description": "Negative away from zero" }, - { "input": [-0.5, 2.0], "expected": -2.0, "description": "Negative small value away from zero" }, - { "input": [0.5, 2.0], "expected": 2.0, "description": "Positive small value" } - ] - }, - "intOverload": { - "description": "RoundToCeilingAwayFromZero(int number, double tolerance)", - "testCases": [ - { "input": [12, 20.0], "expected": 20, "description": "Positive with large tolerance" }, - { "input": [121, 2.0], "expected": 122, "description": "Positive with small tolerance" }, - { "input": [-35, 20.0], "expected": -40, "description": "Negative away from zero" } - ] - } - }, - { - "methodName": "RoundToFloorAwayFromZero", - "description": "Rounds the magnitude of the number toward zero to the previous tolerance multiple, regardless of sign", - "doubleOverload": { - "description": "RoundToFloorAwayFromZero(double number, double tolerance)", - "keyCharacteristics": [ - "Positive numbers: rounds down to nearest tolerance (like Floor)", - "Negative numbers: rounds up (toward zero) to nearest tolerance", - "Opposite behavior to RoundToCeilingAwayFromZero", - "Zero tolerance or zero input: returns input unchanged" - ], - "testCases": [ - { "input": [12.0, 20.0], "expected": 0.0, "description": "Positive with large tolerance" }, - { "input": [121.0, 2.0], "expected": 120.0, "description": "Positive with small tolerance" }, - { "input": [1.2345, 1.1], "expected": 1.1, "description": "Positive fractional" }, - { "input": [0.014, 0.01], "expected": 0.01, "description": "Positive small value" }, - { "input": [-0.014, 0.01], "expected": -0.01, "description": "Negative small value (KEY: toward zero)" }, - { "input": [0.015, 0.01], "expected": 0.01, "description": "Rounding edge case" }, - { "input": [0.014, 0.02], "expected": 0.0, "description": "Tolerance larger than value" }, - { "input": [-3.5, 2.0], "expected": -2.0, "description": "Negative toward zero" }, - { "input": [-0.5, 2.0], "expected": 0.0, "description": "Negative small value toward zero" }, - { "input": [0.5, 2.0], "expected": 0.0, "description": "Positive small value" } - ] - }, - "intOverload": { - "description": "RoundToFloorAwayFromZero(int number, double tolerance)", - "testCases": [ - { "input": [12, 20.0], "expected": 0, "description": "Positive with large tolerance" }, - { "input": [121, 2.0], "expected": 120, "description": "Positive with small tolerance" }, - { "input": [-35, 20.0], "expected": 0, "description": "Negative toward zero" }, - { "input": [-5, 3.0], "expected": -3, "description": "Negative toward zero with smaller tolerance" } - ] - } - } - ], - "keyDifferences": { - "RoundToCeilingAwayFromZero_vs_RoundToCeiling": [ - "RoundToCeiling(-0.014, 0.01) → -0.01 (toward positive/ceiling)", - "RoundToCeilingAwayFromZero(-0.014, 0.01) → -0.02 (away from zero)", - "RoundToCeiling(-3.5, 2.0) → -2.0 (toward positive)", - "RoundToCeilingAwayFromZero(-3.5, 2.0) → -4.0 (away from zero)" - ], - "RoundToFloorAwayFromZero_vs_RoundToFloor": [ - "RoundToFloor(-0.014, 0.01) → -0.02 (away from zero)", - "RoundToFloorAwayFromZero(-0.014, 0.01) → -0.01 (toward zero)", - "RoundToFloor(-3.5, 2.0) → -4.0 (away from zero)", - "RoundToFloorAwayFromZero(-3.5, 2.0) → -2.0 (toward zero)" - ] - }, - "comprehensiveTestCoverage": { - "included": [ - "All examples from method XML documentation", - "Both double and int overloads", - "Positive and negative values", - "Fractional tolerances (0.33, 0.67, 1.33, 1.67)", - "Whole number tolerances (1.0, 2.0, 3.0, 20.0)", - "Edge cases (zero input, zero tolerance, values smaller than tolerance)", - "Range of values (-35 to 121) to verify behavior consistency" - ] - } -} diff --git a/BHoM_Engine/Query/RoundToCeilingAwayFromZero.cs b/BHoM_Engine/Query/RoundToCeilingAwayFromZero.cs index 5a77c1e64..5f912654d 100644 --- a/BHoM_Engine/Query/RoundToCeilingAwayFromZero.cs +++ b/BHoM_Engine/Query/RoundToCeilingAwayFromZero.cs @@ -34,18 +34,19 @@ public static partial class Query [Description("Rounds a number using the given tolerance, always rounding the magnitude of the number away " + "from zero to the next tolerance multiple, regardless of sign. Supports any fractional, integer, " + - "positive or negative numbers." + + "positive or negative numbers. Complements RoundFloorTowardZero()." + "\nSome examples:" + - "\n\t RoundToCeiling(12, 20) ==> 20" + - "\n\t RoundToCeiling(121, 2) ==> 122" + - "\n\t RoundToCeiling(1.2345, 1.1) ==> 2.2" + - "\n\t RoundToCeiling(0.014, 0.01) ==> 0.02" + - "\n\t RoundToCeiling(-0.014, 0.01) ==> -0.02" + - "\n\t RoundToCeiling(0.015, 0.01) ==> 0.02" + - "\n\t RoundToCeiling(0.014, 0.02) ==> 0.02" + + "\n\t RoundToCeilingAwayFromZero(12, 20) ==> 20" + + "\n\t RoundToCeilingAwayFromZero(121, 2) ==> 122" + + "\n\t RoundToCeilingAwayFromZero(1.2345, 1.1) ==> 2.2" + + "\n\t RoundToCeilingAwayFromZero(0.014, 0.01) ==> 0.02" + + "\n\t RoundToCeilingAwayFromZero(-0.014, 0.01) ==> -0.02" + + "\n\t RoundToCeilingAwayFromZero(0.015, 0.01) ==> 0.02" + + "\n\t RoundToCeilingAwayFromZero(0.014, 0.02) ==> 0.02" + "\nand so on.")] [Input("number", "Number to be rounded.")] [Input("tolerance", "Tolerance to use for rounding.")] + [Output("roundedNumber", "The rounded number.")] public static double RoundToCeilingAwayFromZero(this double number, double tolerance) { if (tolerance < 0) @@ -64,14 +65,15 @@ public static double RoundToCeilingAwayFromZero(this double number, double toler /***************************************************/ - [Description("Rounds an integer number using the given tolerance, rounding to ceiling to the nearest tolerance multiplier." + + [Description("Rounds an integer number using the given tolerance, rounding the magnitude away from zero to the nearest tolerance multiplier." + "\nSome examples:" + - "\n\t RoundToCeiling(12, 20) ==> 20" + - "\n\t RoundToCeiling(121, 2) ==> 122" + - "\n\t RoundToCeiling(-35, 20) ==> -20" + + "\n\t RoundToCeilingAwayFromZero(12, 20) ==> 20" + + "\n\t RoundToCeilingAwayFromZero(121, 2) ==> 122" + + "\n\t RoundToCeilingAwayFromZero(-35, 20) ==> -40" + "\nand so on.")] [Input("number", "Number to be rounded.")] [Input("tolerance", "Tolerance to use for rounding.")] + [Output("roundedNumber", "The rounded number.")] public static int RoundToCeilingAwayFromZero(this int number, double tolerance) { if (tolerance < 0) @@ -90,7 +92,8 @@ public static int RoundToCeilingAwayFromZero(this int number, double tolerance) return 0; } - return (int)(Math.Ceiling(number / tolerance) * tolerance); + int sign = number < 0 ? -1 : 1; + return sign * (int)(Math.Ceiling(Math.Abs(number) / tolerance) * tolerance); } /***************************************************/ diff --git a/BHoM_Engine/Query/RoundToFloorAwayFromZero.cs b/BHoM_Engine/Query/RoundToFloorTowardZero.cs similarity index 67% rename from BHoM_Engine/Query/RoundToFloorAwayFromZero.cs rename to BHoM_Engine/Query/RoundToFloorTowardZero.cs index bf8ca820e..8c765dec6 100644 --- a/BHoM_Engine/Query/RoundToFloorAwayFromZero.cs +++ b/BHoM_Engine/Query/RoundToFloorTowardZero.cs @@ -4,20 +4,20 @@ * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. - * - * - * The BHoM is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3.0 of the License, or - * (at your option) any later version. - * - * The BHoM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . */ using BH.oM.Base.Attributes; @@ -36,17 +36,18 @@ public static partial class Query "zero to the previous tolerance multiple, regardless of sign. Supports any fractional, integer, " + "positive or negative numbers." + "\nSome examples:" + - "\n\t RoundToFloor(12, 20) ==> 0" + - "\n\t RoundToFloor(121, 2) ==> 120" + - "\n\t RoundToFloor(1.2345, 1.1) ==> 1.1" + - "\n\t RoundToFloor(0.014, 0.01) ==> 0.01" + - "\n\t RoundToFloor(-0.014, 0.01) ==> -0.01" + - "\n\t RoundToFloor(0.015, 0.01) ==> 0.01" + - "\n\t RoundToFloor(0.014, 0.02) ==> 0" + + "\n\t RoundToFloorTowardZero(12, 20) ==> 0" + + "\n\t RoundToFloorTowardZero(121, 2) ==> 120" + + "\n\t RoundToFloorTowardZero(1.2345, 1.1) ==> 1.1" + + "\n\t RoundToFloorTowardZero(0.014, 0.01) ==> 0.01" + + "\n\t RoundToFloorTowardZero(-0.014, 0.01) ==> -0.01" + + "\n\t RoundToFloorTowardZero(0.015, 0.01) ==> 0.01" + + "\n\t RoundToFloorTowardZero(0.014, 0.02) ==> 0" + "\nand so on.")] [Input("number", "Number to be rounded.")] [Input("tolerance", "Tolerance to use for rounding.")] - public static double RoundToFloorAwayFromZero(this double number, double tolerance) + [Output("roundedNumber", "The rounded number.")] + public static double RoundToFloorTowardZero(this double number, double tolerance) { if (tolerance < 0) { @@ -64,15 +65,16 @@ public static double RoundToFloorAwayFromZero(this double number, double toleran /***************************************************/ - [Description("Rounds an integer number using the given tolerance, rounding to floor to the nearest tolerance multiplier." + + [Description("Rounds an integer number using the given tolerance, rounding the magnitude toward zero to the nearest tolerance multiple." + "\nSome examples:" + - "\n\t RoundToFloor(12, 20) ==> 0" + - "\n\t RoundToFloor(121, 2) ==> 120" + - "\n\t RoundToFloor(-35, 20) ==> -40" + + "\n\t RoundToFloorTowardZero(12, 20) ==> 0" + + "\n\t RoundToFloorTowardZero(121, 2) ==> 120" + + "\n\t RoundToFloorTowardZero(-35, 20) ==> -20" + "\nand so on.")] [Input("number", "Number to be rounded.")] [Input("tolerance", "Tolerance to use for rounding.")] - public static int RoundToFloorAwayFromZero(this int number, double tolerance) + [Output("roundedNumber", "The rounded number.")] + public static int RoundToFloorTowardZero(this int number, double tolerance) { if (tolerance < 0) { @@ -90,11 +92,10 @@ public static int RoundToFloorAwayFromZero(this int number, double tolerance) return 0; } - return (int)(Math.Floor(number / tolerance) * tolerance); + int sign = number < 0 ? -1 : 1; + return sign * (int)(Math.Floor(Math.Abs(number) / tolerance) * tolerance); } /***************************************************/ } } - -