Documentation
¶
Overview ¶
Package vector owns finite numeric coordinates and their JSON representation. Embedding models and vector stores share these values; dimensions, metrics, encoder-space identity, and operation errors belong to their consuming domain. Float32 narrows values at the native storage boundary, whose precision and magnitude constraints determine whether the projection can be indexed.
Example ¶
package main
import (
jsonv2 "encoding/json/v2"
"errors"
"fmt"
"github.com/Tangerg/scope/core/vector"
)
func main() {
var coordinates vector.Coordinates[float64]
if err := jsonv2.Unmarshal([]byte(`[0,1.5]`), &coordinates); err != nil {
panic(err)
}
fmt.Println(vector.Float32(coordinates))
err := jsonv2.Unmarshal([]byte(`[1,null]`), &coordinates)
fmt.Println(errors.Is(err, vector.ErrInvalidCoordinates), coordinates)
}
Output: [0 1.5] true [0 1.5]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidCoordinates = errors.New("vector: invalid coordinates")
Functions ¶
Types ¶
type Coordinates ¶
Coordinates contains measured, finite components. JSON null is unknown, so decoding it must not invent a measured zero component.
func (Coordinates[T]) JSONSchemaModel ¶
func (Coordinates[T]) JSONSchemaModel() any
func (Coordinates[T]) MarshalJSON ¶
func (c Coordinates[T]) MarshalJSON() ([]byte, error)
func (*Coordinates[T]) UnmarshalJSON ¶
func (c *Coordinates[T]) UnmarshalJSON(data []byte) error
func (Coordinates[T]) Validate ¶
func (c Coordinates[T]) Validate() error
Click to show internal directories.
Click to hide internal directories.