def train_test_split(*arrays, **options):
 n_arrays = len(arrays)
 if (n_arrays == 0):
  raise ValueError('At least one array required as input')
 test_size = options.pop('test_size', None)
 train_size = options.pop('train_size', None)
 random_state = options.pop('random_state', None)
 stratify = options.pop('stratify', None)
 if options:
  raise TypeError(('Invalid parameters passed: %s' % str(options)))
 if ((test_size is None) and (train_size is None)):
  test_size = 0.25
 arrays = indexable(*arrays)
 if (stratify is not None):
  CVClass = StratifiedShuffleSplit
 else:
  CVClass = ShuffleSplit
 cv = CVClass(test_size=test_size, train_size=train_size, random_state=random_state)
 (train, test) = next(cv.split(X=arrays[0], y=stratify))
 return list(chain.from_iterable(((safe_indexing(a, train), safe_indexing(a, test)) for a in arrays)))

def train_test_split ( * arrays , ** options ) : n_arrays = len ( arrays ) if ( n_arrays == 0 ) : raise ValueError ( 'At least one array required as input' ) test_size = options . pop ( 'test_size' , None ) train_size = options . pop ( 'train_size' , None ) random_state = options . pop ( 'random_state' , None ) stratify = options . pop ( 'stratify' , None ) if options : raise TypeError ( ( 'Invalid parameters passed: %s' % str ( options ) ) ) if ( ( test_size is None ) and ( train_size is None ) ) : test_size = 0.25 arrays = indexable ( * arrays ) if ( stratify is not None ) : CVClass = StratifiedShuffleSplit else : CVClass = ShuffleSplit cv = CVClass ( test_size = test_size , train_size = train_size , random_state = random_state ) ( train , test ) = next ( cv . split ( X = arrays [ 0 ] , y = stratify ) ) return list ( chain . from_iterable ( ( ( safe_indexing ( a , train ) , safe_indexing ( a , test ) ) for a in arrays ) ) )
split arrays or matrices into random train and test subsets quick utility that wraps input validation and next(shufflesplit() .