def _shape(ys):
    """ Get the shape of a non-numpy python array. This assumes the first index of every dimension is
    indicative of the shape of the whole matrix.

    Examples:
        >>> _shape([1, 2, 3])
        [3]
        >>> _shape([[1, 2, 3], [4, 5]])
        [2, 3]
    """
    if hasattr(ys, '__len__'):
        return [len(ys)] + _shape(ys[0])
    else:
        return []