Skip to content

Commit d0265af

Browse files
authored
Merge pull request #128 from USACE-RMC/testFix
whitespace
2 parents 649b625 + 377ff60 commit d0265af

12 files changed

Lines changed: 69 additions & 61 deletions

File tree

Numerics/Data/Interpolation/Bilinear.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
3132
using Numerics.Distributions;
3233
using System;
3334
using System.Linq;
@@ -56,6 +57,7 @@ namespace Numerics.Data
5657
/// <see href="https://en.wikipedia.org/wiki/Bilinear_interpolation"/>
5758
/// </para>
5859
/// </remarks>
60+
5961
[Serializable]
6062
public class Bilinear
6163
{

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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public Test_PairedData()
6464
double[] xVals = new double[] { 230408, 288010, 345611, 403213, 460815, 518417, 576019, 633612, 691223, 748825, 806427, 864029, 921631, 1036834, 1152038 };
6565
double[] yVals = new double[] { 1519.7, 1520.5, 1520.9, 1521.7, 1523.5, 1525.9, 1528.4, 1530.9, 1533.2, 1534.7, 1535.9, 1538, 1541.3, 1547.7, 1552.7 };
6666
_dataset1 = new OrderedPairedData(xVals, yVals, true, SortOrder.Ascending, true, SortOrder.Ascending);
67-
_dataset2 = new OrderedPairedData(xVals.Reverse().ToArray(), yVals, true, SortOrder.Descending, true, SortOrder.Ascending);
68-
_dataset3 = new OrderedPairedData(xVals, yVals.Reverse().ToArray(), true, SortOrder.Ascending, true, SortOrder.Descending);
69-
_dataset4 = new OrderedPairedData(xVals.Reverse().ToArray(), yVals.Reverse().ToArray(), true, SortOrder.Descending, true, SortOrder.Descending);
67+
_dataset2 = new OrderedPairedData(Enumerable.Reverse(xVals).ToArray(), yVals, true, SortOrder.Descending, true, SortOrder.Ascending);
68+
_dataset3 = new OrderedPairedData(xVals, Enumerable.Reverse(yVals).ToArray(), true, SortOrder.Ascending, 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>
@@ -184,12 +184,12 @@ public void Test_Indexing()
184184

185185
dataset11.Remove(ordinate);
186186
bool test4 = dataset11.Contains(ordinate);
187-
Assert.AreEqual(false, test4);
187+
Assert.IsFalse(test4);
188188

189189
Ordinate newOrdinate = dataset11[4];
190190
dataset11.RemoveAt(4);
191191
bool test5 = dataset11.Contains(newOrdinate);
192-
Assert.AreEqual(false, test5);
192+
Assert.IsFalse(test5);
193193

194194
Ordinate newOrdinate2 = new Ordinate(1243177, 1563.8);
195195
dataset11.Add(newOrdinate2);

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/Paired Data/Test_UncertainPairedData.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public Test_UncertainPairedData()
6868
UnivariateDistributionBase[] yVals = new UnivariateDistributionBase[] { new Triangular(1, 2, 3), new Triangular(2, 4, 5), new Triangular(6, 8, 12), new Triangular(13, 19, 20) };
6969

7070
_dataset1 = new UncertainOrderedPairedData(xVals, yVals, true, SortOrder.Ascending, true, SortOrder.Ascending, UnivariateDistributionType.Triangular);
71-
_dataset2 = new UncertainOrderedPairedData(xVals.Reverse().ToArray(), yVals, true, SortOrder.Descending, true, SortOrder.Ascending, UnivariateDistributionType.Triangular);
72-
_dataset3 = new UncertainOrderedPairedData(xVals, yVals.Reverse().ToArray(), true, SortOrder.Ascending, true, SortOrder.Descending, UnivariateDistributionType.Triangular);
73-
_dataset4 = new UncertainOrderedPairedData(xVals.Reverse().ToArray(), yVals.Reverse().ToArray(), true, SortOrder.Descending, true, SortOrder.Descending, UnivariateDistributionType.Triangular);
71+
_dataset2 = new UncertainOrderedPairedData(Enumerable.Reverse(xVals).ToArray(), yVals, true, SortOrder.Descending, true, SortOrder.Ascending, UnivariateDistributionType.Triangular);
72+
_dataset3 = new UncertainOrderedPairedData(xVals, Enumerable.Reverse(yVals).ToArray(), true, SortOrder.Ascending, true, SortOrder.Descending, UnivariateDistributionType.Triangular);
73+
_dataset4 = new UncertainOrderedPairedData(Enumerable.Reverse(xVals).ToArray(), Enumerable.Reverse(yVals).ToArray(), true, SortOrder.Descending, true, SortOrder.Descending, UnivariateDistributionType.Triangular);
7474
}
7575

7676
/// <summary>
@@ -112,9 +112,9 @@ public void Test_CurveSample()
112112
double[] yMeanVals = new double[] { 2, 3.66667, 8.66667, 17.33333 };
113113

114114
var data1Expected = new OrderedPairedData(xVals, yMeanVals, true, SortOrder.Ascending, true, SortOrder.Ascending);
115-
var data2Expected = new OrderedPairedData(xVals.Reverse().ToArray(), yMeanVals, true, SortOrder.Descending, true, SortOrder.Ascending);
116-
var data3Expected = new OrderedPairedData(xVals, yMeanVals.Reverse().ToArray(), true, SortOrder.Ascending, true, SortOrder.Descending);
117-
var data4Expected = new OrderedPairedData(xVals.Reverse().ToArray(), yMeanVals.Reverse().ToArray(), true, SortOrder.Descending, true, SortOrder.Descending);
115+
var data2Expected = new OrderedPairedData(Enumerable.Reverse(xVals).ToArray(), yMeanVals, true, SortOrder.Descending, true, SortOrder.Ascending);
116+
var data3Expected = new OrderedPairedData(xVals, Enumerable.Reverse(yMeanVals).ToArray(), true, SortOrder.Ascending, true, SortOrder.Descending);
117+
var data4Expected = new OrderedPairedData(Enumerable.Reverse(xVals).ToArray(), Enumerable.Reverse(yMeanVals).ToArray(), true, SortOrder.Descending, true, SortOrder.Descending);
118118

119119
for (int i = 0; i < data1.Count; i++)
120120
{
@@ -153,9 +153,9 @@ public void Test_Curve_Sample_Probability()
153153
double[] yInverseVals = new double[] { 2, 3.732051, 8.535898, 17.58258 };
154154

155155
var data1Expected = new OrderedPairedData(xVals, yInverseVals, true, SortOrder.Ascending, true, SortOrder.Ascending);
156-
var data2Expected = new OrderedPairedData(xVals.Reverse().ToArray(), yInverseVals, true, SortOrder.Descending, true, SortOrder.Ascending);
157-
var data3Expected = new OrderedPairedData(xVals, yInverseVals.Reverse().ToArray(), true, SortOrder.Ascending, true, SortOrder.Descending);
158-
var data4Expected = new OrderedPairedData(xVals.Reverse().ToArray(), yInverseVals.Reverse().ToArray(), true, SortOrder.Descending, true, SortOrder.Descending);
156+
var data2Expected = new OrderedPairedData(Enumerable.Reverse(xVals).ToArray(), yInverseVals, true, SortOrder.Descending, true, SortOrder.Ascending);
157+
var data3Expected = new OrderedPairedData(xVals, Enumerable.Reverse(yInverseVals).ToArray(), true, SortOrder.Ascending, true, SortOrder.Descending);
158+
var data4Expected = new OrderedPairedData(Enumerable.Reverse(xVals).ToArray(), Enumerable.Reverse(yInverseVals).ToArray(), true, SortOrder.Descending, true, SortOrder.Descending);
159159

160160
for (int i = 0; i < data1.Count; i++)
161161
{
@@ -189,12 +189,12 @@ public void Test_IList()
189189
// Test Remove and Contains
190190
pairedData.Remove(ordinate);
191191
bool test2 = pairedData.Contains(ordinate);
192-
Assert.AreEqual(false, test2);
192+
Assert.IsFalse(test2);
193193

194194
// Test RemoveAt and Contains
195195
pairedData.RemoveAt(2);
196196
bool test3 = pairedData.Contains(ordinate);
197-
Assert.AreEqual(false, test3);
197+
Assert.IsFalse(test3);
198198

199199
// Test Insert and IndexOf
200200
pairedData.Insert(2, ordinate);

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: 4 additions & 4 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)
@@ -175,9 +175,9 @@ private static void AssertRoughlyEqual(double a, double b, double relTol = 1e-6,
175175

176176
double denom = Math.Max(Math.Abs(a), Math.Abs(b));
177177
if (denom == 0)
178-
Assert.IsTrue(diff <= absTol);
178+
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

0 commit comments

Comments
 (0)