MCPcopy Create free account
hub / github.com/evilsocket/sum / TestWrappedRecordCosine

Function TestWrappedRecordCosine

wrapper/record_test.go:131–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

129}
130
131func 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
144func TestWrappedRecordCosineWithNull(t *testing.T) {
145 assertPanic(t, "cosine similarity should panic with null wrapped record", func() {

Callers

nothing calls this directly

Calls 3

WrapRecordFunction · 0.85
CosineMethod · 0.80
SetDataMethod · 0.80

Tested by

no test coverage detected