Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Download tests/test_diarization_table.py from treble-technologies/ffasr: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/treble-technologies/ffasr/resolve/main/tests/test_diarization_table.py
- Command line
-
hf download hf://spaces/treble-technologies/ffasr/tests/test_diarization_table.py
-
curl -L -o test_diarization_table.py https://huggingface.co/spaces/treble-technologies/ffasr/resolve/main/tests/test_diarization_table.py
1.5 kB
| """Diarization table: missing cells rank last; displayed numbers stay numeric.""" | |
| from diarization_config import CONDITION_KEYS, metric_column | |
| from diarization_results import ( | |
| MODEL_COL, | |
| PARAMS_COL, | |
| RANK_COL, | |
| RTF_COL, | |
| build_table, | |
| overall_col_name, | |
| ) | |
| def _complete(model_id: str, der: float) -> dict: | |
| row = { | |
| "model_id": model_id, | |
| "eval_family": "pyannote", | |
| "eval_rtf": "10.55", | |
| "num_params": "1234000000", | |
| } | |
| for key in CONDITION_KEYS: | |
| row[metric_column("der", key)] = str(der) | |
| row[metric_column("jer", key)] = str(der) | |
| return row | |
| def test_missing_cells_rank_last_and_numbers_are_rounded(): | |
| partial = {"model_id": "someone/partial-run", "eval_family": "nemo", "eval_rtf": "3"} | |
| partial[metric_column("der", CONDITION_KEYS[0])] = "0.01" | |
| frame = build_table( | |
| [ | |
| partial, | |
| _complete("good/model", 0.2), | |
| _complete("best/model", 0.1), | |
| ] | |
| ) | |
| models = list(frame[MODEL_COL]) | |
| assert "best/model" in models[0] | |
| assert "good/model" in models[1] | |
| assert "partial-run" in models[2] | |
| assert list(frame[RANK_COL])[:2] == [1, 2] | |
| assert frame[RANK_COL].isna().iloc[2] | |
| der_col = overall_col_name("der") | |
| assert frame[der_col].iloc[0] == 10.0 | |
| assert frame[RTF_COL].iloc[0] == 10.6 | |
| assert frame[PARAMS_COL].iloc[0] == 1.23 | |
| assert str(frame[der_col].dtype) == "Float64" | |
| assert str(frame[RTF_COL].dtype) == "Float64" | |