Skip to content

Cherr-pick revert of heterogeneous list fix and add workflow test that highlights performance degradation #9441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Engine/ProtoCore/Lang/Replication/Replicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,11 @@ public static List<List<StackValue>> ComputeAllReducedParams(
//This should generally be a collection, so we need to do a one phase unboxing
var targets = reducedParams.Select(r => r[index]).ToList();
var target = basicList[index];

if (!target.IsArray)
{
System.Console.WriteLine("WARNING: Replication unbox requested on Singleton. Trap: 437AD20D-9422-40A3-BFFD-DA4BAD7F3E5F");
System.Console.WriteLine(
"WARNING: Replication unbox requested on Singleton. Trap: 437AD20D-9422-40A3-BFFD-DA4BAD7F3E5F");
continue;
}

Expand All @@ -231,7 +232,7 @@ public static List<List<StackValue>> ComputeAllReducedParams(
var arrayStats = new HashSet<StackValue>();
foreach (var targetTemp in targets)
{
var temp = ArrayUtils.GetTypeExamplesForLayer2(targetTemp, runtimeCore).ToList();
var temp = ArrayUtils.GetTypeExamplesForLayer(targetTemp, runtimeCore).Values.ToList();
arrayStats.UnionWith(temp);
}

Expand All @@ -247,6 +248,7 @@ public static List<List<StackValue>> ComputeAllReducedParams(
reducedParams.Add(newArgs);
}
}

}
}

Expand Down
41 changes: 0 additions & 41 deletions src/Engine/ProtoCore/Utils/ArrayUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public static ClassNode GetGreatestCommonSubclassForArray(StackValue array, Runt
return runtimeCore.DSExecutable.classTable.ClassNodes[orderedTypes.First()];
}

// TODO gantaa/pratapa: Remove this deprecated method in 3.0 and rename GetTypeExamplesForLayer2
public static Dictionary<int, StackValue> GetTypeExamplesForLayer(StackValue array, RuntimeCore runtimeCore)
{
Dictionary<int, StackValue> usageFreq = new Dictionary<int, StackValue>();
Expand All @@ -140,46 +139,6 @@ public static Dictionary<int, StackValue> GetTypeExamplesForLayer(StackValue arr
return usageFreq;
}

public static IEnumerable<StackValue> GetTypeExamplesForLayer2(StackValue array, RuntimeCore runtimeCore)
{
var usageFreq = new Dictionary<int, List<StackValue>>();

if (!array.IsArray)
{
usageFreq.Add(array.metaData.type, new List<StackValue> {array});

// return flattened list of unique values
return usageFreq.Values.SelectMany(x => x);
}

//This is the element on the heap that manages the data structure
var dsArray = runtimeCore.Heap.ToHeapObject<DSArray>(array);
foreach (var sv in dsArray.Values)
{
// If sv is an array type, continue adding array values to usageFreq dictionary
// as different arrays need not necessarily contain the same types.
if (sv.IsArray)
{
List<StackValue> list;
if (usageFreq.TryGetValue(sv.metaData.type, out list))
{
list.Add(sv);
}
else
{
usageFreq.Add(sv.metaData.type, new List<StackValue> {sv});
}
}
else if (!usageFreq.ContainsKey(sv.metaData.type))
{
usageFreq.Add(sv.metaData.type, new List<StackValue> {sv});
}
}
// return flattened list of unique values
return usageFreq.Values.SelectMany(x => x);
}



/// <summary>
/// Generate type statistics for given layer of an array
Expand Down
4 changes: 2 additions & 2 deletions test/Engine/ProtoTest/Associative/BuiltinMethodsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ public void TestTryGetValuesFromDictionary08()
thisTest.Verify("r", null);
}

[Test]
[Test, Category("Failure")]
public void TestTryGetValuesFromDictionary09()
{
string code = @"
Expand Down Expand Up @@ -1099,7 +1099,7 @@ public void TestTryGetValuesFromDictionary10()
thisTest.Verify("r2", new object[] { new object[] { new object[] { 24 } }, 42 });
}

[Test]
[Test, Category("Failure")]
public void TestTryGetValuesFromDictionary11()
{
string code = @"
Expand Down
32 changes: 32 additions & 0 deletions test/Libraries/WorkflowTests/ComplexTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,5 +1174,37 @@ public void Test_WorkFlowTestForCSV()
var nurbsCurve = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace(curveID);
Assert.AreEqual(ElementState.Warning, nurbsCurve.State);
}

[Test]
public void Test_PerforationsByImage()
{
string openPath = Path.Combine(TestDirectory, @"core\WorkflowTestFiles\PerforatedScreenByImage\Perforations by image.dyn");

RunModel(openPath);
AssertNoDummyNodes();

Assert.AreEqual(30, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
Assert.AreEqual(40, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());

//check Curve.ExtrudeAsSolid
var solidID = "15cdd045-e5dc-4217-85eb-0c7aac2c7901";
AssertPreviewCount(solidID, 20);
var solid = GetFlattenedPreviewValues(solidID);
foreach (var element in solid)
{
Assert.IsNotNull(solid);
}

//check Solid.ByUnion
var unionID = "0892604a-39a6-40f4-a12b-4043959de522";
var union = GetPreviewValue(unionID) as Solid;
Assert.IsNotNull(union);

//check Surface.SubtractFrom
var geometryID = "d15326de-522b-441f-b85b-90ae2dbb8207";
AssertPreviewCount(geometryID, 1);
var geometry = GetPreviewValueAtIndex(geometryID, 0) as Surface;
Assert.IsNotNull(geometry);
}
}
}
Loading