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

Code before:
    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.

    Raises
    ------
    ValueError
        If the dimensions n, q, or p could not be determined or if the shapes are
        incompatible with each other.

    See Also
    --------
    StateSpace: Linear Time Invariant system in state-space form.
    dlti: Discrete-time linear time invariant system base class.
    tf2ss: Transfer function to state-space representation.
    ss2tf: State-space to transfer function.
    ss2zpk: State-space representation to zero-pole-gain representation.

Review comment (suggestion):
IMO the "convertible" part is implied by array like
```suggestion
        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).
```

Code after:
    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.

    Raises
    ------
    ValueError
        If the dimensions n, q, or p could not be determined or if the shapes are
        incompatible with each other.

    See Also
    --------
    StateSpace: Linear Time Invariant system in state-space form.
    dlti: Discrete-time linear time invariant system base class.
    tf2ss: Transfer function to state-space representation.
    ss2tf: State-space to transfer function.
    ss2zpk: State-space representation to zero-pole-gain representation.