Make cosine reject vectors of different lengths in the translator diarizer #1

Open
opened 2026-10-02 06:33:58 +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:.
  2. cosine([1, 0], [1, 0, 5]) throws an Error whose message starts with cosine:.
  3. cosine([1, 0], [1, 0]) returns 1.
  4. cosine([0, 0], [0, 0]) returns 0.

Files

  • diarize.mjs

T2T-Issue: 0x98f19ce946d4ef692a1354cdda7c9c22c3deb8168f1eb224b4d56b790e2ca305
Number: 1
Kind: bug
Origin: imported
Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919
Ledger: elffuss/ledger, event 158

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:`. 2. `cosine([1, 0], [1, 0, 5])` throws an Error whose message starts with `cosine:`. 3. `cosine([1, 0], [1, 0])` returns 1. 4. `cosine([0, 0], [0, 0])` returns 0. ### Files - `diarize.mjs` --- T2T-Issue: 0x98f19ce946d4ef692a1354cdda7c9c22c3deb8168f1eb224b4d56b790e2ca305 Number: 1 Kind: bug Origin: imported Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919 Ledger: elffuss/ledger, event 158
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: elffuss/translator#1