diff --git a/src/Engine/ProtoCore/Utils/MathUtils.cs b/src/Engine/ProtoCore/Utils/MathUtils.cs index 77e679bd749..5615b399715 100644 --- a/src/Engine/ProtoCore/Utils/MathUtils.cs +++ b/src/Engine/ProtoCore/Utils/MathUtils.cs @@ -30,7 +30,7 @@ public static bool IsLessThanOrEquals(double lhs, double rhs) return (lhs < rhs) || Equals(lhs, rhs); } - public static bool Equals(double lhs, double rhs) + public static bool Equals(double lhs, double rhs, double tolerance) { if (double.IsPositiveInfinity(lhs) && double.IsPositiveInfinity(rhs)) return true; @@ -38,7 +38,12 @@ public static bool Equals(double lhs, double rhs) if (double.IsNegativeInfinity(lhs) && double.IsNegativeInfinity(rhs)) return true; - return Math.Abs(lhs - rhs) < Tolerance; + return Math.Abs(lhs - rhs) < tolerance; + } + + public static bool Equals(double lhs, double rhs) + { + return Equals(lhs, rhs, Tolerance); } } } diff --git a/src/Libraries/CoreNodeModels/CoreNodeModels.csproj b/src/Libraries/CoreNodeModels/CoreNodeModels.csproj index c7af21e6de6..9629c405f3e 100644 --- a/src/Libraries/CoreNodeModels/CoreNodeModels.csproj +++ b/src/Libraries/CoreNodeModels/CoreNodeModels.csproj @@ -53,6 +53,7 @@ + diff --git a/src/Libraries/CoreNodeModels/CoreNodeModelsImages.resx b/src/Libraries/CoreNodeModels/CoreNodeModelsImages.resx index 097b83c93e4..ccd3f8bb340 100644 --- a/src/Libraries/CoreNodeModels/CoreNodeModelsImages.resx +++ b/src/Libraries/CoreNodeModels/CoreNodeModelsImages.resx @@ -1274,22 +1274,21 @@ - iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAADEElEQVR4Xu2XPWpUARRGs6ds - YFqFYCOmMY02wRVYprOwsbEUbQKmVlxDEARdgWLhBqwE/+aDuRC+OZdXzUwufAdOd5r7wXuPdx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wN4xySztr9XE0MJzooDH2wqWz0yTJP4LKv209IbOpMLcTFOCu3pFw2 + 3ALkPixGKEdRiJN9thLXuGurso3oOxzFsG3nwSieTkOTow+3CiGEEEIIIYQQQgghhBBCCCHEKObm/gdF + uTYQicmIVQAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAd1JREFUWEft + Vb1KA0EQTiJ2Igimt7C2s5ZcEMTOiCD+FDa+gCksfQEtLlERwcLkBUyh6CvYRJLmNkUabeJDrN+3OxxG + Et27jQhyH3zc7NzOzO7O7GwuQ4YMSaG1zq9d9heCem8/qKmqIWTq+E+mTR50HtSjjVKoOuAgqEWNUhid + klamTnU5Z+ILObzS0whyH4TRy+pFb+VE64L8ikEd/3EO526dD2bklx/oCLvUcPrmsjNzUqFq0YYLF3U6 + GGdm56olKmdwwbT1SgfyWkFe22mc2JNAOlATokoGu3vVZV5FlRimJuAj1SnwWrGyRxWcK2hLH/QlKneU + a709GDdlOATsaBd8Bu/AA7AIroPLMiUG6qDBPiFDd5TD6AjGZzKMgSAF8BhclKBPIG9IA5yTaTFsn1BV + Gbpj3AIIBFoCN8F5UVEXy5+RfgFjUoBA2+AjeAO+i3wLXsuUIaROwbgiRKCiiJRnwR2QqZgSdQyvIoTD + PIw7vteQPuhLVMkA479rRIQ9hegBi3gVlTPYvr1bMcEHxT5Ginf+R2dm53gHaDPpF5En0WZeR3VH6qT1 + trlz75fwK2w6VIVFBQ7AJvsESZk6BO/iW/E+9u9A57xW7BNsVoaQqfvVwBky/FPkch8Yc7bTvUnhewAA + AABJRU5ErkJggg== \ No newline at end of file diff --git a/src/Libraries/CoreNodeModels/Equals.cs b/src/Libraries/CoreNodeModels/Equals.cs new file mode 100644 index 00000000000..829353a3341 --- /dev/null +++ b/src/Libraries/CoreNodeModels/Equals.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CoreNodeModels.Properties; +using Dynamo.Graph.Nodes; +using Newtonsoft.Json; +using ProtoCore.AST.AssociativeAST; +using ProtoCore.DSASM; +using ProtoCore.Utils; + +namespace CoreNodeModels +{ + [NodeName("==")] + [NodeDescription("EqualsWithToleranceDescription", typeof(Resources))] + [NodeCategory("Core.Math")] + [NodeSearchTags("EqualsWithToleranceSearchTags", typeof(Resources))] + [InPortTypes("double", "double", "double")] + [OutPortTypes("bool")] + [IsDesignScriptCompatible] + public class Equals : NodeModel + { + private static readonly DoubleNode tolerancePortDefaultValue = new DoubleNode(MathUtils.Tolerance); + + [JsonConstructor] + private Equals(IEnumerable inPorts, IEnumerable outPorts) : base(inPorts, outPorts) + { + ArgumentLacing = LacingStrategy.Auto; + inPorts.ElementAt(2).DefaultValue = tolerancePortDefaultValue; + } + + public Equals() + { + ArgumentLacing = LacingStrategy.Auto; + + InPorts.Add(new PortModel(PortType.Input, this, new PortData("x", Resources.EqualsWithToleranceLhsRhsTooltip))); + InPorts.Add(new PortModel(PortType.Input, this, new PortData("y", Resources.EqualsWithToleranceLhsRhsTooltip))); + InPorts.Add(new PortModel(PortType.Input, this, + new PortData("tolerance", string.Format(Resources.EqualsWithToleranceTooltip, MathUtils.Tolerance), tolerancePortDefaultValue))); + OutPorts.Add(new PortModel(PortType.Output, this, new PortData("bool", Resources.EqualsWithToleranceOutportTooltip))); + RegisterAllPorts(); + } + + public override IEnumerable BuildOutputAst(List inputAstNodes) + { + if (!InPorts[0].IsConnected && !InPorts[1].IsConnected && !InPorts[2].IsConnected) + { + return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) }; + } + + AssociativeNode rhs; + if (IsPartiallyApplied) + { + var connectedInputs = Enumerable.Range(0, InPorts.Count) + .Where(index => InPorts[index].IsConnected) + .Select(x => new IntNode(x) as AssociativeNode) + .ToList(); + var arguments = AstFactory.BuildExprList(inputAstNodes); + + + var functionNode = new IdentifierListNode + { + LeftNode = new IdentifierNode("DSCore.Math"), + RightNode = new IdentifierNode("Equals") + }; + IntNode paramNumNode = new IntNode(3); + var positionNode = AstFactory.BuildExprList(connectedInputs); + + var inputParams = new List + { + functionNode, + paramNumNode, + positionNode, + arguments, + AstFactory.BuildBooleanNode(true) + }; + + rhs = AstFactory.BuildFunctionCall("__CreateFunctionObject", inputParams); + } + else + { + UseLevelAndReplicationGuide(inputAstNodes); + + rhs = AstFactory.BuildFunctionCall(new Func(DSCore.Math.Equals), + inputAstNodes); + } + + return new[] + { + AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), rhs) + }; + } + } +} diff --git a/src/Libraries/CoreNodeModels/Properties/Resources.Designer.cs b/src/Libraries/CoreNodeModels/Properties/Resources.Designer.cs index 3bd7826c95e..85fd34c3d70 100644 --- a/src/Libraries/CoreNodeModels/Properties/Resources.Designer.cs +++ b/src/Libraries/CoreNodeModels/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace CoreNodeModels.Properties -{ - - +namespace CoreNodeModels.Properties { + using System; + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -375,6 +375,52 @@ public static string DynamoConvertSearchTags { } } + /// + /// Looks up a localized string similar to Equals with tolerance input.. + /// + public static string EqualsWithToleranceDescription { + get { + return ResourceManager.GetString("EqualsWithToleranceDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Integer or double value. + /// + public static string EqualsWithToleranceLhsRhsTooltip { + get { + return ResourceManager.GetString("EqualsWithToleranceLhsRhsTooltip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Result of equality check. + /// + public static string EqualsWithToleranceOutportTooltip { + get { + return ResourceManager.GetString("EqualsWithToleranceOutportTooltip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to equals;tolerance. + /// + public static string EqualsWithToleranceSearchTags { + get { + return ResourceManager.GetString("EqualsWithToleranceSearchTags", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Tolerance + ///Default value: {0}. + /// + public static string EqualsWithToleranceTooltip { + get { + return ResourceManager.GetString("EqualsWithToleranceTooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Creates a file object from a path.. /// diff --git a/src/Libraries/CoreNodeModels/Properties/Resources.en-US.resx b/src/Libraries/CoreNodeModels/Properties/Resources.en-US.resx index cf08e1ab8b7..8c72b60479a 100644 --- a/src/Libraries/CoreNodeModels/Properties/Resources.en-US.resx +++ b/src/Libraries/CoreNodeModels/Properties/Resources.en-US.resx @@ -590,4 +590,22 @@ color + + Equals with tolerance input. + Description for Equals with tolerance node + + + Integer or double value + Equals with tolerance node input port tooltip + + + Result of equality check + + + equals;tolerance + + + Tolerance +Default value: {0} + \ No newline at end of file diff --git a/src/Libraries/CoreNodeModels/Properties/Resources.resx b/src/Libraries/CoreNodeModels/Properties/Resources.resx index cf08e1ab8b7..8c72b60479a 100644 --- a/src/Libraries/CoreNodeModels/Properties/Resources.resx +++ b/src/Libraries/CoreNodeModels/Properties/Resources.resx @@ -590,4 +590,22 @@ color + + Equals with tolerance input. + Description for Equals with tolerance node + + + Integer or double value + Equals with tolerance node input port tooltip + + + Result of equality check + + + equals;tolerance + + + Tolerance +Default value: {0} + \ No newline at end of file diff --git a/src/Libraries/CoreNodes/CoreNodes.csproj b/src/Libraries/CoreNodes/CoreNodes.csproj index d23e2749cae..9f21a045140 100644 --- a/src/Libraries/CoreNodes/CoreNodes.csproj +++ b/src/Libraries/CoreNodes/CoreNodes.csproj @@ -97,6 +97,10 @@ DynamoCore False + + {7a9e0314-966f-4584-baa3-7339cbb849d1} + ProtoCore + {ef879a10-041d-4c68-83e7-3192685f1bae} DynamoServices diff --git a/src/Libraries/CoreNodes/Math.cs b/src/Libraries/CoreNodes/Math.cs index 606429cc837..e234ba2a963 100644 --- a/src/Libraries/CoreNodes/Math.cs +++ b/src/Libraries/CoreNodes/Math.cs @@ -5,6 +5,7 @@ using Autodesk.DesignScript.Runtime; using DSCore.Properties; using NCalc; +using ProtoCore.Utils; using CSMath = System.Math; namespace DSCore @@ -200,6 +201,19 @@ public static double Abs(double number) return CSMath.Abs(number); } + /// + /// This method is ONLY used by the Equals (with tolerance) NodeModel node + /// + /// + /// + /// + /// + [IsVisibleInDynamoLibrary(false)] + public static bool Equals(double lhs, double rhs, double tol) + { + return MathUtils.Equals(lhs, rhs, tol); + } + /// /// Finds the absolute value of a number. /// diff --git a/src/LibraryViewExtension/web/library/layoutSpecs.json b/src/LibraryViewExtension/web/library/layoutSpecs.json index f17a6c763b0..040253bacd7 100644 --- a/src/LibraryViewExtension/web/library/layoutSpecs.json +++ b/src/LibraryViewExtension/web/library/layoutSpecs.json @@ -687,6 +687,9 @@ { "path": "Operators.==" }, + { + "path": "Core.Math.==" + }, { "path": "Operators.>=" }, diff --git a/src/Resources/CoreNodeModels/LargeIcons/CoreNodeModels.Equals.Large.png b/src/Resources/CoreNodeModels/LargeIcons/CoreNodeModels.Equals.Large.png new file mode 100644 index 00000000000..79edd042a5c Binary files /dev/null and b/src/Resources/CoreNodeModels/LargeIcons/CoreNodeModels.Equals.Large.png differ diff --git a/src/Resources/CoreNodeModels/SmallIcons/CoreNodeModels.Equals.Small.png b/src/Resources/CoreNodeModels/SmallIcons/CoreNodeModels.Equals.Small.png new file mode 100644 index 00000000000..f6c41993be9 Binary files /dev/null and b/src/Resources/CoreNodeModels/SmallIcons/CoreNodeModels.Equals.Small.png differ diff --git a/test/DynamoCoreTests/DefaultArgumentTests.cs b/test/DynamoCoreTests/DefaultArgumentTests.cs index c352cdbff29..ef3e164b1a6 100644 --- a/test/DynamoCoreTests/DefaultArgumentTests.cs +++ b/test/DynamoCoreTests/DefaultArgumentTests.cs @@ -3,6 +3,7 @@ using System.IO; using Dynamo.Graph.Nodes; using Dynamo.Graph.Nodes.ZeroTouch; +using FFITarget.DesignScript; using NUnit.Framework; namespace Dynamo.Tests @@ -86,5 +87,30 @@ public void TestDefaultArgumentExpressionResolutionWithConflict() Assert.IsTrue(result.State == ElementState.Warning); } + + [Test] + public void TestDefaultArgumentExpressionWithReplicationGuides() + { + // Simulate loading of external libraries in Dynamo by importing + // FFITarget after preloading the standard set of libraries above + string libraryPath = "FFITarget.dll"; + + CurrentDynamoModel.LibraryServices.ImportLibrary(libraryPath); + + string openPath = Path.Combine(TestDirectory, + @"core\dsevaluation\TestDefaultArgumentExpressionWithReplicationGuides.dyn"); + OpenModel(openPath); + + BeginRun(); + + // Assert that node using default argument expression with fully qualified Point class evaluates + var pt00 = Point.XYZ(1, 2, 0); + var pt01 = Point.XYZ(1, 3, 0); + var pt10 = Point.XYZ(2, 2, 0); + var pt11 = Point.XYZ(2, 3, 0); + + AssertPreviewValue("cc365216-df02-41ce-9ea4-e477c06b7d55", + new object[] {new[] {pt00, pt01}, new[] {pt10, pt11}}); + } } } diff --git a/test/DynamoCoreTests/Nodes/LogicTests.cs b/test/DynamoCoreTests/Nodes/LogicTests.cs index f3ed756a52e..1da65aae94d 100644 --- a/test/DynamoCoreTests/Nodes/LogicTests.cs +++ b/test/DynamoCoreTests/Nodes/LogicTests.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.IO; +using System.Runtime.CompilerServices; using NUnit.Framework; namespace Dynamo.Tests @@ -12,6 +13,7 @@ protected override void GetLibrariesToPreload(List libraries) libraries.Add("VMDataBridge.dll"); libraries.Add("DesignScriptBuiltin.dll"); libraries.Add("DSCoreNodes.dll"); + libraries.Add("FunctionObject.ds"); base.GetLibrariesToPreload(libraries); } @@ -254,6 +256,48 @@ public void testCompare_StringDouble() AssertPreviewValue("a4c69409-8430-42a4-9769-2817a507b1b7", null); AssertPreviewValue("5801abfd-e00f-408a-8bb1-8289b795686f", null); } + + [Test] + public void testToleranceEquals_defaultTolerance() + { + string testFilePath = Path.Combine(logicTestFolder, "testToleranceEquals_defaultTolerance.dyn"); + + RunModel(testFilePath); + AssertPreviewValue("d3ca0126-f365-4d79-8168-476022009dc2", false); + AssertPreviewValue("c2f69bf4-34be-47fa-8f0a-4a0ceca5910b", false); + } + + [Test] + public void testToleranceEquals_lacing() + { + string testFilePath = Path.Combine(logicTestFolder, "testToleranceEquals_lacing.dyn"); + + RunModel(testFilePath); + AssertPreviewValue("89af328d-f688-489f-a0b8-e01566ee74d5", new[] {true, true, false, false}); + AssertPreviewValue("9db0f6f3-0680-4c0f-bd60-82fd38ac536b", + new object[] {new[] {true, false, false, false}, new[] {false, true, false, false}}); + AssertPreviewValue("399a6b0a-699f-4494-8160-d6e4301b7921", new[] {true, true}); + } + + [Test] + public void testToleranceEquals_map() + { + string testFilePath = Path.Combine(logicTestFolder, "testToleranceEquals_map.dyn"); + + RunModel(testFilePath); + AssertPreviewValue("94354c1d-853d-4932-9228-38b241bac6f3", new[] {true, true}); + AssertPreviewValue("462b6cae-ceea-475a-ac4a-76dd79d17d68", new[] {true, true}); + } + + [Test] + public void testToleranceEquals_map2() + { + string testFilePath = Path.Combine(logicTestFolder, "testToleranceEquals_map2.dyn"); + + RunModel(testFilePath); + AssertPreviewValue("8f17012e-9331-455d-9760-3537233e7262", + new object[] {new[] {true, false}, new[] {false, true}, new[] {false, false}, new[] {false, false}}); + } } [TestFixture] diff --git a/test/Engine/FFITarget/ProtoFFITests.cs b/test/Engine/FFITarget/ProtoFFITests.cs index 09166dc62ff..436f33d076c 100644 --- a/test/Engine/FFITarget/ProtoFFITests.cs +++ b/test/Engine/FFITarget/ProtoFFITests.cs @@ -978,6 +978,25 @@ public static Point ByCoordinates(double x, double y, double z) public double dX { get; set; } public double dY { get; set; } public double dZ { get; set; } + + [IsVisibleInDynamoLibrary(false)] + public override bool Equals(object obj) + { + if (obj == null) return false; + + if (GetType() != obj.GetType()) return false; + + var other = obj as Point; + if (dX == other.dX && dY == other.dY && dZ == other.dZ) return true; + + return false; + } + + [IsVisibleInDynamoLibrary(false)] + public override int GetHashCode() + { + return dX.GetHashCode() ^ dY.GetHashCode() ^ dZ.GetHashCode(); + } } } diff --git a/test/Engine/FFITarget/TestDefaultArgumentAttributes.cs b/test/Engine/FFITarget/TestDefaultArgumentAttributes.cs index d37ad07085f..97f04fd0fe2 100644 --- a/test/Engine/FFITarget/TestDefaultArgumentAttributes.cs +++ b/test/Engine/FFITarget/TestDefaultArgumentAttributes.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using Autodesk.DesignScript.Runtime; using FFITarget.DesignScript; @@ -16,5 +18,10 @@ public static double ComputeCircleConflict([DefaultArgument("Point.ByCoordinates { return radius * radius * Math.PI; } + + public static IEnumerable> ComputeFlattenedPoints([DefaultArgument("FFITarget.DesignScript.Point.ByCoordinates((1..2)<1>, (2..3)<2>, 0)")]IEnumerable> points) + { + return points; + } } } diff --git a/test/core/dsevaluation/TestDefaultArgumentExpressionWithReplicationGuides.dyn b/test/core/dsevaluation/TestDefaultArgumentExpressionWithReplicationGuides.dyn new file mode 100644 index 00000000000..c53212cd9d9 --- /dev/null +++ b/test/core/dsevaluation/TestDefaultArgumentExpressionWithReplicationGuides.dyn @@ -0,0 +1,85 @@ +{ + "Uuid": "7de9d6eb-6b1b-4862-8fbf-cfd97683cf7e", + "IsCustomNode": false, + "Description": null, + "Name": "TestDefaultArgumentExpressionWithReplicationGuides", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "FFITarget.TestDefaultArgumentAttributes.ComputeFlattenedPoints@FFITarget.DesignScript.Point[][]", + "Id": "cc365216df0241ce9ea4e477c06b7d55", + "Inputs": [ + { + "Id": "9c50a73576a54cb18536ca1f1c794c7c", + "Name": "points", + "Description": "Point[][]\nDefault value : FFITarget.DesignScript.Point.ByCoordinates((1..10)<1>, (2..20)<2>, 0)", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "fdc64164bc2f4581b882f3d90317f530", + "Name": "Point[]", + "Description": "Point[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "TestDefaultArgumentAttributes.ComputeFlattenedPoints (points: Point[][] = FFITarget.DesignScript.Point.ByCoordinates((1..10)<1>, (2..20)<2>, 0)): Point[]" + } + ], + "Connectors": [], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.5.0.6324", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Background Preview", + "EyeX": -32.633264315044464, + "EyeY": 35.352703007964834, + "EyeZ": 157.72744418938157, + "LookX": 32.633264315044464, + "LookY": -35.352703007964834, + "LookZ": -157.72744418938157, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "NodeViews": [ + { + "ShowGeometry": true, + "Name": "TestDefaultArgumentAttributes.ComputeFlattenedPoints", + "Id": "cc365216df0241ce9ea4e477c06b7d55", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 429.0, + "Y": 334.0 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/test/core/logic/comparison/testToleranceEquals_defaultTolerance.dyn b/test/core/logic/comparison/testToleranceEquals_defaultTolerance.dyn new file mode 100644 index 00000000000..4449bef03ac --- /dev/null +++ b/test/core/logic/comparison/testToleranceEquals_defaultTolerance.dyn @@ -0,0 +1,211 @@ +{ + "Uuid": "f86c300d-ef05-4b62-b583-118c86f5b45e", + "IsCustomNode": false, + "Description": null, + "Name": "testToleranceEquals_defaultTolerance", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "0.0;\n0.00001;", + "Id": "c782cf633be34abebca2de185ba431a8", + "Inputs": [], + "Outputs": [ + { + "Id": "7042b0fc8bbf48c5b4597572a61c5521", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "4276cf1c8ec3424bb7cd865edb5c2d65", + "Name": "", + "Description": "Value of expression at line 2", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "==@var[]..[],var[]..[]", + "Id": "d3ca0126f3654d798168476022009dc2", + "Inputs": [ + { + "Id": "67ae19e97e394d7ca20d2e4ac51566ac", + "Name": "x", + "Description": "x value.\n\nvar[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "6ee3fb5997564f87ba99d3500f0fa1de", + "Name": "y", + "Description": "y value.\n\nvar[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "62576a7a9aeb4ea7bc4e455829002ef4", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Equal x to y?\n\n== (x: var[]..[], y: var[]..[]): var[]..[]" + }, + { + "ConcreteType": "CoreNodeModels.Equals, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "c2f69bf434be47fa8f0a4a0ceca5910b", + "Inputs": [ + { + "Id": "f56e15e8af374ddb871b1f29e8e98a27", + "Name": "x", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "d79da400f2d44831b2a9fd6b87901fce", + "Name": "y", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "b57fb26dfd2e4e3ab18e6762afb32119", + "Name": "tolerance", + "Description": "tolerance", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "1cacbf10418940938c15812fdc28a3e1", + "Name": "bool", + "Description": "result of equality check", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Equals with tolerance input." + } + ], + "Connectors": [ + { + "Start": "7042b0fc8bbf48c5b4597572a61c5521", + "End": "67ae19e97e394d7ca20d2e4ac51566ac", + "Id": "c68633bb5694445c82396ca6d88b7211" + }, + { + "Start": "7042b0fc8bbf48c5b4597572a61c5521", + "End": "f56e15e8af374ddb871b1f29e8e98a27", + "Id": "bb364c40f5324c1a94e983c907596557" + }, + { + "Start": "4276cf1c8ec3424bb7cd865edb5c2d65", + "End": "6ee3fb5997564f87ba99d3500f0fa1de", + "Id": "cf3d26c817cc43149658bcce3cd404f3" + }, + { + "Start": "4276cf1c8ec3424bb7cd865edb5c2d65", + "End": "d79da400f2d44831b2a9fd6b87901fce", + "Id": "7fba6a1d576447a0b37b957bf2bf7f38" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.5.0.6324", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "NodeViews": [ + { + "ShowGeometry": true, + "Name": "Code Block", + "Id": "c782cf633be34abebca2de185ba431a8", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 318.0, + "Y": 324.0 + }, + { + "ShowGeometry": true, + "Name": "==", + "Id": "d3ca0126f3654d798168476022009dc2", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 516.0, + "Y": 512.0 + }, + { + "ShowGeometry": true, + "Name": "==", + "Id": "c2f69bf434be47fa8f0a4a0ceca5910b", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 572.0, + "Y": 211.0 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/test/core/logic/comparison/testToleranceEquals_lacing.dyn b/test/core/logic/comparison/testToleranceEquals_lacing.dyn new file mode 100644 index 00000000000..e14ac1a754d --- /dev/null +++ b/test/core/logic/comparison/testToleranceEquals_lacing.dyn @@ -0,0 +1,286 @@ +{ + "Uuid": "ce4dea94-aab4-40ff-906c-d04dab768dd8", + "IsCustomNode": false, + "Description": null, + "Name": "testToleranceEquals_lacing", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "1..2;\n1..4;", + "Id": "0e2592bec36548f89b0cd14919c71b6c", + "Inputs": [], + "Outputs": [ + { + "Id": "9eb4d3d2dfdf469aa94a318e6cad5e2e", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "bdbb106e4ac6441db7065c2657330f9a", + "Name": "", + "Description": "Value of expression at line 2", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + }, + { + "ConcreteType": "CoreNodeModels.Equals, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "399a6b0a699f44948160d6e4301b7921", + "Inputs": [ + { + "Id": "c972dd56187f4dbfb68155b78ca3bc5b", + "Name": "x", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "f58e257e7ae94e0595ef4df2bea36b8d", + "Name": "y", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "58eaa706dd0149e3bd428c7a94ae2fbd", + "Name": "tolerance", + "Description": "tolerance", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "cf74c6b54f40402ab56f315614825e2b", + "Name": "bool", + "Description": "result of equality check", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Shortest", + "Description": "Equals with tolerance input." + }, + { + "ConcreteType": "CoreNodeModels.Equals, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "9db0f6f306804c0fbd6082fd38ac536b", + "Inputs": [ + { + "Id": "bd8dff34a3a240a98644f1375b9e085b", + "Name": "x", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "fb8e7da709f040929f25ef708cd3b72a", + "Name": "y", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "410ac52b76d24d22bd574681381261d7", + "Name": "tolerance", + "Description": "tolerance", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "da6c373f91d444ccaad04cc0d7a59ce0", + "Name": "bool", + "Description": "result of equality check", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "CrossProduct", + "Description": "Equals with tolerance input." + }, + { + "ConcreteType": "CoreNodeModels.Equals, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "89af328df688489fa0b8e01566ee74d5", + "Inputs": [ + { + "Id": "a6db08c6246e4a45921eb40174b0cff2", + "Name": "x", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "d73bf85b7fe84d92b45b98be9aeede96", + "Name": "y", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "d15cc3450e604b529bd703cfd544623f", + "Name": "tolerance", + "Description": "tolerance", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "9268493a64204246bba50ea2581a043f", + "Name": "bool", + "Description": "result of equality check", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Longest", + "Description": "Equals with tolerance input." + } + ], + "Connectors": [ + { + "Start": "9eb4d3d2dfdf469aa94a318e6cad5e2e", + "End": "c972dd56187f4dbfb68155b78ca3bc5b", + "Id": "b934ac2db7e843aeaebeab8250385724" + }, + { + "Start": "9eb4d3d2dfdf469aa94a318e6cad5e2e", + "End": "bd8dff34a3a240a98644f1375b9e085b", + "Id": "cf43c4850f1242caab560f499b154056" + }, + { + "Start": "9eb4d3d2dfdf469aa94a318e6cad5e2e", + "End": "a6db08c6246e4a45921eb40174b0cff2", + "Id": "4d3ffe8c41af4b9eb7e74d0e5c83637f" + }, + { + "Start": "bdbb106e4ac6441db7065c2657330f9a", + "End": "f58e257e7ae94e0595ef4df2bea36b8d", + "Id": "d65d68cf8d7847018e74246b0be1501d" + }, + { + "Start": "bdbb106e4ac6441db7065c2657330f9a", + "End": "fb8e7da709f040929f25ef708cd3b72a", + "Id": "6143b89fb7434cbd8516ac990dd5aab9" + }, + { + "Start": "bdbb106e4ac6441db7065c2657330f9a", + "End": "d73bf85b7fe84d92b45b98be9aeede96", + "Id": "05e507ef853648948d444fe80afa15b3" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.5.0.6324", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "NodeViews": [ + { + "ShowGeometry": true, + "Name": "Code Block", + "Id": "0e2592bec36548f89b0cd14919c71b6c", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 167.0, + "Y": 178.0 + }, + { + "ShowGeometry": true, + "Name": "==", + "Id": "399a6b0a699f44948160d6e4301b7921", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 184.0, + "Y": 455.0 + }, + { + "ShowGeometry": true, + "Name": "==", + "Id": "9db0f6f306804c0fbd6082fd38ac536b", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 518.0, + "Y": 362.0 + }, + { + "ShowGeometry": true, + "Name": "==", + "Id": "89af328df688489fa0b8e01566ee74d5", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 822.0, + "Y": 127.0 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/test/core/logic/comparison/testToleranceEquals_map.dyn b/test/core/logic/comparison/testToleranceEquals_map.dyn new file mode 100644 index 00000000000..6864d0fdf13 --- /dev/null +++ b/test/core/logic/comparison/testToleranceEquals_map.dyn @@ -0,0 +1,361 @@ +{ + "Uuid": "ce4dea94-aab4-40ff-906c-d04dab768dd8", + "IsCustomNode": false, + "Description": null, + "Name": "testToleranceEquals_map", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "1..2;\n1..4;", + "Id": "0e2592bec36548f89b0cd14919c71b6c", + "Inputs": [], + "Outputs": [ + { + "Id": "9eb4d3d2dfdf469aa94a318e6cad5e2e", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "bdbb106e4ac6441db7065c2657330f9a", + "Name": "", + "Description": "Value of expression at line 2", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + }, + { + "ConcreteType": "CoreNodeModels.HigherOrder.Map, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "8f17012e9331455d97603537233e7262", + "Inputs": [ + { + "Id": "886a14a716b44210b86d04a9963fbb2a", + "Name": "list", + "Description": "The list to map over.", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "388ede573414431d960eabac923db778", + "Name": "f(x)", + "Description": "The procedure used to map element", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "f440cae199014e57b21bf213f5887430", + "Name": "mapped", + "Description": "Mapped list", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Applies a function over all elements of a list, generating a new list from the results." + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "0.00001;", + "Id": "54fe19d0c2c643e5a3c7ad383944ddcb", + "Inputs": [], + "Outputs": [ + { + "Id": "f1ce35e348b04726b70993b82aae9a12", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + }, + { + "ConcreteType": "CoreNodeModels.Equals, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "462b6caeceea475aac4a76dd79d17d68", + "Inputs": [ + { + "Id": "74b4d0953e6144e2b8552074608c1529", + "Name": "x", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "f5ac5cc4831543d8a4935803a58ba806", + "Name": "y", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "49abf2e0659045f496d18f8129e04efb", + "Name": "tolerance", + "Description": "tolerance", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "6dde5d4586b44c08b36b40f14a89c464", + "Name": "bool", + "Description": "result of equality check", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Equals with tolerance input." + }, + { + "ConcreteType": "CoreNodeModels.Equals, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "558cd23c74b147eeb7c3c8ff2de3b693", + "Inputs": [ + { + "Id": "8af67ef9a283471e85b4808081be784f", + "Name": "x", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "2d43943ed5b948ee82fa496907ee4dce", + "Name": "y", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "b24a152b3fa0468cbb7126e573df5ff3", + "Name": "tolerance", + "Description": "tolerance (disabled)", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "f85a22db28dc40499866c1c33a3a79fe", + "Name": "bool", + "Description": "result of equality check", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Equals with tolerance input." + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "DSCore.List.Flatten@var[]..[],int", + "Id": "94354c1d853d4932922838b241bac6f3", + "Inputs": [ + { + "Id": "a061e3cd5c324e978613f1ca7c00b917", + "Name": "list", + "Description": "List to flatten.\n\nvar[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "3d1a186a991f423f8abd825dbbccb579", + "Name": "amt", + "Description": "Layers of nesting to remove.\n\nint\nDefault value : -1", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "0f972a0a19c04834895fe9107f918abc", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Flattens a nested list of lists by a certain amount.\n\nList.Flatten (list: var[]..[], amt: int = -1): var[]..[]" + } + ], + "Connectors": [ + { + "Start": "9eb4d3d2dfdf469aa94a318e6cad5e2e", + "End": "74b4d0953e6144e2b8552074608c1529", + "Id": "5bc86e2cb2fc43d691bd6a9b78ee6d7f" + }, + { + "Start": "9eb4d3d2dfdf469aa94a318e6cad5e2e", + "End": "8af67ef9a283471e85b4808081be784f", + "Id": "624c1ed0d0c3445791e102ff5af7ac2b" + }, + { + "Start": "bdbb106e4ac6441db7065c2657330f9a", + "End": "f5ac5cc4831543d8a4935803a58ba806", + "Id": "c2c1f8968a0f4417b4d2af7c647ac0b3" + }, + { + "Start": "bdbb106e4ac6441db7065c2657330f9a", + "End": "2d43943ed5b948ee82fa496907ee4dce", + "Id": "b7ec334cbe7e4163a62e87e1125930c9" + }, + { + "Start": "f440cae199014e57b21bf213f5887430", + "End": "a061e3cd5c324e978613f1ca7c00b917", + "Id": "c6bef275ba3e444ab7b293c0ef3613ab" + }, + { + "Start": "f1ce35e348b04726b70993b82aae9a12", + "End": "886a14a716b44210b86d04a9963fbb2a", + "Id": "6002fb22366641efb8e94b2e5854b598" + }, + { + "Start": "f85a22db28dc40499866c1c33a3a79fe", + "End": "388ede573414431d960eabac923db778", + "Id": "29367f9085184044822b3327a1a0aa9f" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.5.0.6324", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "NodeViews": [ + { + "ShowGeometry": true, + "Name": "Code Block", + "Id": "0e2592bec36548f89b0cd14919c71b6c", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 109.0, + "Y": 311.0 + }, + { + "ShowGeometry": true, + "Name": "List.Map", + "Id": "8f17012e9331455d97603537233e7262", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 787.0, + "Y": 54.0 + }, + { + "ShowGeometry": true, + "Name": "Code Block", + "Id": "54fe19d0c2c643e5a3c7ad383944ddcb", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 423.0, + "Y": 21.0 + }, + { + "ShowGeometry": true, + "Name": "==", + "Id": "462b6caeceea475aac4a76dd79d17d68", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 515.99433427762, + "Y": 433.09065155807349 + }, + { + "ShowGeometry": true, + "Name": "==", + "Id": "558cd23c74b147eeb7c3c8ff2de3b693", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 431.99291784702541, + "Y": 196.86118980169971 + }, + { + "ShowGeometry": true, + "Name": "List.Flatten", + "Id": "94354c1d853d4932922838b241bac6f3", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 1025.0, + "Y": 60.045325779036773 + } + ], + "Annotations": [], + "X": -40.0, + "Y": 70.954674220963227, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/test/core/logic/comparison/testToleranceEquals_map2.dyn b/test/core/logic/comparison/testToleranceEquals_map2.dyn new file mode 100644 index 00000000000..e19ee96bd83 --- /dev/null +++ b/test/core/logic/comparison/testToleranceEquals_map2.dyn @@ -0,0 +1,205 @@ +{ + "Uuid": "ce4dea94-aab4-40ff-906c-d04dab768dd8", + "IsCustomNode": false, + "Description": null, + "Name": "testToleranceEquals_map2", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "1..2;\n1..4;", + "Id": "0e2592bec36548f89b0cd14919c71b6c", + "Inputs": [], + "Outputs": [ + { + "Id": "9eb4d3d2dfdf469aa94a318e6cad5e2e", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "bdbb106e4ac6441db7065c2657330f9a", + "Name": "", + "Description": "Value of expression at line 2", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + }, + { + "ConcreteType": "CoreNodeModels.HigherOrder.Map, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "8f17012e9331455d97603537233e7262", + "Inputs": [ + { + "Id": "886a14a716b44210b86d04a9963fbb2a", + "Name": "list", + "Description": "The list to map over.", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "388ede573414431d960eabac923db778", + "Name": "f(x)", + "Description": "The procedure used to map element", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "f440cae199014e57b21bf213f5887430", + "Name": "mapped", + "Description": "Mapped list", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Applies a function over all elements of a list, generating a new list from the results." + }, + { + "ConcreteType": "CoreNodeModels.Equals, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "50a636be76e147c48a08460844181e31", + "Inputs": [ + { + "Id": "66e3271253e04a12a458fa19b189342d", + "Name": "x", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "05a7f7281c94449398038b12b40624b7", + "Name": "y", + "Description": "integer or double value", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "5ae0405868454997ad23b9eb5077bbbc", + "Name": "tolerance", + "Description": "tolerance", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "4b3bc5cbd8b046b2a4cf2c07fc14e844", + "Name": "bool", + "Description": "result of equality check", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Equals with tolerance input." + } + ], + "Connectors": [ + { + "Start": "9eb4d3d2dfdf469aa94a318e6cad5e2e", + "End": "66e3271253e04a12a458fa19b189342d", + "Id": "35cc1216217f4e4aab4a5171fa1cff7a" + }, + { + "Start": "bdbb106e4ac6441db7065c2657330f9a", + "End": "886a14a716b44210b86d04a9963fbb2a", + "Id": "a66129d985c947faac5cd003a6d8bf38" + }, + { + "Start": "4b3bc5cbd8b046b2a4cf2c07fc14e844", + "End": "388ede573414431d960eabac923db778", + "Id": "199bad95a005436ca101f628c82b507a" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.5.0.6324", + "RunType": "Manual", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "NodeViews": [ + { + "Id": "0e2592bec36548f89b0cd14919c71b6c", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Name": "Code Block", + "ShowGeometry": true, + "Excluded": false, + "X": 263.0, + "Y": 62.0 + }, + { + "Id": "8f17012e9331455d97603537233e7262", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Name": "List.Map", + "ShowGeometry": true, + "Excluded": false, + "X": 754.0, + "Y": 76.0 + }, + { + "Id": "50a636be76e147c48a08460844181e31", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Name": "==", + "ShowGeometry": true, + "Excluded": false, + "X": 457.0, + "Y": 173.0 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file