candding 0.1.0

Pure candle embeddings for Rust with no ONNX: dense, sparse, multi-vector and rerank models today, image models on the roadmap
Documentation
use super::*;

#[test]
fn an_empty_embedding_still_reports_its_declared_width() {
  let embedding = MultiVectorEmbedding::from_rows(5, Vec::<Vec<f32>>::new());
  assert_eq!(embedding.dim(), 5);
  assert_eq!(embedding.row_count(), 0);
  assert!(embedding.is_empty());
  assert_eq!(embedding.rows().count(), 0);
}

#[test]
fn rows_come_back_in_construction_order() {
  let embedding = MultiVectorEmbedding::from_rows(2, [vec![1.0, 2.0], vec![3.0, 4.0]]);
  assert_eq!(embedding.row_count(), 2);
  assert!(!embedding.is_empty());
  let rows: Vec<Vec<f32>> = embedding.rows().map(<[f32]>::to_vec).collect();
  assert_eq!(rows, vec![vec![1.0, 2.0], vec![3.0, 4.0]]);
}

#[test]
#[should_panic(expected = "has 3 components, expected 2")]
fn from_rows_panics_on_a_row_of_the_wrong_width() {
  MultiVectorEmbedding::from_rows(2, [vec![1.0, 2.0, 3.0]]);
}

/// `rows()` uses `chunks(dim.max(1))` so a zero-width embedding does not panic on `chunks(0)`.
#[test]
fn a_zero_width_embedding_iterates_zero_rows_without_panicking() {
  let embedding = MultiVectorEmbedding::from_rows(0, Vec::<Vec<f32>>::new());
  assert_eq!(embedding.dim(), 0);
  assert_eq!(embedding.rows().count(), 0);
}

mod scoring;