コード例 #1
0
def test_normalize_axis_tuple():
    assert normalize_axis_tuple(-1, 3) == (2, )
    assert normalize_axis_tuple([0, -2], 3) == (0, 1)
    assert sorted(normalize_axis_tuple({0, -2}, 3)) == [0, 1]

    with pytest.raises(ValueError) as cm:
        normalize_axis_tuple((1, -2), 3, argname='axes')
    assert 'axes' in str(cm.value)

    with pytest.raises(ValueError):
        normalize_axis_tuple((1, -2), 3)
コード例 #2
0
ファイル: test_utils.py プロジェクト: yyaaa1/mars
    def testNormalizeAxisTuple(self):
        self.assertEqual(normalize_axis_tuple(-1, 3), (2,))
        self.assertEqual(normalize_axis_tuple([0, -2], 3), (0, 1))
        self.assertEqual(sorted(normalize_axis_tuple({0, -2}, 3)), [0, 1])

        with self.assertRaises(ValueError) as cm:
            normalize_axis_tuple((1, -2), 3, argname='axes')
        self.assertIn('axes', str(cm.exception))

        with self.assertRaises(ValueError):
            normalize_axis_tuple((1, -2), 3)