-
Notifications
You must be signed in to change notification settings - Fork 438
Change to code for ctrb and obsv #300
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
Conversation
@billtubbs Thanks for the contribution to python-control! Your proposed changes are not passing the Travis CI unit tests. Can you fix those and then resubmit? The problem could be in your code or could be in the unit tests, but something is not right. Also, I wonder whether it might not be faster by using the fact that each iteration of the computation just needs to pre-/post-multiple the last col/row of the matrix by |
I see I made an error. I checked out your unit tests and realised my mistake. I will make the change shortly and test it with your tests this time... Sorry about that. |
I fixed the error and it seems to pass the unit tests now:
|
Changes look good. More pythonic and if we get some speed up as well, that's great. |
Cool, thanks. It's only a minor speed improvement of 13-17% on something that wasn't exactly computationally demanding... Anyhow, I am interested in this project. If there is any way I can help let me know. I'd say I'm an intermediate/good python programmer and currently learning control engineering. |
Ah yes, good idea. I'll look into that. |
Places that could use help: https://github.com/python-control/python-control/issues |
I worked on some faster versions. Turns out converting the arguments to np.mat was wasting a lot of time. However, the fastest two solutions are not that pretty and hardly as readable as What do you think? Setup:
|
The numpy matrix class is being deprecated, so eventually the The PR is now merged, so if you want to make additional changes it will have to go in a new PR. |
Understood. Seems like a good idea to replace I'll have to add things like the following to ctrb and obsv:
or even:
I'll maybe work on this next weekend and make sure it's working before starting a new PR. |
Current changes are better than what was there. OK to keep tweaking, but there are lots of other things to work on that could use work, if you have time. |
This is not a bug fix. It's a minor speed improvement to
statefbk.ctrb
andstatefbk.obsv
.[It's the first time I have contributed to someone else's project so welcome feedback and advice if I'm not doing this correctly]
Summary
I noticed that you can avoid multiple hstack operations by creating a list first.
I've done some testing and I think the behaviour of these methods is unchanged. See my test outputs below.
I realise this is a very minor improvement so feel free to ignore.
1. Testing
ctrb()
Results with official control package for comparison
2. Testing
obsv()
Results with official control package for comparison
3. Speed Tests (In Python 3.7 on a 2013 MacBook Pro)