Reformat / cleanup
This commit is contained in:
@@ -5,7 +5,7 @@ namespace ZB.MOM.WW.CBDD.Tests;
|
||||
public class VectorMathTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies distance calculations across all supported vector metrics.
|
||||
/// Verifies distance calculations across all supported vector metrics.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Distance_Should_Cover_All_Metrics()
|
||||
@@ -13,19 +13,19 @@ public class VectorMathTests
|
||||
float[] v1 = [1f, 2f];
|
||||
float[] v2 = [3f, 4f];
|
||||
|
||||
var cosineDistance = VectorMath.Distance(v1, v2, VectorMetric.Cosine);
|
||||
var l2Distance = VectorMath.Distance(v1, v2, VectorMetric.L2);
|
||||
var dotDistance = VectorMath.Distance(v1, v2, VectorMetric.DotProduct);
|
||||
float cosineDistance = VectorMath.Distance(v1, v2, VectorMetric.Cosine);
|
||||
float l2Distance = VectorMath.Distance(v1, v2, VectorMetric.L2);
|
||||
float dotDistance = VectorMath.Distance(v1, v2, VectorMetric.DotProduct);
|
||||
|
||||
l2Distance.ShouldBe(8f);
|
||||
dotDistance.ShouldBe(-11f);
|
||||
|
||||
var expectedCosine = 1f - (11f / (MathF.Sqrt(5f) * 5f));
|
||||
float expectedCosine = 1f - 11f / (MathF.Sqrt(5f) * 5f);
|
||||
MathF.Abs(cosineDistance - expectedCosine).ShouldBeLessThan(0.0001f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies cosine similarity returns zero when one vector has zero magnitude.
|
||||
/// Verifies cosine similarity returns zero when one vector has zero magnitude.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void CosineSimilarity_Should_Return_Zero_For_ZeroMagnitude_Vector()
|
||||
@@ -37,7 +37,7 @@ public class VectorMathTests
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies dot product throws for mismatched vector lengths.
|
||||
/// Verifies dot product throws for mismatched vector lengths.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DotProduct_Should_Throw_For_Length_Mismatch()
|
||||
@@ -49,7 +49,7 @@ public class VectorMathTests
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies squared Euclidean distance throws for mismatched vector lengths.
|
||||
/// Verifies squared Euclidean distance throws for mismatched vector lengths.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void EuclideanDistanceSquared_Should_Throw_For_Length_Mismatch()
|
||||
@@ -59,4 +59,4 @@ public class VectorMathTests
|
||||
|
||||
Should.Throw<ArgumentException>(() => VectorMath.EuclideanDistanceSquared(v1, v2));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user