Skip to content

Bug in xferfcn.py #369

Description

@rlegnain

Hi,
I found a bug in _common_den() method, line 935 in xferfcn.py file. The line code is :
num[i, j, maxindex+1-len(numpoly):maxindex+1] = numpoly

The error happen when numerator order is larger than denominator order. The error message is "ValueError: could not broadcast input array from shape (4) into shape (1)"

Activity

  1. bnavigator commented on Jan 27, 2020

    @bnavigator
    Contributor

    Yes the num and den arrays are sized according to the order of the denominator

    # figure out maximum number of poles, for sizing the den
    maxindex = max([len(p) for p in poles])
    den = zeros((self.inputs, maxindex + 1), dtype=float)
    num = zeros((max(1, self.outputs, self.inputs),
    max(1, self.outputs, self.inputs),
    maxindex + 1),
    dtype=float)

    This could be extended to use the maximum of numerator and denominator, but I am not sure TD04AD will handle this, as it likely expects a proper transfer function? The documenation of TD04AD seems to imply that always denorder > numorder.

    _common_den() should not fail with a ValueError though. A check and proper exception should be raised, or a return of the correct num and den and a warning display.

  2. rlegnain commented on Jan 28, 2020

    @rlegnain
    Author

    I think a return of num and den with warning message will be good.

    Thanks

  3. added this to the 0.8.4 milestone on Mar 21, 2020
  4. self-assigned this
    on Mar 22, 2020
  5. murrayrm commented on Jul 11, 2020

    @murrayrm
    Member

    Fixed in PR #370

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions