question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe 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:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
ilayncommented, Oct 14, 2021

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.

0reactions
ilayncommented, Jul 5, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found