Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

Addresses code review feedback requesting test coverage for the VectorUtils module (magnitude, inner, normalize, normalizeNumberArray).

Test Coverage Added

52 test cases covering:

  • magnitude() - L2 norm calculation across Float16/32/64Array, Int8/16Array, Uint8/16Array, number arrays; zero vectors, negative values, large vectors
  • inner() - Dot product for all typed array types; orthogonal vectors, zero vectors
  • normalize() - Unit length normalization with type preservation; Float16Array → Float32Array conversion; zero vector handling via throwOnZero parameter
  • normalizeNumberArray() - Number array normalization; immutability verification; zero vector handling

Edge cases tested: zero vectors, single elements, negative/mixed values, already normalized inputs, large vectors (1000 elements).

// Example test structure
test("should normalize Float32Array to unit length", () => {
  const vector = new Float32Array([3, 4]);
  const result = normalize(vector);
  expect(result).toBeInstanceOf(Float32Array);
  expect(magnitude(result)).toBeCloseTo(1, 5);
});

test("should throw error for zero vector by default", () => {
  const vector = new Float32Array([0, 0, 0]);
  expect(() => normalize(vector)).toThrow("Cannot normalize a zero vector.");
});

Tests follow repository's vitest patterns. CI will validate execution.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Address feedback on VectorQuantizeTask and VectorSimilarityTask Add test coverage for VectorUtils module Jan 4, 2026
Copilot AI requested a review from sroussey January 4, 2026 01:03
@sroussey sroussey closed this Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants