Doctest failures in FID and CalinskiHarabaszScore metrics
🐛 Bug description
Running doctests produces 2 failures:
- In
ignite/metrics/gan/fid.py,scipy.linalg.sqrtm(A, disp=False)no longer returns a tuple in newer versions of scipy (>= 1.12). The current code assumes tuple unpacking:
covmean, _ = scipy.linalg.sqrtm(sigma1.mm(sigma2).numpy(), disp=False)
This raises:
ValueError: not enough values to unpack (expected 2, got 1)
- In
ignite/metrics/clustering/calinski_harabasz_score.py, the doctest testoutput expects an exact float5.733935832977295, but the actual result varies across environments (e.g.,5.733934746005431), causing a mismatch.
Steps to reproduce
cd docs
make html && make doctest
Both failures appear in the doctest output with 2 items had failures.
Environment
- PyTorch Version (e.g., 1.4): 2.10.0+cu128
- Ignite Version (e.g., 0.3.0): 0.6.0
- OS (e.g., Linux): Linux
- How you installed Ignite (
conda,pip, source): source - Python version: 3.12.3
- Any other relevant information: scipy 1.17.0
@TahaZahid05 thanks for the report. Currently doctest on master is passing: http://github.com/pytorch/ignite/actions/runs/22531771286/job/65272114405
@vfdev-5
The reason it passes on master but fails locally is due to the scipy version. Since requirements-dev.txt leaves scipy unpinned, fresh installs get the latest version. In the newer versions, the disp argument in scipy.linalg.sqrtm is deprecated and no longer returns the tuple when disp=False. The same reason applies to scikit-learn. The PR ensures the doctests are forward-compatible with the newer versions of these libraries so users don't get failed doctest errors.
@TahaZahid05 I do not understand, sorry. In the CI on master we should get the latest version and it should fail according to what you say.
@vfdev-5
I think the discrepancy stems from CI caching. In the GitHub actions, setup-uv runs with enable-cache: true keyed to ${{ hashFiles('requirements-dev.txt') }}. Since requirements-dev.txt hasn't changed in terms of code lines, uv is reusing cached, older versions of libraries. Locally, running a pip install fetches the latest versions.
My PR ensures the codebase is forward-compatible with these newer library versions, which CI will eventually hit whenever its cache busts.
This makes sense! We should also add the week number in the cache key like for unit tests: https://github.com/pytorch/ignite/blob/4f42e102cc9c0b3542d5065ae342ee97fdb61197/.github/workflows/unit-tests.yml#L74
So, let's apply this to all the CI jobs where we are using the cache and let's observe the failure
@vfdev-5 done!
@TahaZahid05 where can we see the failure ?
@vfdev-5 , #3612 contained fixes to FID and CalinskiHarabaszScore and updates to CI, which is why it is passing the checks. To show the failure, I have made a temporary PR #3616 . You can approve it so it can run the CI and show the failed doctests as FID and CalinskiHarabaszScore aren't fixed in that PR.
Hi, I opened a PR to fix this issue.
PR: #3620
This handles the scipy sqrtm return change causing doctest failure in FID metric.
Please let me know if any changes are needed.
@AmitEpoch08 there is already a PR by @TahaZahid05 fixing the issue and we discussing the details. Your PR will unlikely to be merged. Please, next time make sure to ask in the issue first before coding and sending a PR. You can work on other "help wanted" issues.