BUG: sqrtm dtype
See original GitHub issueDescribe your issue.
sqrtm
does not pass through np.float32
for single precision input. I think the behavior changed starting at 1.6.
Reporting after a debugging session (the joys of mysteriously mixing dtypes in numerical code, 😂 ).
It’s not a terrible bug or anything, but I’d like to know if this was intentional or will be changed.
I have seen this on multiple platforms now that I narrowed it down.
I really appreciate your software. Thanks!
Reproducing Code Example
Python 3.7.11 (default, Jul 27 2021, 07:03:16)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import scipy.linalg as la
>>> la.sqrtm(np.zeros((10,10),dtype=np.float32)).dtype
dtype('float64')
>>>
# Old behavior:
Python 3.6.13 |Anaconda, Inc.| (default, Feb 23 2021, 12:58:59)
[GCC Clang 10.0.0 ] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import numpy as np
>>> import scipy.linalg as la
>>> la.sqrtm(np.zeros((10,10),dtype=np.float32)).dtype
dtype(‘float32’)
Error message
See code example for differing dtype.
SciPy/NumPy/Python version information
1.6.1 1.21.2 sys.version_info(major=3, minor=7, micro=11, releaselevel=‘final’, serial=0)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to handle that error in pytorch: expected Long but found ...
Show activity on this post. just change the tensor type as follows x = torch.tensor([[1,-12],[0,4]],dtype=torch.float) sqrtm(x).
Read more >tf.linalg.sqrtm | TensorFlow v2.11.0
Computes the matrix square root of one or more square matrices:
Read more >scipy.linalg.sqrtm — SciPy v1.9.3 Manual
Returns. sqrtm(N, N) ndarray. Value of the sqrt function at A. errestfloat. (if disp == False). Frobenius norm of the estimated error, ||err||_F...
Read more >numpy.sqrt — NumPy v1.24 Manual
numpy.sqrt(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'sqrt'>#.
Read more >https://afni.nimh.nih.gov/pub/dist/bin/macosx_10.7...
dtype = mdp.numx.dtype(dtype) if array.dtype == dtype: return array return ... lo-1:hi] w = w[lo-1:hi] return w, Z def sqrtm(A): """This is a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah we are busted 😃 Thanks @garrettwrong for the report. This is something we briefly discussed way back when and unfortunately went float64-only to ease up the Cythonization effort. But you are right that we need some sort of a unification. As usual I am going waaaay behind of my promises such as #12838 thus the intention is most definitely there but commitments are not in par with them. Sorry about this. I really want to get to this as soon as our work over linalg.solve materializes.
Argh, I don’t think we can make it to 1.9.0 I have the PR ready but didn’t finish all the tests regarding the nd array inputs