Skip to content

Implement MB02ED#214

Merged
bnavigator merged 13 commits into
python-control:masterfrom
saasaa:master
Sep 24, 2023
Merged

Implement MB02ED#214
bnavigator merged 13 commits into
python-control:masterfrom
saasaa:master

Conversation

@saasaa

@saasaa saasaa commented Sep 19, 2023

Copy link
Copy Markdown
Contributor

Hi,

I have to implement the function MB02ED. Since I am no expert in Fortran, F2Py or numerics I am opening this draft PR to make sure, that I haven't overlooked something obvious or am not following the conventions of this library properly.

I have at the moment:

  • Created the F2Py Signature for MB02ED.
  • Created the wrapper function mb02ed in slycot/math.py
  • Written a test using the example data from examples , which passes pytest

I still have to

  • Convert the SLICOT Fortran documentation to a numpydocstyle docstring

which I plan to do over the course of this week.

Have I overlooked something?

Thanks

@saasaa saasaa marked this pull request as ready for review September 19, 2023 18:38
@bnavigator

Copy link
Copy Markdown
Collaborator

Hi @saasaa,

glad to see someone working on this.

Your seem to have activated some linter in your editor. Please try to avoid the format changes in unrelated functions and import statements at the head of the module files for this PR.

@saasaa

saasaa commented Sep 20, 2023

Copy link
Copy Markdown
Contributor Author

I am using black as formatter by default, but I think I have removed all changes.

@saasaa

saasaa commented Sep 21, 2023

Copy link
Copy Markdown
Contributor Author

I have added the docstring

Comment thread slycot/math.py Outdated
Comment thread slycot/math.py Outdated
Comment thread slycot/math.py
Comment thread slycot/math.py Outdated
Comment thread slycot/math.py Outdated
@bnavigator

Copy link
Copy Markdown
Collaborator

Please see #200 and consider using copy in the wrapper for B and T

@bnavigator

Copy link
Copy Markdown
Collaborator

Don't worry about the current test failures of 15188ef , they look unrelated

@saasaa

saasaa commented Sep 23, 2023

Copy link
Copy Markdown
Contributor Author

I have added tests for wrong input parameters and a negative definite matrix, the tests for the wrong parameters pass, but the test for the negative definite matrix gives me an TypeError: SlycotError.__init__() takes 3 positional arguments but 4 were given and I cannot figure out the cause.

Comment thread slycot/math.py Outdated
@bnavigator

Copy link
Copy Markdown
Collaborator

I fixed the CI errors with setuptools_scm. Please rebase onto current master branch.

Comment thread slycot/math.py Outdated
Comment thread slycot/math.py Outdated
Comment thread slycot/math.py Outdated
Comment on lines +71 to +73
SlycotParameterError
:info < 0:
if INFO = -i, the i-th argument had an illegal value.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

>       with pytest.raises(expected_exception=SlycotParameterError, match="k must be >= 0") as cm:
E       AssertionError: Regex pattern did not match.
E        Regex: 'k must be >= 0'
E        Input: '\nif INFO = -i, the i-th argument had an illegal value.'

If you want to have more meaningful error messages (not mandatory);

Suggested change
SlycotParameterError
:info < 0:
if INFO = -i, the i-th argument had an illegal value.
SlycotParameterError
:info = -2:
k must be >= 0
:info = -3:
n must be >= 0

and so on

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Otherwise just remove the info < 0 zero case and make sure the arg_list is in the correct order, then raise_if_slycot_error will generate a reasonable message. You will have to adjust the regex pattern in the tests then.

@saasaa

saasaa commented Sep 23, 2023

Copy link
Copy Markdown
Contributor Author

I have added docstrings for the different SlycotParameterError, I have fixed the checks in the function signature, but the tests still fail with E _wrapper.error: (k>=0) failed for 2nd argument k: mb02ed:k=-1

Comment thread slycot/src/math.pyf Outdated

@bnavigator bnavigator left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks quite good now. A few minor nitpicks:

Comment thread slycot/math.py Outdated
Comment thread slycot/math.py
Comment thread slycot/tests/test_mb.py
Comment thread slycot/tests/test_mb.py Outdated
Comment thread slycot/tests/test_mb.py
Comment thread slycot/math.py Outdated
Comment thread slycot/math.py Outdated
saasaa and others added 2 commits September 23, 2023 22:51
Co-authored-by: Ben Greiner <code@bnavigator.de>
@saasaa saasaa requested a review from bnavigator September 24, 2023 13:27
@bnavigator bnavigator merged commit 9485d94 into python-control:master Sep 24, 2023
@bnavigator

Copy link
Copy Markdown
Collaborator

Thanks a lot for the hard work and the patience with the reviews.

@saasaa

saasaa commented Sep 24, 2023

Copy link
Copy Markdown
Contributor Author

Thank you accepting my PR!

@bnavigator

Copy link
Copy Markdown
Collaborator

Just a heads up @saasaa: You have worked from the master branch in your clone. It has now diverged from upstream. You have to reset your origin and local master branches to upstream/master and use a new "feature" branch, when you prepare your next contribution. (https://github.com/python-control/python-control/wiki/How-to-contribute-with-a-pull-request) Looking forward to it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants