(t *testing.T)
| 129 | } |
| 130 | |
| 131 | func TestWrappedRecordCosine(t *testing.T) { |
| 132 | a := WrapRecord(&pb.Record{Data: []float32{3, 6, 9}}) |
| 133 | b := WrapRecord(&pb.Record{Data: []float32{0, 0, 0}}) |
| 134 | if cos := a.Cosine(b); cos != 0.0 { |
| 135 | t.Fatalf("cosine similarity should be %f, got %f", 0.0, cos) |
| 136 | } |
| 137 | |
| 138 | b.SetData(a.record.Data) |
| 139 | if cos := a.Cosine(b); cos != 1.0 { |
| 140 | t.Fatalf("cosine similarity should be %f, got %f", 1.0, cos) |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | func TestWrappedRecordCosineWithNull(t *testing.T) { |
| 145 | assertPanic(t, "cosine similarity should panic with null wrapped record", func() { |
nothing calls this directly
no test coverage detected