github.com/weaviate/weaviate@v1.24.6/test/helper/distance.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package helper
    13  
    14  import (
    15  	"testing"
    16  
    17  	"github.com/weaviate/weaviate/entities/additional"
    18  )
    19  
    20  func CertaintyToDist(t *testing.T, in float32) float32 {
    21  	asFloat64 := float64(in)
    22  	dist := additional.CertaintyToDistPtr(&asFloat64)
    23  	if dist == nil {
    24  		t.Fatalf(
    25  			"somehow %+v of type %T failed to produce a non-null *float64", in, in)
    26  	}
    27  	return float32(*dist)
    28  }