diff --git a/src/Engine/ProtoCore/Lang/Replication/Replicator.cs b/src/Engine/ProtoCore/Lang/Replication/Replicator.cs index 1da73ba4785..75ba486e5a7 100644 --- a/src/Engine/ProtoCore/Lang/Replication/Replicator.cs +++ b/src/Engine/ProtoCore/Lang/Replication/Replicator.cs @@ -212,35 +212,32 @@ public static List> ComputeAllReducedParams( var indices = ri.Zipped ? ri.ZipIndecies : new List { ri.CartesianIndex }; foreach (int index in indices) { - //This should generally be a collection, so we need to do a one phase unboxing - var targets = reducedParams.Select(r => r[index]).ToList(); - foreach (var target in targets) + StackValue target = basicList[index]; + + if (!target.IsArray) { - if (!target.IsArray) - { System.Console.WriteLine("WARNING: Replication unbox requested on Singleton. Trap: 437AD20D-9422-40A3-BFFD-DA4BAD7F3E5F"); continue; - } + } - var array = runtimeCore.Heap.ToHeapObject(target); - if (array.Count == 0) - { + var array = runtimeCore.Heap.ToHeapObject(target); + if (array.Count == 0) + { continue; - } + } - var arrayStats = ArrayUtils.GetTypeExamplesForLayer(target, runtimeCore).Values; + var arrayStats = ArrayUtils.GetTypeExamplesForLayer(target, runtimeCore).Values; - List> clonedList = new List>(reducedParams); - reducedParams.Clear(); + List> clonedList = new List>(reducedParams); + reducedParams.Clear(); - foreach (StackValue sv in arrayStats) + foreach (StackValue sv in arrayStats) + { + foreach (List lst in clonedList) { - foreach (List lst in clonedList) - { - List newArgs = new List(lst); - newArgs[index] = sv; - reducedParams.Add(newArgs); - } + List newArgs = new List(lst); + newArgs[index] = sv; + reducedParams.Add(newArgs); } } } diff --git a/test/DynamoCoreTests/DSEvaluationModelTest.cs b/test/DynamoCoreTests/DSEvaluationModelTest.cs index f89ed7988c9..3222f3ca52a 100644 --- a/test/DynamoCoreTests/DSEvaluationModelTest.cs +++ b/test/DynamoCoreTests/DSEvaluationModelTest.cs @@ -8,7 +8,6 @@ using Dynamo.Graph.Nodes.ZeroTouch; using NUnit.Framework; - namespace Dynamo.Tests { [Category("DSExecution")] @@ -1173,6 +1172,20 @@ public void TestMAGN9507() OpenModel(dynFilePath); AssertPreviewValue("3bf992eb-ecc9-4fcc-a90b-9b1ee7e925e9", 3); } + + [Test, Category("UnitTests")] + public void TestHeterogenousList() + { + // open test graph + RunModel(@"core\dsevaluation\test_hetereogenous_list.dyn"); + + var guidX = "d7c44c9098d647e0bbd4be8fa2c842eb"; + var guidY = "a5463d1fb5d0457da51e563a5707d1cd"; + var guidZ = "d35348ab082c451aac9fc2e8a04f7263"; + AssertPreviewValue(guidX, new object[] { null, null, null, 5 }); + AssertPreviewValue(guidY, new object[] { null, null, null, 10.2 }); + AssertPreviewValue(guidZ, new object[] { null, null, null, 15.2 }); + } } [Category("DSCustomNode")] diff --git a/test/core/dsevaluation/test_hetereogenous_list.dyn b/test/core/dsevaluation/test_hetereogenous_list.dyn new file mode 100644 index 00000000000..fad002124eb --- /dev/null +++ b/test/core/dsevaluation/test_hetereogenous_list.dyn @@ -0,0 +1,343 @@ +{ + "Uuid": "9c0f5d9a-a576-4b5f-aa96-16f23aa368aa", + "IsCustomNode": false, + "Description": null, + "Name": "test_hetereogenous_list", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "[null,2,\"dynamo\",5];", + "Id": "118c57f1daae49d5881d85fd87457854", + "Inputs": [], + "Outputs": [ + { + "Id": "e1611e607e244d68909f8c79dd6367c0", + "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": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "Autodesk.DesignScript.Geometry.Point.ByCoordinates@double,double,double", + "Id": "a552dc86624b4907a05398d42a9bed2a", + "Inputs": [ + { + "Id": "e047cdaf28344f62800d077e41368405", + "Name": "x", + "Description": "double\nDefault value : 0", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "ce53b7523b1f42c0a0f04d7559aead3d", + "Name": "y", + "Description": "double\nDefault value : 0", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "5cea5d17a27148a999633f6b4aad50ed", + "Name": "z", + "Description": "double\nDefault value : 0", + "UsingDefaultValue": true, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "51837e30accd4c9fa543ee31afa3ef51", + "Name": "Point", + "Description": "Point", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Shortest", + "Description": "Form a Point given 3 cartesian coordinates\n\nPoint.ByCoordinates (x: double = 0, y: double = 0, z: double = 0): Point" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "[null,\"2.1\",4,15.2];", + "Id": "e69207f1fedb4aeba5805f521b4131da", + "Inputs": [], + "Outputs": [ + { + "Id": "83cdb0e2043b4117bb1026d330a80b66", + "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": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "[false,null,0,10.2];", + "Id": "51a04f1ba8b14520ac45aca38ccfa2d4", + "Inputs": [], + "Outputs": [ + { + "Id": "71674e5aebcd43fc907b7cf3c289d7ae", + "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": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "Autodesk.DesignScript.Geometry.Point.X", + "Id": "d7c44c9098d647e0bbd4be8fa2c842eb", + "Inputs": [ + { + "Id": "93fb61ccf42a4711b9df172fb268b296", + "Name": "point", + "Description": "Autodesk.DesignScript.Geometry.Point", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "0c76438367dc4930b97d65fa1d611ea8", + "Name": "double", + "Description": "double", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Get the X component of a Point\n\nPoint.X: double" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "Autodesk.DesignScript.Geometry.Point.Y", + "Id": "a5463d1fb5d0457da51e563a5707d1cd", + "Inputs": [ + { + "Id": "9eb9b4686cf444f099efe22c7da07b5f", + "Name": "point", + "Description": "Autodesk.DesignScript.Geometry.Point", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "5df624b541f9474d9d87c5d8430b7328", + "Name": "double", + "Description": "double", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Get the Y component of a Point\n\nPoint.Y: double" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "Autodesk.DesignScript.Geometry.Point.Z", + "Id": "d35348ab082c451aac9fc2e8a04f7263", + "Inputs": [ + { + "Id": "5ba94294f75049f1bb825a5ae598de1f", + "Name": "point", + "Description": "Autodesk.DesignScript.Geometry.Point", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "6b371a4ec8c947079a9ff1681de06189", + "Name": "double", + "Description": "double", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Get the Z component of a Point\n\nPoint.Z: double" + } + ], + "Connectors": [ + { + "Start": "e1611e607e244d68909f8c79dd6367c0", + "End": "e047cdaf28344f62800d077e41368405", + "Id": "62f8ae3741ac49038e6b4f88e01cc7e8" + }, + { + "Start": "51837e30accd4c9fa543ee31afa3ef51", + "End": "93fb61ccf42a4711b9df172fb268b296", + "Id": "6d32408fc6d94616a6a907283a1d56da" + }, + { + "Start": "51837e30accd4c9fa543ee31afa3ef51", + "End": "9eb9b4686cf444f099efe22c7da07b5f", + "Id": "a095b8c0a1484319864cc035cc7d862b" + }, + { + "Start": "51837e30accd4c9fa543ee31afa3ef51", + "End": "5ba94294f75049f1bb825a5ae598de1f", + "Id": "2fc5bfea29634d45b17bf8166f657b58" + }, + { + "Start": "83cdb0e2043b4117bb1026d330a80b66", + "End": "5cea5d17a27148a999633f6b4aad50ed", + "Id": "e53d3fa52e2a4e778c458ad4078ae90f" + }, + { + "Start": "71674e5aebcd43fc907b7cf3c289d7ae", + "End": "ce53b7523b1f42c0a0f04d7559aead3d", + "Id": "8eee54696c234883a8e1b2121b9046bf" + } + ], + "Dependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.1.0.7185", + "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": "118c57f1daae49d5881d85fd87457854", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 78.0, + "Y": 68.0 + }, + { + "ShowGeometry": true, + "Name": "Point.ByCoordinates", + "Id": "a552dc86624b4907a05398d42a9bed2a", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 442.0, + "Y": 145.0 + }, + { + "ShowGeometry": true, + "Name": "Code Block", + "Id": "e69207f1fedb4aeba5805f521b4131da", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 75.0, + "Y": 265.0 + }, + { + "ShowGeometry": true, + "Name": "Code Block", + "Id": "51a04f1ba8b14520ac45aca38ccfa2d4", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 80.0, + "Y": 170.0 + }, + { + "ShowGeometry": true, + "Name": "Point.X", + "Id": "d7c44c9098d647e0bbd4be8fa2c842eb", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 684.0, + "Y": 13.0 + }, + { + "ShowGeometry": true, + "Name": "Point.Y", + "Id": "a5463d1fb5d0457da51e563a5707d1cd", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 686.0, + "Y": 133.0 + }, + { + "ShowGeometry": true, + "Name": "Point.Z", + "Id": "d35348ab082c451aac9fc2e8a04f7263", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 687.0, + "Y": 276.0 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file