|
1 | 1 | // Copyright (c) Microsoft. All rights reserved. |
2 | 2 |
|
3 | 3 | using System.Collections; |
4 | | -#if NET8_0_OR_GREATER |
5 | 4 | using Microsoft.Extensions.AI; |
6 | | -#endif |
7 | 5 | using Microsoft.Extensions.VectorData; |
8 | 6 | using Pgvector; |
9 | 7 | using PgVector.ConformanceTests.Support; |
@@ -41,16 +39,27 @@ public virtual Task Array_of_Half() |
41 | 39 | new ReadOnlyMemoryEmbeddingGenerator<Half>([(byte)1, (byte)2, (byte)3])); |
42 | 40 | #endif |
43 | 41 |
|
44 | | - // TODO: Figure out the embedding generation story for binaryvec/sparsevec - need an Embedding wrapper |
45 | | - |
46 | 42 | [ConditionalFact] |
47 | 43 | public virtual Task BitArray() |
48 | | - => this.Test<BitArray>(new BitArray(new bool[] { true, false, true }), distanceFunction: DistanceFunction.HammingDistance, embeddingGenerator: null); |
| 44 | + => this.Test<BitArray>( |
| 45 | + new BitArray([true, false, true]), |
| 46 | + new BinaryEmbeddingGenerator(new BitArray([true, false, true])), |
| 47 | + distanceFunction: DistanceFunction.HammingDistance); |
| 48 | + |
| 49 | + [ConditionalFact] |
| 50 | + public virtual Task BinaryEmbedding() |
| 51 | + => this.Test<BinaryEmbedding>( |
| 52 | + new BinaryEmbedding(new([true, false, true])), |
| 53 | + new BinaryEmbeddingGenerator(new BitArray([true, false, true])), |
| 54 | + distanceFunction: DistanceFunction.HammingDistance, |
| 55 | + vectorEqualityAsserter: (e, a) => Assert.Equal(e.Vector, a.Vector)); |
49 | 56 |
|
50 | 57 | [ConditionalFact] |
51 | 58 | public virtual Task SparseVector() |
52 | 59 | => this.Test<SparseVector>(new SparseVector(new ReadOnlyMemory<float>([1, 2, 3])), embeddingGenerator: null); |
53 | 60 |
|
| 61 | + // TODO: Figure out the embedding generation story for sparsevec - need an Embedding wrapper |
| 62 | + |
54 | 63 | public new class Fixture : EmbeddingTypeTests<int>.Fixture |
55 | 64 | { |
56 | 65 | public override TestStore TestStore => PostgresTestStore.Instance; |
|
0 commit comments