Skip to content

test: add non-zero CER/WER assertions for better metric coverage#16

Open
Julianblock wants to merge 1 commit into
facebookresearch:mainfrom
Julianblock:test/cer-wer-nonzero-coverage
Open

test: add non-zero CER/WER assertions for better metric coverage#16
Julianblock wants to merge 1 commit into
facebookresearch:mainfrom
Julianblock:test/cer-wer-nonzero-coverage

Conversation

@Julianblock

Copy link
Copy Markdown

The existing tests only exercise the zero-error (perfect prediction) branch of the CER torchmetric and the WER helper. Add:

  • test_cer_metric_nonzero: verifies the CER torchmetric returns 0.75 for a prediction of all-class-0 against a [0,1,2,3] reference (3/4 characters wrong), pinning normalisation and accumulation.

  • test_error_rates_nonzero: verifies compute_cer/compute_wer return correct positive values (all words wrong -> WER=1.0, half wrong -> WER=0.5, all chars wrong -> CER=1.0) and that the empty-reference guard still returns NaN.

The existing tests only exercise the zero-error (perfect prediction)
branch of the CER torchmetric and the WER helper. Add:

- test_cer_metric_nonzero: verifies the CER torchmetric returns 0.75
  for a prediction of all-class-0 against a [0,1,2,3] reference
  (3/4 characters wrong), pinning normalisation and accumulation.

- test_error_rates_nonzero: verifies compute_cer/compute_wer return
  correct positive values (all words wrong -> WER=1.0, half wrong ->
  WER=0.5, all chars wrong -> CER=1.0) and that the empty-reference
  guard still returns NaN.
@meta-cla meta-cla Bot added the cla signed label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant