Skip to content

Add test coverage for VBuffer #1804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 3, 2018
Merged

Conversation

yaeldekel
Copy link

Add unit tests for VBuffer operations.
Fixes #1803 .

Copy link
Contributor

@TomFinley TomFinley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, thanks @yaeldekel , that's a lot of tests!

@@ -586,6 +586,14 @@ public static bool AreEqual(Double[] arr1, Double[] arr2)
return true;
}

public static void Shuffle<T>(Random rand, Span<T> rgv)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rgv [](start = 59, length = 3)

just curios, what it stands for?
random general values?

Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -36,6 +36,19 @@ public static class LinqExtensions
return argMax;
}

public static int ArgMax<T>(this ReadOnlySpan<T> span) where T : IComparable<T>
Copy link
Member

@eerhardt eerhardt Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to remove the method above this, since arrays are implicitly convertible to ReadOnlySpan. #Resolved

{
Contracts.Assert(0 <= count && count <= _size);
Contracts.Assert(dst != null);
Contracts.Assert(0 <= index && index <= dst.Length - count);
Array.Copy(Items, _base, dst, index, count);
for (int i = 0; i < count; i++)
Copy link
Member

@eerhardt eerhardt Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think this code is going away with #1657)

You don't need to copy element by element. Instead you can say Items.AsSpan(_base + i, count).CopyTo(dst); #Resolved

};
}

private void AssertAreEqual(float expected, float actual, int tol)
Copy link
Member

@eerhardt eerhardt Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have this method (with different implementation):

public bool CompareNumbersWithTolerance(double expected, double actual, int? iterationOnCollection = null, int digitsOfPrecision = DigitsOfPrecision)

#Resolved

{
var result = equalityFunc(expected.GetValues()[i], actual.GetValues()[i]);
if (!result)
Console.WriteLine("Friendly debug here");
Copy link
Member

@eerhardt eerhardt Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? #Resolved

Array.Sort(indices, 0, count);
for (int i = 0; i < count; ++i)
indices[i] += i;
Contracts.Assert(Utils.IsIncreasing(0, indices, count, len));
Copy link
Member

@eerhardt eerhardt Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use Assert here - that way the tests always fail (even in Release mode). #Resolved

}

[Fact]
public void SparsifyNormalizeTopSparce2()
Copy link
Member

@eerhardt eerhardt Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sparse? #Resolved

}

[Fact]
public void SparsifyNormalizeTopSparce2()
Copy link
Member

@eerhardt eerhardt Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I previously added some SparsifyNormalize tests (since I didn't know these tests existed).

public void TestSparsifyNormalize(int startRange, bool normalize, float[] expectedValues, int[] expectedIndices)

Can you move those two tests here as well? So all the tests that test a specific function are in the same spot? #Resolved

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@yaeldekel yaeldekel merged commit f0fb2a0 into dotnet:master Dec 3, 2018
@yaeldekel yaeldekel deleted the vbuffertests branch December 3, 2018 22:21
@ghost ghost locked as resolved and limited conversation to collaborators Mar 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants