From 9f9bf3b0a6a1a8b181a96575871f98d4b66bce01 Mon Sep 17 00:00:00 2001 From: Martin Molinero Date: Wed, 3 Jan 2024 13:49:47 -0300 Subject: [PATCH] Minor plotting test fix --- Algorithm/QCAlgorithm.Plotting.cs | 5 +---- Tests/Algorithm/AlgorithmPlottingTests.cs | 10 +++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Algorithm/QCAlgorithm.Plotting.cs b/Algorithm/QCAlgorithm.Plotting.cs index 2c22830ca193..34c81826425b 100644 --- a/Algorithm/QCAlgorithm.Plotting.cs +++ b/Algorithm/QCAlgorithm.Plotting.cs @@ -543,8 +543,7 @@ public IEnumerable GetChartUpdates(bool clearChartData = false) { foreach (var chart in _charts.Values) { - var updates = chart.GetUpdates(); - + yield return chart.GetUpdates(); if (clearChartData) { // we can clear this data out after getting updates to prevent unnecessary memory usage @@ -553,8 +552,6 @@ public IEnumerable GetChartUpdates(bool clearChartData = false) series.Value.Purge(); } } - - yield return updates; } } } diff --git a/Tests/Algorithm/AlgorithmPlottingTests.cs b/Tests/Algorithm/AlgorithmPlottingTests.cs index fb8ed489da25..69e27897a5d7 100644 --- a/Tests/Algorithm/AlgorithmPlottingTests.cs +++ b/Tests/Algorithm/AlgorithmPlottingTests.cs @@ -29,7 +29,7 @@ namespace QuantConnect.Tests.Algorithm { - [TestFixture] + [TestFixture, Parallelizable(ParallelScope.Fixtures)] public class AlgorithmPlottingTests { private Symbol _spy; @@ -105,7 +105,7 @@ public void TestGetChartUpdatesWhileAdding() { for (var i = 0; i < 1000; i++) { - _algorithm.GetChartUpdates(true); + _algorithm.GetChartUpdates(true).ToList(); Thread.Sleep(1); } }); @@ -168,7 +168,7 @@ def Update(self, input): customIndicator.Update(input); customIndicator.Current.Value = customIndicator.Value; Assert.DoesNotThrow(() => _algorithm.Plot("PlotTest", customIndicator)); - var charts = _algorithm.GetChartUpdates(); + var charts = _algorithm.GetChartUpdates().ToList(); Assert.IsTrue(charts.Where(x => x.Name == "PlotTest").Any()); Assert.AreEqual(10, charts.First().Series["custom"].GetValues().First().y); } @@ -194,7 +194,7 @@ def Update(self, input): var customIndicator = module.GetAttr("CustomIndicator").Invoke(); Assert.DoesNotThrow(() => _algorithm.Plot("PlotTest", customIndicator)); - var charts = _algorithm.GetChartUpdates(); + var charts = _algorithm.GetChartUpdates().ToList(); Assert.IsFalse(charts.Where(x => x.Name == "PlotTest").Any()); Assert.IsTrue(charts.Where(x => x.Name == "Strategy Equity").Any()); Assert.AreEqual(10, charts.First().Series["PlotTest"].GetValues().First().y); @@ -213,7 +213,7 @@ public void PlotIndicatorPlotsBaseIndicator() sma1.Update(new DateTime(2022, 11, 15), 1); sma2.Update(new DateTime(2022, 11, 15), 2); - var charts = _algorithm.GetChartUpdates(); + var charts = _algorithm.GetChartUpdates().ToList(); Assert.IsTrue(charts.Where(x => x.Name == "PlotTest").Any()); var chart = charts.First();