def test_numpyarray_fails(self):
        with pytest.raises(ValueError):
            greater_than_or_equal_to(np.asarray(((1, 2), (3, 4))), 4)

        with pytest.raises(ValueError):
            greater_than_or_equal_to(np.asarray(((1, 2), (3, 4))),
                                     ((2, 3), (4, 5)))
예제 #2
0
def inertia_tensor(value: Union[Sequence[Sequence[Num]], Matrix],
                   name: Optional[AnyStr] = None):
    value = np_.asarray(value)

    try:
        dimensions(value, 2, name)
        shape(value, (3, 3), name)
        greater_than_or_equal_to(
            value.diagonal(), 0,
            'diag({})'.format(name if name is not None else 'value'))
    except ValueError as ValueE:
        raise ValueError(
            'Expected `{}` to be a valid inertia tensor, but was '
            'not'.format(name if name is not None else 'value', )) from ValueE
 def test_numpyarray_passes(self):
     greater_than_or_equal_to(np.asarray(((1, 2), (3, 4))), 1)
     greater_than_or_equal_to(np.asarray(((1, 2), (3, 4))),
                              np.asarray(((1, 2), (3, 4))))
    def test_list_of_list_fails(self):
        with pytest.raises(ValueError):
            greater_than_or_equal_to(((1, 2), (3, 4)), 4)

        with pytest.raises(ValueError):
            greater_than_or_equal_to(((1, 2), (3, 4)), ((2, 3), (4, 5)))
 def test_list_of_list_passes(self):
     greater_than_or_equal_to(((1, 2), (3, 4)), 1)
     greater_than_or_equal_to(((1, 2), (3, 4)), ((1, 2), (3, 4)))
    def test_list_fails(self):
        with pytest.raises(ValueError):
            greater_than_or_equal_to([1, 2, 3, 4], 4)

        with pytest.raises(ValueError):
            greater_than_or_equal_to([1, 2, 3, 4], [2, 3, 4, 5])
 def test_list_passes(self):
     greater_than_or_equal_to([1, 2, 3, 4], 1)
     greater_than_or_equal_to([1, 2, 3, 4], [1, 2, 3, 4])
 def test_scalar_passes(self):
     greater_than_or_equal_to(1, 1)
     greater_than_or_equal_to(0, 0)
     greater_than_or_equal_to(-1, -1)