Updated gram to support discrete-time systems by billtubbs · Pull Request #969 · python-control/python-control

@billtubbs

gram function for observability/controllability Gramians did not support discrete time systems, as described in #967 (comment).

Updated control/statefbk.py and tests in control/tests/statefbk_test.py.

@bnavigator

I have fixed the failing FutureWarning test. Could you please rebase onto current main?

bnavigator

Choose a reason for hiding this comment

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

Thanks for working on these ancient TODO lines! They're 13 years old!

9b5b460

raise ValueError("Oops, the system is unstable!")

else:
raise ValueError("sys")

Choose a reason for hiding this comment

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

I imagine an error message from this line could be very confusing.

Is this even reachable by normal API usage? If so, could you please cover it in statefbk_test.py? If not, do we really need the line or is a if sys.isctime(): .. else: ... construct enough?

Choose a reason for hiding this comment

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

This is true. The only time this would ever get raised is if someone passed an object that returns false to both isctime and isdtime. I put it in because it's bad practice to do if cond1: ... elif cond2: with no else but it would only realistically get raised during development if something was wrong. That's why I left the message very simple because no real user is likely to ever see it, hopefully!

Choose a reason for hiding this comment

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

If sys.isdtime literally returned not sys.isctime then we can be sure this will never occur. But it looks more complicated than that.

Still, this might be a case of 'belt and braces' (belt and suspenders) and I'm happy to delete it.

Choose a reason for hiding this comment

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

Okay, this may be pedantic but for the sake of coverage, please create a test so that the test suite at least hits that line once.

@billtubbs

I have fixed the failing FutureWarning test. Could you please rebase onto current main?

Sorry, how do I do that again? I just tried using these instructions and not sure it worked.

@bnavigator

Sorry, how do I do that again? I just tried using these instructions and not sure it worked.

Those instructions are not complete for your case. Your PR comes from basicmachines/main. That makes it a bit more complicated than our own instructions in https://github.com/python-control/python-control/wiki/How-to-contribute-with-a-pull-request

You need to:

option A

  1. Sync your fork on https://github.com/basicmachines/python-control-2/tree/main using the sync fork button
  2. Assuming your local machine has above repository as remote "origin":
git fetch origin
git rebase origin/main
git push -f

option B

# on branch main tracking basicmachines:main (https://github.com/basicmachines/python-control-2/tree/main)
git remote add upstreamhttps://github.com/python-control/python-control.git
git fetch upstream
git rebase upstream/main
git push -f

(Why do you have two forks? Better work with properly named feature branches)

@billtubbs

(Why do you have two forks? Better work with properly named feature branches)

Sorry I probably shouldn't have created another fork. The previous fork has all that work I did on the plot functions previously (I shared a link to it with Richard in case he needs to refer to it). It's all far behind the origin now.

I'll fix that conditional statement so no test is needed and re-submit the PR.

@billtubbs

I committed the change so it should be ready to merge now. I only ran the statefbk_test.py tests and there are still two fails but I don't think these are anything to do with the changes I made:

XFAIL control/tests/statefbk_test.py::TestStatefbk::testLQR_warning - warning not implemented
XFAIL control/tests/statefbk_test.py::TestStatefbk::testDLQR_warning - warning not implemented

@coveralls

Coverage Status

coverage: 94.425% (+0.003%) from 94.422%
when pulling 0836ad8 on basicmachines:main
into 7a70be1 on python-control:main.

@bnavigator

XFAIL

That is an "Expected fail" and nothing to worry about here.

@bnavigator

@sawyerbfuller

@billtubbs if you're getting tied up doing a rebase (as has often happened to me) maybe easier would be to try working on a fresh branch from an up-to-date main and re-doing your changes by hand?

@billtubbs

Hi Ben, Sawyer, sorry I got distracted and forgot to finish this. Thanks for the reminder I will get back to it this week.

@murrayrm

@billtubbs I'm likely to release a new version of python-control in the next day or two. If you have a chance to rebase this PR, I'll include it in the v0.10.0 (otherwise v0.10.1).

@billtubbs

@billtubbs

@billtubbs

Sorry for delay. I just rebased it using your earlier instructions and it seemed to work. Running the tests again now...

@billtubbs

Tests seemed to work. Is this success?

3550 passed, 30 skipped, 11 xfailed, 5 warnings in 133.34s (0:02:13)

@murrayrm