Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: linalg._qz String formatter syntax error #8178

Merged
merged 2 commits into from
Nov 23, 2017
Merged

Conversation

ilayn
Copy link
Member

@ilayn ilayn commented Nov 20, 2017

In the _qz function the warning has the string formatting command

warnings.warn('.... %d ...' % info -1)

which leads to a TypeError since the argument is not inside brackets. Thus, switched to the "modern" version with '...{}...'.format(info-1).

In the meantime also changed the warning type and set the stacklevel and some housekeeping.

To trigger the problem I've used

a = np.array([[-0.0566335083203545, 0.7618601631045951, 0.1380799881600429,  -0.2496547271520516],
              [-0.6953017686620624, 0.1721825836377841, 0.3524311236692528,  -0.0976480305217913],
              [-0.2778527965349485, 0.0822406719680793, 0.3642622234574927,  0.4324046824057498],
              [0.1630969211638234, -0.1925663248287017, 0.4859689326072161,  0.5655695646632785]])

b = np.array([[-0.6282702999111819, 0.2566040837956725, -0.0590286999428144,  -0.4484746121151296],
              [ 2.993120574942286,  -3.0140376750215672, -2.4376036127193954,  -0.1083956777260289],
              [-0.3395903200140198, -0.0297149078005973,  0.5974019693416047,   0.3581544256691085],
              [ 0.19152708930348,    2.3546781693565211, -2.1809506731995891,  -3.6531715901566919]])

aa, bb, *_ = sp.linalg.qz(a, b, output='complex')

Some housekeeping and warning fix.
@ilayn ilayn added defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.linalg labels Nov 20, 2017
@@ -78,7 +78,7 @@ def _qz(A, B, output='real', lwork=None, sort=None, overwrite_a=False,
raise ValueError("The 'sort' input of qz() has to be None and will be "
"removed in a future release. Use ordqz instead.")

if output not in ['real', 'complex', 'r', 'c']:
if output.lower() not in ['real', 'complex', 'r', 'c']:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing to e.g. https://github.com/scipy/scipy/blob/v0.18.1/scipy/linalg/decomp_schur.py#L90 it seems that that linalg doesn't always do this. Why do it here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a habit I guess. I can revert it back I really don't mind. Just picked up from some tutorial a while back which stayed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not like it's a big deal. But maybe if it is to be changed it would be better to them all at once.

@ilayn
Copy link
Member Author

ilayn commented Nov 23, 2017

I've cancelled the build and if you don't have other comments, I'm leaning towards merging this.

@ilayn ilayn merged commit 5f41f93 into scipy:master Nov 23, 2017
@ilayn ilayn deleted the qz_typo branch November 23, 2017 11:37
@ilayn ilayn added this to the 1.1.0 milestone Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.linalg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants