CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow) and pe-check. BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
107 lines
4.0 KiB
C#
107 lines
4.0 KiB
C#
using Chronos.Testing;
|
||
using Chronos.Ui.Visuals;
|
||
|
||
namespace Chronos.App.Tests.Visuals;
|
||
|
||
public sealed class MinMaxDecimatorTests
|
||
{
|
||
[Test]
|
||
public void ShortSeriesKeepsEverySample()
|
||
{
|
||
double[] values = [3, 1, 4, 1, 5];
|
||
var output = new int[MinMaxDecimator.Capacity(values.Length, 10)];
|
||
var n = MinMaxDecimator.Decimate(values, 10, output);
|
||
Assert.SequenceEqual([0, 1, 2, 3, 4], output[..n]);
|
||
}
|
||
|
||
[Test]
|
||
public void LongSeriesKeepsAtMostTwoSamplesPerColumn()
|
||
{
|
||
var values = Noise(200_000, seed: 1);
|
||
const int columns = 800;
|
||
var output = new int[MinMaxDecimator.Capacity(values.Length, columns)];
|
||
var n = MinMaxDecimator.Decimate(values, columns, output);
|
||
Assert.LessOrEqual(n, 2 * columns);
|
||
Assert.Monotonic(output[..n].Select(i => (double)i), strict: true);
|
||
}
|
||
|
||
[Test]
|
||
public void EveryColumnPreservesItsMinimumAndMaximum()
|
||
{
|
||
var values = Noise(123_457, seed: 2);
|
||
// Plant spikes that a naive stride sampler would miss.
|
||
values[50_001] = 1000;
|
||
values[99_999] = -1000;
|
||
const int columns = 640;
|
||
var output = new int[MinMaxDecimator.Capacity(values.Length, columns)];
|
||
var n = MinMaxDecimator.Decimate(values, columns, output);
|
||
var kept = output[..n];
|
||
|
||
for (var c = 0; c < columns; c++)
|
||
{
|
||
var start = (int)((long)c * values.Length / columns);
|
||
var end = (int)((long)(c + 1) * values.Length / columns);
|
||
double min = double.PositiveInfinity, max = double.NegativeInfinity;
|
||
double keptMin = double.PositiveInfinity, keptMax = double.NegativeInfinity;
|
||
for (var i = start; i < end; i++)
|
||
{
|
||
min = Math.Min(min, values[i]);
|
||
max = Math.Max(max, values[i]);
|
||
}
|
||
foreach (var i in kept)
|
||
{
|
||
if (i < start || i >= end) continue;
|
||
keptMin = Math.Min(keptMin, values[i]);
|
||
keptMax = Math.Max(keptMax, values[i]);
|
||
}
|
||
Assert.Equal(min, keptMin, $"column {c} min");
|
||
Assert.Equal(max, keptMax, $"column {c} max");
|
||
}
|
||
Assert.Contains(50_001, kept);
|
||
Assert.Contains(99_999, kept);
|
||
}
|
||
|
||
[Test]
|
||
public void NonFiniteRunsBecomeSingleGaps()
|
||
{
|
||
double[] values = [1, double.NaN, double.NaN, 2, double.PositiveInfinity, 3, double.NaN];
|
||
var output = new int[values.Length];
|
||
var n = MinMaxDecimator.Decimate(values, 100, output);
|
||
Assert.SequenceEqual([0, MinMaxDecimator.Gap, 3, MinMaxDecimator.Gap, 5], output[..n]);
|
||
}
|
||
|
||
[Test]
|
||
public void EmptyColumnsBreakTheLineInDecimatedMode()
|
||
{
|
||
var values = new double[1000];
|
||
for (var i = 0; i < values.Length; i++) values[i] = i < 400 || i >= 600 ? i : double.NaN;
|
||
var output = new int[MinMaxDecimator.Capacity(values.Length, 10)];
|
||
var n = MinMaxDecimator.Decimate(values, 10, output);
|
||
// Columns 4 and 5 (indices 400–599) hold no finite sample: exactly one gap between columns 3 and 6.
|
||
Assert.SequenceEqual([0, 99, 100, 199, 200, 299, 300, 399, MinMaxDecimator.Gap, 600, 699, 700, 799, 800, 899, 900, 999], output[..n]);
|
||
}
|
||
|
||
[Test]
|
||
public void FlatColumnsEmitOneSample()
|
||
{
|
||
var values = Enumerable.Repeat(5.0, 1000).ToArray();
|
||
var output = new int[MinMaxDecimator.Capacity(values.Length, 4)];
|
||
var n = MinMaxDecimator.Decimate(values, 4, output);
|
||
Assert.SequenceEqual([0, 250, 500, 750], output[..n]);
|
||
}
|
||
|
||
[Test]
|
||
public void UndersizedOutputIsRejected()
|
||
{
|
||
Assert.Throws<ArgumentException>(() => MinMaxDecimator.Decimate(new double[100], 10, new int[5]));
|
||
}
|
||
|
||
private static double[] Noise(int count, int seed)
|
||
{
|
||
var random = new Random(seed);
|
||
var values = new double[count];
|
||
for (var i = 0; i < count; i++) values[i] = Math.Sin(i * 0.001) + random.NextDouble() * 0.2;
|
||
return values;
|
||
}
|
||
}
|