| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
* pin numpy to < 2.0 * update numpy pin in requirements.txt * fix SVD in stitch with scipy>=1.11.0 * speedup check if matrix contains only zeros * improve readability
|
As a user and downstream packager, I would just like to ask why numpy is being pinned to less than 2? In my experience it has been quite "smooth" all things considered to transition to numpy2 for python packages. Tensorflow also just released a version compatible with numpy2 these last few months (tensorflow 2.18) |
Sorry, something went wrong.
Tracklet stitching estimated a Hankelet's rank from its singular values via scipy.linalg.interpolative.svd. On NumPy 2 that randomized routine raises "array must not contain infs or NaNs" on finite input, so any stitching that computes tracklet affinities fails at runtime. Only the singular values matter, so use np.linalg.svd(compute_uv=False): exact, deterministic, identical on NumPy 1.22.4 and 2. It also returns zeros for an all-zero matrix instead of raising, making the DeepLabCut#2827 guard against scipy>=1.11's all-zero ValueError redundant; it is removed. scipy is removing the backend's noncompliant randomization: scipy/scipy#18367
| Back | FazBrowse Home | New Git URL |
This pull request pins the numpy version required for DeepLabCut to numpy<2.0.0 and fixes SVD computation in Tracklet.estimate_rank for scipy>=1.11.0.
scipy SVD computation
With scipy<1.11.0, computation of the SVD of an all-zero matrix would be successful, returning an all-zero array for the singular values. With scipy>=1.11.0, this fails with a ValueError. Hence, we first check if the matrice is the zero matrix before computing the SVD. If it is, we return a zero-vector to match the behavior of scipy<1.11.0.
This can be verified with the following script:
With scipy==1.10.1 this succeeds with the output:
While with scipy==1.15.0 this fails with the output:
# Installed packages # # Package Version # ---------- ------- # numpy 1.26.4 # pip 24.2 # scipy 1.15.0 # setuptools 75.1.0 # wheel 0.44.0 (10,) [1.00000000e+002 1.97841743e-014 2.33093502e-029 3.08938377e-044 4.24604188e-059 6.43087871e-074 1.13626229e-088 8.36470319e-104 1.62555162e-118 3.13271339e-133] Traceback (most recent call last): File "sktest.py", line 11, in <module> u, s, v = svd(mat, 10) File "/miniconda/envs/sk15/lib/python3.10/site-packages/scipy/linalg/interpolative.py", line 905, in svd U, S, V = _backend.iddr_asvd(A, k, rng=rng) File "_decomp_interpolative.pyx", line 933, in scipy.linalg._decomp_interpolative.iddr_asvd File "/miniconda/envs/sk15/lib/python3.10/site-packages/scipy/linalg/_decomp_svd.py", line 106, in svd a1 = _asarray_validated(a, check_finite=check_finite) File "/miniconda/envs/sk15/lib/python3.10/site-packages/scipy/_lib/_util.py", line 537, in _asarray_validated a = toarray(a) File "/miniconda/envs/sk15/lib/python3.10/site-packages/numpy/lib/function_base.py", line 630, in asarray_chkfinite raise ValueError( ValueError: array must not contain infs or NaNs