# Path: surprise/utils.py
# def get_rng(random_state):
#     """Return a 'validated' RNG.
# 
#     If random_state is None, use RandomState singleton from numpy.  Else if
#     it's an integer, consider it's a seed and initialized an rng with that
#     seed. If it's already an rng, return it.
#     """
#     if random_state is None:
#         return np.random.mtrand._rand
#     elif isinstance(random_state, (numbers.Integral, np.integer)):
#         return np.random.RandomState(random_state)
#     if isinstance(random_state, np.random.RandomState):
#         return random_state
#     raise ValueError('Wrong random state. Expecting None, an int or a numpy '
#                      'RandomState instance, got a '
#                      '{}'.format(type(random_state)))


from itertools import chain
from math import ceil, floor
from collections import defaultdict
from six import iteritems
from six import string_types
from ..utils import get_rng
import numbers
import numpy as np

        if train_size is None:
            train_size = n_ratings - test_size
        elif np.asarray(train_size).dtype.kind == 'f':
            train_size = floor(train_size * n_ratings)

        if test_size is None:
            test_size = n_ratings - train_size

        if train_size + test_size > n_ratings:
            raise ValueError('The sum of train_size and test_size ({0}) '
                             'should be smaller than the number of '
                             'ratings {1}.'.format(train_size + test_size,
                                                   n_ratings))

        return int(train_size), int(test_size)

    def split(self, data):
        """Generator function to iterate over trainsets and testsets.

        Args:
            data(:obj:`Dataset<surprise.dataset.Dataset>`): The data containing
                ratings that will be divided into trainsets and testsets.

        Yields:
            tuple of (trainset, testset)
        """

        test_size, train_size = self.validate_train_test_sizes(
            self.test_size, self.train_size, len(data.raw_ratings))

# Path: surprise/utils.py
# def get_rng(random_state):
#     """Return a 'validated' RNG.
# 
#     If random_state is None, use RandomState singleton from numpy.  Else if
#     it's an integer, consider it's a seed and initialized an rng with that
#     seed. If it's already an rng, return it.
#     """
#     if random_state is None:
#         return np.random.mtrand._rand
#     elif isinstance(random_state, (numbers.Integral, np.integer)):
#         return np.random.RandomState(random_state)
#     if isinstance(random_state, np.random.RandomState):
#         return random_state
#     raise ValueError('Wrong random state. Expecting None, an int or a numpy '
#                      'RandomState instance, got a '
#                      '{}'.format(type(random_state)))


# Path: surprise/model_selection/split.py
from itertools import chain
from math import ceil, floor
from collections import defaultdict
from six import iteritems
from six import string_types
from ..utils import get_rng
import numbers
import numpy as np


        if train_size is None:
            train_size = n_ratings - test_size
        elif np.asarray(train_size).dtype.kind == 'f':
            train_size = floor(train_size * n_ratings)

        if test_size is None:
            test_size = n_ratings - train_size

        if train_size + test_size > n_ratings:
            raise ValueError('The sum of train_size and test_size ({0}) '
                             'should be smaller than the number of '
                             'ratings {1}.'.format(train_size + test_size,
                                                   n_ratings))

        return int(train_size), int(test_size)

    def split(self, data):
        """Generator function to iterate over trainsets and testsets.

        Args:
            data(:obj:`Dataset<surprise.dataset.Dataset>`): The data containing
                ratings that will be divided into trainsets and testsets.

        Yields:
            tuple of (trainset, testset)
        """

        test_size, train_size = self.validate_train_test_sizes(
            self.test_size, self.train_size, len(data.raw_ratings))

        rng = get_rng(self.random_state)