From e0a60d5d8702a362ab39dd4342f14f6ff9a47b78 Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Sat, 23 Mar 2024 00:25:09 -0700 Subject: [PATCH] Fix weird violin plots --- Craftimizer/ImGuiUtils.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Craftimizer/ImGuiUtils.cs b/Craftimizer/ImGuiUtils.cs index bea59c0..f7b0e56 100644 --- a/Craftimizer/ImGuiUtils.cs +++ b/Craftimizer/ImGuiUtils.cs @@ -253,7 +253,10 @@ public ViolinData(IEnumerable samples, float min, float max, int resolution .Select(n => Lerp(min, max, n / (float)resolution)) .Select(n => (n, (float)KernelDensity.EstimateGaussian(n, bandwidth, samplesList))) .Select(n => new Point(n.n, n.Item2, -n.Item2)); - DataArray = [.. data]; + // ParallelQuery doesn't support [.. data] correctly. The plots look very wrong. +#pragma warning disable IDE0305 // Simplify collection initialization + DataArray = data.ToArray(); +#pragma warning restore IDE0305 // Simplify collection initialization s.Stop(); Log.Debug($"Violin plot processing took {s.Elapsed.TotalMilliseconds:0.00}ms"); });