Repository: scipy/scipy
File: scipy/signal/_lti_conversion.py (Python)

Code before:
        # matrix. Thus, it should have a non-zero shape so that
        # it can be operated on by functions like 'ss2tf'
        D = array([[0]], float)

    if K == 1:
        D = D.reshape(num.shape)

        return (zeros((1, 1)), zeros((1, D.shape[1])),
                zeros((D.shape[0], 1)), D)

    frow = -array([den[1:]])
    A = r_[frow, eye(K - 2, K - 1)]
    B = eye(K - 1, 1)
    C = num[:, 1:] - outer(num[:, 0], den[1:])
    D = D.reshape((C.shape[0], B.shape[1]))

    return A, B, C, D


def abcd_normalize(A=None, B=None, C=None, D=None):
    """Check state-space matrices compatibility and ensure they are 2d arrays.

    Converts input matrices into two-dimensional arrays as needed. Then the dimensions
    n, q, p are determined by investigating the non-zero entries of the array shapes.
    If a parameter is ``None``, or has shape (0, 0), it is tried to set it to a
    zero-array of compatible shape. Finally, it is verified that all parameter shapes
    are compatible to each other. If that fails, a ``ValueError`` is raised. Note that
    the dimensions n, q, p are allowed to be zero.

    Parameters
    ----------
    A: array_like, optional
        Must be convertible to a two-dimensional array of shape (n, n).
    B: array_like, optional
        Must be convertible to a two-dimensional array of shape (n, p).
    C: array_like, optional
        Must be convertible to a two-dimensional array of shape (q, n).
    D: array_like, optional
        Must be convertible to a two-dimensional array of shape (q, p).

    Returns
    -------
    A, B, C, D : array
        State-space matrices as two-dimensional arrays.

    Notes
    -----
    The :ref:`tutorial_signal_state_space_representation` section of the
    :ref:`user_guide` presents the corresponding definitions of continuous-time and
    disrcete time state space systems.


Review comment (suggestion):
Perhaps clearer 
```suggestion
    If a parameter is ``None``, or has shape (0, 0), it is set to a
    zero-array of compatible shape. Finally, it is verified that all parameter shapes
```

Code after:
        # matrix. Thus, it should have a non-zero shape so that
        # it can be operated on by functions like 'ss2tf'
        D = array([[0]], float)

    if K == 1:
        D = D.reshape(num.shape)

        return (zeros((1, 1)), zeros((1, D.shape[1])),
                zeros((D.shape[0], 1)), D)

    frow = -array([den[1:]])
    A = r_[frow, eye(K - 2, K - 1)]
    B = eye(K - 1, 1)
    C = num[:, 1:] - outer(num[:, 0], den[1:])
    D = D.reshape((C.shape[0], B.shape[1]))

    return A, B, C, D


def abcd_normalize(A=None, B=None, C=None, D=None):
    """Check state-space matrices compatibility and ensure they are 2d arrays.

    Converts input matrices into two-dimensional arrays as needed. Then the dimensions
    n, q, p are determined by investigating the non-zero entries of the array shapes.
    If a parameter is ``None``, or has shape (0, 0), it is set to a
    zero-array of compatible shape. Finally, it is verified that all parameter shapes
    are compatible to each other. If that fails, a ``ValueError`` is raised. Note that
    the dimensions n, q, p are allowed to be zero.

    Parameters
    ----------
    A: array_like, optional
        Two-dimensional array of shape (n, n).
    B: array_like, optional
        Two-dimensional array of shape (n, p).
    C: array_like, optional
        Two-dimensional array of shape (q, n).
    D: array_like, optional
        Two-dimensional array of shape (q, p).

    Returns
    -------
    A, B, C, D : array
        State-space matrices as two-dimensional arrays.

    Notes
    -----
    The :ref:`tutorial_signal_state_space_representation` section of the
    :ref:`user_guide` presents the corresponding definitions of continuous-time and
    disrcete time state space systems.