Skip to content

Implement MB02ED #214

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

Merged
merged 13 commits into from
Sep 24, 2023
Merged

Implement MB02ED #214

merged 13 commits into from
Sep 24, 2023

Conversation

saasaa
Copy link
Contributor

@saasaa saasaa commented Sep 19, 2023

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
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
Copy link
Contributor Author

saasaa commented Sep 20, 2023

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

@saasaa
Copy link
Contributor Author

saasaa commented Sep 21, 2023

I have added the docstring

@bnavigator
Copy link
Collaborator

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

@bnavigator
Copy link
Collaborator

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

@saasaa
Copy link
Contributor Author

saasaa commented Sep 23, 2023

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.

@bnavigator
Copy link
Collaborator

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

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
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
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
Copy link
Contributor Author

saasaa commented Sep 23, 2023

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

Copy link
Collaborator

@bnavigator bnavigator left a comment

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:

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
Collaborator

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

@saasaa
Copy link
Contributor Author

saasaa commented Sep 24, 2023

Thank you accepting my PR!

@bnavigator
Copy link
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