Skip to content

Do not overwrite np = numpy with an array size. #98

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

Closed
wants to merge 1 commit into from
Closed

Do not overwrite np = numpy with an array size. #98

wants to merge 1 commit into from

Conversation

ochurlaud
Copy link

The function failed to be called with python3

The function failed to be called with python3
@coveralls
Copy link

coveralls commented Jun 23, 2016

Coverage Status

Coverage decreased (-0.2%) to 75.764% when pulling 8e6a853 on ochurlaud:patch-1 into 7b07af3 on python-control:master.

@slivingston slivingston self-assigned this Aug 10, 2016
@slivingston
Copy link
Member

I would not expect this to only affect Python 3.

@slivingston
Copy link
Member

Can you provide an example that demonstrates the error?

Since np as an identifier for numpy is not used within the function scope after where np is assigned to an array size, it is not an error. I agree that changing the name would improve the style, but it is not a matter of correctness.

@ochurlaud
Copy link
Author

Hum, I don't remember: it was some time ago. Comparing to other modules, t should be call _np I think instead of what I wrote. Anyway: as it's a small fix, without huge repercussions, I think it should be somehow done.

Even if you don't use my PR, just do the correction somehow?

@roryyorke
Copy link
Contributor

I fixed this on #100. It is a bug; if, on that branch, I revert from np_ to np, I get the error below. I'd have to read up on how Python handles globals and locals to explain this (did that change in Python 3?).

Test h2syn
----------------------------------------------------------------------
Traceback (most recent call last):
  File "robust_test.py", line 34, in testH2syn
    k = control.robust.h2syn(p, 1, 1)
  File "/home/rory/src/python-control/control/robust.py", line 91, in h2syn
    n = np.size(P.A,0)
UnboundLocalError: local variable 'np' referenced before assignment

@ochurlaud
Copy link
Author

Ok, then maybe merging #100 would be better than mine.

@slivingston
Copy link
Member

Changes from pull request #100 were merged, which subsumes changes from here, as noted above. In particular, cf. lines 93 and 157 of control/robust.py as of commit d4e0155 (current tip of master branch).

@ochurlaud Nonetheless, thanks for this pull request. I should have been faster to review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants