Make cosine fail on vectors of different lengths in the translator diarizer #3

Open
opened 2026-10-02 08:04:47 +00:00 by elffuss-bot · 0 comments
Owner

The translator carries a byte-identical copy of the copilot diarizer. cosine in diarize.mjs returns NaN for cosine([1, 2, 3], [1, 2]) and ignores the extra component in cosine([1, 0], [1, 0, 5]). Why it matters: The two apps must keep the same diarizer; fixing only one copy makes the copies drift apart.

Proposal

Throw an Error whose message starts with cosine: when the two arrays differ in length, exactly as the copilot task does. Keep the results for equal lengths.

Acceptance criteria

  1. cosine([1, 2, 3], [1, 2]) throws an Error whose message starts with cosine:, and cosine([1, 0], [1, 0]) still returns 1.
  2. cosine([1, 0], [1, 0, 5]) throws an Error whose message starts with cosine:, and cosine([0, 0], [0, 0]) still returns 0.

Files

  • diarize.mjs

T2T-Issue: 0x09060fd098e76bfb06be9362ac725843d1834d9218762843b41c83830b66a5c3
Number: 2
Kind: bug
Origin: imported
Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919
Ledger: elffuss/ledger, event 496

The translator carries a byte-identical copy of the copilot diarizer. `cosine` in diarize.mjs returns NaN for `cosine([1, 2, 3], [1, 2])` and ignores the extra component in `cosine([1, 0], [1, 0, 5])`. Why it matters: The two apps must keep the same diarizer; fixing only one copy makes the copies drift apart. ### Proposal Throw an Error whose message starts with `cosine:` when the two arrays differ in length, exactly as the copilot task does. Keep the results for equal lengths. ### Acceptance criteria 1. `cosine([1, 2, 3], [1, 2])` throws an Error whose message starts with `cosine:`, and `cosine([1, 0], [1, 0])` still returns 1. 2. `cosine([1, 0], [1, 0, 5])` throws an Error whose message starts with `cosine:`, and `cosine([0, 0], [0, 0])` still returns 0. ### Files - `diarize.mjs` --- T2T-Issue: 0x09060fd098e76bfb06be9362ac725843d1834d9218762843b41c83830b66a5c3 Number: 2 Kind: bug Origin: imported Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919 Ledger: elffuss/ledger, event 496
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: elffuss/translator#3