def test_shuffle_mixed_dimension(self): # Test for trac ticket #2074 for t in [[1, 2, 3, None], [(1, 1), (2, 2), (3, 3), None], [1, (2, 2), (3, 3), None], [(1, 1), 2, 3, None]]: mt19937.seed(12345) shuffled = list(t) mt19937.shuffle(shuffled) assert_array_equal(shuffled, [t[0], t[3], t[1], t[2]])
def test_shuffle_of_array_of_objects(self): # Test that permuting an array of objects will not cause # a segfault on garbage collection. # See gh-7719 mt19937.seed(1234) a = np.array([np.arange(1), np.arange(4)]) for _ in range(1000): mt19937.shuffle(a) # Force Garbage Collection - should not segfault. import gc gc.collect()
def test_shuffle_of_array_of_different_length_strings(self): # Test that permuting an array of different length strings # will not cause a segfault on garbage collection # Tests gh-7710 mt19937.seed(1234) a = np.array(['a', 'a' * 1000]) for _ in range(100): mt19937.shuffle(a) # Force Garbage Collection - should not segfault. import gc gc.collect()