Skip to content
Snippets Groups Projects
Commit 621e6038 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

fix tests

parent 75d6fd64
No related branches found
No related tags found
No related merge requests found
......@@ -13,14 +13,17 @@ def shuffle_together(*args: tp.Sequence) -> tp.List[tp.List]:
>>> a = [1, 2, 3]
>>> b = ['a', 'b', 'c']
>>> c = permute_together(a, b)
>>> c = shuffle_together(a, b)
Might equal
>>> c == [[3, 1, 2], ['c', 'a', 'b']]
"""
indices = list(range(len(args[0])))
"""
try:
indices = list(range(len(args[0])))
except IndexError:
return [] # empty array
random.shuffle(indices)
return [[arg[i] for arg, i in zip(arg, indices)] for arg in args]
return [[arg[i] for i in indices] for arg in args]
......@@ -5,6 +5,9 @@ from satella.random import shuffle_together
class TestRandom(unittest.TestCase):
def test_random(self):
a = [(1, 2, 3), ('a', 'b', 'c')]
b = zip(shuffle_together(*a))
b = zip(*shuffle_together(*a))
self.assertEqual(set(b), {(1, 'a'), (2, 'b'), (3, 'c')})
self.assertEqual(shuffle_together(), [])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment