Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Small improvements to nlsys, bdalg#1019

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

murrayrm
Copy link
Member

This PR provides some small changes to nonlinear I/O systems process:

  • Allows system name to be overridden inlinearize, even ifcopy_names isFalse.
  • Allows renaming of system/signal names in bdalg functions:
    sys = ct.series(sys1, sys2, inputs='u', outputs='y')
  • Newupdate_names method for I/O systems that allows signal and system names to be updated.
  • Refactoring of code for processingx0,u0 keywords inlinearize andinput_output_response to provide common functionality in allowing concatenation of lists and zero padding ("vector element processing").
  • Improved error messages whenx0 andu0 don't match the expected size.
  • If no output function is given innlsys, which provides full state output, the output signal names are set to match the state names.
  • Updated unit tests and documentation (including a new section on "vector element processing").

@coveralls
Copy link

Coverage Status

coverage: 94.603% (+0.09%) from 94.518%
when pullinga402a7f on murrayrm:nlsys_improvements-24May2024
intofeeb56a on python-control:main.

@murrayrmmurrayrm added this to the0.10.1 milestoneJun 30, 2024
Copy link
Contributor

@roryyorkeroryyorke left a comment

Choose a reason for hiding this comment

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

Functionality looks good. Minor suggestions and remarks.

from .iosys import InputOutputSystem

__all__ = ['series', 'parallel', 'negate', 'feedback', 'append', 'connect']


def series(sys1, *sysn):
def series(sys1, *sysn, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

kwargs not documented in docstring, here or the other functions inbdalg.py.


Parameters
----------
inputs : int, list of str, or None
Copy link
Contributor

Choose a reason for hiding this comment

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

name kwarg not documented

@@ -825,6 +865,7 @@ def _process_labels(labels, name, default):
#
import re
Copy link
Contributor

Choose a reason for hiding this comment

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

this can go - imported at top (not changed in this PR, tho...)


Parameters
----------
inputs : int, list of str, or None
Copy link
Contributor

Choose a reason for hiding this comment

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

explanation (or pointer to such - think this convention used in a few places?) of what integer and None do.

Possibly out-of-scope: what about a dict, of{oldname1:newname1, oldname2:newname2,...} - in this case don't have to specify all inputs (or outputs, or states...)


"""
self.name = kwargs.pop('name', self.name)
if kwargs.get('inputs', None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ifkwargs.get('inputs',None):
if'inputs'inkwargs:

Easier to read?

dict.get has signatureget(key, default=None), so if you want to use get you don't need None.

v = np.array(v).reshape(-1) # convert to 1D array
val_list += v.tolist() # add elements to list
val = np.array(val_list)
elif np.isscalar(arg) and size is not None: # extend scalars
Copy link
Contributor

Choose a reason for hiding this comment

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

does this funciton need to handle the case when np.isscalar(arg) and sizeis None, e.g., doval = np.array([arg]) ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Added this case.

# Process input argument
#
# The input argument is interpreted very flexibly, allowing the
# use of listsa and/or tuples of mixed scalar and vector elements.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# use oflistsa and/or tuples of mixed scalar and vector elements.
# use oflists and/or tuples of mixed scalar and vector elements.

@coveralls
Copy link

coveralls commentedJul 9, 2024
edited
Loading

Coverage Status

coverage: 94.628% (+0.1%) from 94.518%
when pulling8e123aa on murrayrm:nlsys_improvements-24May2024
intofeeb56a on python-control:main.

doc/iosys.rst Outdated
* Vector elements are zero padded to the required length. If you
specify only a portion of the values for states or inputs, the
remaining values are taken as zero. (If the final element in the
given vector is non-zero, a warning is issues.)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
given vector is non-zero, a warning isissues.)
given vector is non-zero, a warning isissued.)

doc/iosys.rst Outdated
state and input vectors, respectively.

If we want to linearize the closed loop system around a process state
``x0`` (with two elemenst) and an estimator state ``0`` (for both states),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
``x0`` (with twoelemenst) and an estimator state ``0`` (for both states),
``x0`` (with twoelements) and an estimator state ``0`` (for both states),

doc/iosys.rst Outdated
``x0`` (with two elemenst) and an estimator state ``0`` (for both states),
we can use the list processing feature::

H = clsys.liniearize([x0, 0], 0)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
H = clsys.liniearize([x0, 0], 0)
H = clsys.linearize([x0, 0], 0)

doc/iosys.rst Outdated
second argument in the list ``[x0, 0]`` is a scalar and so the vector
``[x0, 0]`` only has three elements instead of the required four.

To run an input/output simulation with a sinsoidal signal for the first
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
To run an input/output simulation with asinsoidal signal for the first
To run an input/output simulation with asinusoidal signal for the first

@murrayrmmurrayrm merged commit6406868 intopython-control:mainJul 9, 2024
23 checks passed
@murrayrmmurrayrm deleted the nlsys_improvements-24May2024 branchJuly 9, 2024 14:39
@murrayrmmurrayrm mentioned this pull requestJul 27, 2024
11 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@roryyorkeroryyorkeroryyorke left review comments

@slivingstonslivingstonslivingston left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
0.10.1
Development

Successfully merging this pull request may close these issues.

4 participants
@murrayrm@coveralls@roryyorke@slivingston

[8]ページ先頭

©2009-2025 Movatter.jp