Exemple #1
0
def test_normalized_axes_tuple_raise():
    """Test if errors are raised for invalid input."""

    with pytest.raises(TypeError):
        normalized_axes_tuple(1.5, ndim=3)  # float

    with pytest.raises(TypeError):
        normalized_axes_tuple(None, ndim=3)  # garbage

    with pytest.raises(ValueError):
        normalized_axes_tuple((0, 1.5), ndim=3)  # sequence containing float

    with pytest.raises(TypeError):
        normalized_axes_tuple((0, None), ndim=3)  # sequence containing garbge

    with pytest.raises(ValueError):
        normalized_axes_tuple((0, 0, 1), ndim=3)  # duplicate

    with pytest.raises(ValueError):
        normalized_axes_tuple((0, ), ndim=0)  # nonpositive ndim

    with pytest.raises(ValueError):
        normalized_axes_tuple((0, 1), ndim=1)  # axis out of range

    with pytest.raises(ValueError):
        normalized_axes_tuple(-3, ndim=2)  # axis out of range

    with pytest.raises(ValueError):
        normalized_axes_tuple((0, 2), ndim=2)  # axis out of range
Exemple #2
0
def test_normalized_axes_tuple_raise():
    """Test if errors are raised for invalid input."""

    with pytest.raises(TypeError):
        normalized_axes_tuple(1.5, ndim=3)  # float

    with pytest.raises(TypeError):
        normalized_axes_tuple(None, ndim=3)  # garbage

    with pytest.raises(ValueError):
        normalized_axes_tuple((0, 1.5), ndim=3)  # sequence containing float

    with pytest.raises(TypeError):
        normalized_axes_tuple((0, None), ndim=3)  # sequence containing garbge

    with pytest.raises(ValueError):
        normalized_axes_tuple((0, 0, 1), ndim=3)  # duplicate

    with pytest.raises(ValueError):
        normalized_axes_tuple((0,), ndim=0)  # nonpositive ndim

    with pytest.raises(ValueError):
        normalized_axes_tuple((0, 1), ndim=1)  # axis out of range

    with pytest.raises(ValueError):
        normalized_axes_tuple(-3, ndim=2)  # axis out of range

    with pytest.raises(ValueError):
        normalized_axes_tuple((0, 2), ndim=2)  # axis out of range
Exemple #3
0
def test_normalized_axes_tuple(axes_conv):
    """Test if all valid sequences are converted correctly."""
    axes, conversion = axes_conv
    assert normalized_axes_tuple(axes, ndim=3) == conversion
Exemple #4
0
def test_normalized_axes_tuple(axes_conv):
    """Test if all valid sequences are converted correctly."""
    axes, conversion = axes_conv
    assert normalized_axes_tuple(axes, ndim=3) == conversion