Skip to content

Commit 377ff60

Browse files
committed
minor fixes.
1 parent 8afbbf8 commit 377ff60

9 files changed

Lines changed: 49 additions & 45 deletions

File tree

Numerics/Data/Paired Data/ProbabilityOrdinate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class ProbabilityOrdinates : List<double>, INotifyCollectionChanged, INot
7878
public event NotifyCollectionChangedEventHandler CollectionChanged;
7979

8080
/// <summary>
81-
/// Occurs when a property value changes, such as <see cref="Count"/>
81+
/// Occurs when a property value changes/>
8282
/// or the indexer <c>Item[]</c>.
8383
/// </summary>
8484
public event PropertyChangedEventHandler PropertyChanged;

Numerics/Numerics.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@
3434
<AssemblyVersion>2.0.0.0</AssemblyVersion>
3535
</PropertyGroup>
3636

37-
38-
<ItemGroup>
37+
<PropertyGroup>
38+
<Nullable>enable</Nullable>
39+
</PropertyGroup>
40+
41+
42+
<ItemGroup>
3943
<!--https://github.com/dotnet/reproducible-builds-->
4044
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.25">
4145
<PrivateAssets>all</PrivateAssets>

Test_Numerics/Data/Paired Data/Test_PairedData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Test_PairedData()
6666
_dataset1 = new OrderedPairedData(xVals, yVals, true, SortOrder.Ascending, true, SortOrder.Ascending);
6767
_dataset2 = new OrderedPairedData(Enumerable.Reverse(xVals).ToArray(), yVals, true, SortOrder.Descending, true, SortOrder.Ascending);
6868
_dataset3 = new OrderedPairedData(xVals, Enumerable.Reverse(yVals).ToArray(), true, SortOrder.Ascending, true, SortOrder.Descending);
69-
_dataset4 = new OrderedPairedData(Enumerable.Reverse(xVals).ToArray(), yVals.Reverse().ToArray(), true, SortOrder.Descending, true, SortOrder.Descending);
69+
_dataset4 = new OrderedPairedData(Enumerable.Reverse(xVals).ToArray(), Enumerable.Reverse(yVals).ToArray(), true, SortOrder.Descending, true, SortOrder.Descending);
7070
}
7171

7272
/// <summary>

Test_Numerics/Data/Paired Data/Test_UncertainOrdinate.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ public void Test_Construction()
8585
// Also testing overloaded equality operators
8686
Assert.IsTrue(unordinate1 == unordinate3);
8787
Assert.IsTrue(unordinate1 == unordinate2);
88-
Assert.AreEqual(unordinate1.X, 2);
89-
Assert.AreEqual(unordinate1.Y, distribution);
90-
Assert.AreEqual(unordinate3.X, 2);
88+
Assert.AreEqual(2,unordinate1.X);
89+
Assert.AreEqual(distribution, unordinate1.Y);
90+
Assert.AreEqual(2,unordinate3.X );
9191
Assert.IsTrue(unordinate3.Y == distribution);
9292

93-
Assert.AreEqual(unordinate1.IsValid, true);
94-
Assert.AreEqual(unordinate4.IsValid, false);
95-
Assert.AreEqual(unordinate5.IsValid, false);
93+
Assert.IsTrue(unordinate1.IsValid );
94+
Assert.IsFalse(unordinate4.IsValid);
95+
Assert.IsFalse(unordinate5.IsValid);
9696

9797
Assert.IsTrue(unordinate1 != unordinate4);
9898
Assert.IsTrue(unordinate1 != unordinate5);

Test_Numerics/Data/Statistics/Test_GoodnessOfFit.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -826,11 +826,11 @@ public void Test_MetricsConsistency_GoodModel()
826826
double RSR = GoodnessOfFit.RSR(observed, modeled);
827827

828828
// Good model expectations
829-
Assert.IsTrue(NSE > 0.9, "NSE should be > 0.9 for a good model");
830-
Assert.IsTrue(KGE > 0.9, "KGE should be > 0.9 for a good model");
831-
Assert.IsTrue(RMSE < 5.0, "RMSE should be low for a good model");
832-
Assert.IsTrue(Math.Abs(PBIAS) < 5.0, "PBIAS should be low for a good model");
833-
Assert.IsTrue(RSR < 0.5, "RSR should be < 0.5 for a good model");
829+
Assert.IsGreaterThan(0.9, NSE);
830+
Assert.IsGreaterThan(0.9, KGE);
831+
Assert.IsLessThan(5.0, RMSE);
832+
Assert.IsLessThan(5.0, Math.Abs(PBIAS));
833+
Assert.IsLessThan(0.5, RSR);
834834
}
835835

836836
/// <summary>
@@ -854,12 +854,12 @@ public void Test_MetricsConsistency_PoorModel()
854854
// - RMSE equals the standard deviation of observations
855855
// - RSR should be exactly 1.0 (RMSE / StdDev)
856856

857-
Assert.IsTrue(NSE <= 0.05, $"NSE should be near 0 for constant-at-mean prediction, got {NSE}");
857+
Assert.IsLessThanOrEqualTo(0.05, NSE);
858858

859859
// KGE returns -10.0 for zero-variance predictions (degenerate case)
860-
Assert.IsTrue(KGE < -5.0, $"KGE should be very poor for constant predictions (zero variance), got {KGE}");
860+
Assert.IsLessThan(-5.0, KGE);
861861

862-
Assert.IsTrue(RMSE > 15.0, "RMSE should be high for a poor model");
862+
Assert.IsGreaterThan(15.0, RMSE);
863863
Assert.IsTrue(RSR >= 0.95 && RSR <= 1.05, $"RSR should be approximately 1.0 for constant-at-mean prediction, got {RSR}");
864864
}
865865

Test_Numerics/Data/Time Series/Test_TimeSeriesDownload.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public class Test_TimeSeriesDownload
146146
private static void AssertDailySeriesMonotonic(TimeSeries ts)
147147
{
148148
Assert.IsNotNull(ts, "Time series is null.");
149-
Assert.IsTrue(ts.Count > 0, "Time series is empty.");
149+
Assert.IsGreaterThan( 0, ts.Count);
150150

151151
DateTime? prev = null;
152152
foreach (var pt in ts)
@@ -177,7 +177,7 @@ private static void AssertRoughlyEqual(double a, double b, double relTol = 1e-6,
177177
if (denom == 0)
178178
Assert.IsLessThanOrEqualTo(absTol,diff);
179179
else
180-
Assert.IsTrue(diff / denom <= relTol, $"Values differ: {a} vs {b}");
180+
Assert.IsLessThanOrEqualTo(relTol, diff / denom);
181181
}
182182

183183
#endregion
@@ -572,7 +572,7 @@ public async Task BOM_WindowedDownload_Works()
572572
startDate: WinStart, endDate: WinEnd);
573573

574574
Assert.IsNotNull(ts, "Time series is null.");
575-
Assert.IsTrue(ts.Count > 0, "Time series is empty.");
575+
Assert.IsGreaterThan(0, ts.Count);
576576

577577
// Verify data is within requested window (allowing for some timezone flexibility)
578578
var firstDate = ts.First().Index;

Test_Numerics/Distributions/Univariate/Test_EmpiricalDistribution.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public void Test_ConvolveFiveDistributions()
259259
var convolved = EmpiricalDistribution.Convolve(distributions, 1024);
260260

261261
// Assert number of points
262-
Assert.AreEqual(1024, convolved.XValues.Count, "Should have exactly 1024 points");
262+
Assert.HasCount(1024, convolved.XValues);
263263

264264
// Expected: Range ≈ [0, 10], Mean ≈ 5
265265
Assert.AreEqual(0.0, convolved.Minimum, 0.2, "Minimum should be approximately 0");

Test_Numerics/Mathematics/Optimization/Dynamic/BinaryHeapTesting.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void HeapTest4()
143143
//Compare
144144
for (int i = 0; i < weights.Length; i++)
145145
{
146-
Assert.AreEqual(heap.RemoveMin().Value == weights[i], false);
146+
Assert.AreNotEqual(heap.RemoveMin().Value , weights[i]);
147147
}
148148
}
149149

Test_Numerics/Mathematics/Optimization/Dynamic/DijkstraTesting.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public void SimpleEdgeGraphCost()
5252

5353
float[,] result = Dijkstra.Solve(edges, 3,6);
5454

55-
Assert.AreEqual(result[3, 2], 0f);
56-
Assert.AreEqual(result[2, 2], 3f);
57-
Assert.AreEqual(result[1, 2], 4f);
58-
Assert.AreEqual(result[0, 2], 6f);
59-
Assert.AreEqual(result[4, 2], 7f);
55+
Assert.AreEqual(0f, result[3, 2]);
56+
Assert.AreEqual(3f, result[2, 2]);
57+
Assert.AreEqual(4f, result[1, 2]);
58+
Assert.AreEqual(6f, result[0, 2]);
59+
Assert.AreEqual(7f, result[4, 2]);
6060
Assert.IsTrue(float.IsPositiveInfinity(result[5,2]));
6161

6262
}
@@ -117,11 +117,11 @@ public void SimpleNetworkRouting()
117117

118118
float[,] result = Dijkstra.Solve(edges,9);
119119

120-
Assert.AreEqual(result[0, 0], 5f); //Algorithm is choosing the next node that yields the shortest paths
121-
Assert.AreEqual(result[0, 2], 8f);
120+
Assert.AreEqual(5f, result[0, 0]); //Algorithm is choosing the next node that yields the shortest paths
121+
Assert.AreEqual(8f, result[0, 2]);
122122

123-
Assert.AreEqual(result[1, 0], 7);
124-
Assert.AreEqual(result[1, 2], 5);
123+
Assert.AreEqual(7, result[1, 0]);
124+
Assert.AreEqual(5, result[1, 2]);
125125

126126
Assert.AreEqual(1, result[2, 0]);
127127
Assert.AreEqual(6, result[2, 2]);
@@ -241,10 +241,10 @@ public void MultipleDestSharedPath()
241241

242242
var result = Dijkstra.Solve(edges, [0,3],4);
243243

244-
Assert.AreEqual(result[1, 0], 0);
245-
Assert.AreEqual(result[1, 2], 3);
246-
Assert.AreEqual(result[2, 0], 1);
247-
Assert.AreEqual(result[2, 2], 5);
244+
Assert.AreEqual(0, result[1, 0]);
245+
Assert.AreEqual(3, result[1, 2]);
246+
Assert.AreEqual(1, result[2, 0]);
247+
Assert.AreEqual(5, result[2, 2]);
248248
}
249249

250250
/// <summary>
@@ -262,10 +262,10 @@ public void DisconnectedComponent()
262262
new Edge(2,3,1,2)
263263
};
264264
var result = Dijkstra.Solve(edges, [0, 3], 4);
265-
Assert.AreEqual(result[1,0],0);
266-
Assert.AreEqual(result[1, 2], 3);
267-
Assert.AreEqual(result[2, 0], 3);
268-
Assert.AreEqual(result[2, 2], 1);
265+
Assert.AreEqual(0, result[1, 0]);
266+
Assert.AreEqual(3, result[1, 2]);
267+
Assert.AreEqual(3, result[2, 0]);
268+
Assert.AreEqual(1, result[2, 2]);
269269
}
270270

271271
/// <summary>
@@ -304,11 +304,11 @@ public void TrianglePath()
304304
};
305305

306306
var result = Dijkstra.Solve(edges, [0, 2], 3);
307-
Assert.AreEqual(result[0, 0], 0);
308-
Assert.AreEqual(result[0, 2], 0);
309-
Assert.AreEqual(result[1, 0], 2);
310-
Assert.AreEqual(result[1, 2], 1);
311-
Assert.AreEqual(result[2, 0], 2);
307+
Assert.AreEqual(0, result[0, 0]);
308+
Assert.AreEqual(0, result[0, 2]);
309+
Assert.AreEqual(2, result[1, 0]);
310+
Assert.AreEqual(1, result[1, 2]);
311+
Assert.AreEqual(2, result[2, 0]);
312312
}
313313
}
314314
}

0 commit comments

Comments
 (0)