本文整理汇总了Python中series.slices函数的典型用法代码示例。如果您正苦于以下问题:Python slices函数的具体用法?Python slices怎么用?Python slices使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了slices函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_overly_short_slice
def test_overly_short_slice(self):
with self.assertRaises(ValueError):
slices("01234", 0)
示例2: test_slices_of_five
def test_slices_of_five(self):
self.assertEqual([[0, 1, 2, 3, 4]],
slices("01234", 5))
示例3: test_overly_long_slice
def test_overly_long_slice(self):
with self.assertRaises(ValueError):
slices("012", 4)
示例4: test_slices_of_three
def test_slices_of_three(self):
self.assertEqual([[9, 7, 8], [7, 8, 6], [8, 6, 7],
[6, 7, 5], [7, 5, 6], [5, 6, 4]],
slices("97867564", 3))
示例5: test_slices_of_four
def test_slices_of_four(self):
self.assertEqual([[0, 1, 2, 3], [1, 2, 3, 4]],
slices("01234", 4))
示例6: test_slices_of_two
def test_slices_of_two(self):
self.assertEqual(
slices("97867564", 2),
[[9, 7], [7, 8], [8, 6], [6, 7], [7, 5], [5, 6], [6, 4]], )
示例7: test_slices_of_one
def test_slices_of_one(self):
self.assertEqual([[0], [1], [2], [3], [4]],
slices("01234", 1))
示例8: test_slice_length_cannot_be_negative
def test_slice_length_cannot_be_negative(self):
with self.assertRaisesWithMessage(ValueError):
slices("123", -1)
示例9: test_empty_series_is_invalid
def test_empty_series_is_invalid(self):
with self.assertRaisesWithMessage(ValueError):
slices("", 1)
示例10: test_slice_length_is_too_large
def test_slice_length_is_too_large(self):
with self.assertRaisesWithMessage(ValueError):
slices("12345", 6)
示例11: test_slice_length_cannot_be_zero
def test_slice_length_cannot_be_zero(self):
with self.assertRaisesWithMessage(ValueError):
slices("12345", 0)
示例12: test_slices_can_include_duplicates
def test_slices_can_include_duplicates(self):
self.assertEqual(slices("777777", 3), ["777", "777", "777", "777"])
示例13: test_slices_of_two_overlap
def test_slices_of_two_overlap(self):
self.assertEqual(slices("9142", 2), ["91", "14", "42"])
示例14: test_slices_of_two
def test_slices_of_two(self):
self.assertEqual(slices("35", 2), ["35"])
示例15: test_slices_of_one_from_two
def test_slices_of_one_from_two(self):
self.assertEqual(slices("12", 1), ["1", "2"])