Exemplo n.º 1
0
def random_state(random_state=None, force=False):
    global _random_state
    if _random_state is None:
        _random_state = np.random.RandomState(
            seed=42) if random_state is None else random_state
    elif random_state is not None:
        if force:
            _random_state = random_state
        else:
            raise exc.NumericError(
                'Process-wide random state is already set; it may not be set twice'
            )
    return _random_state
Exemplo n.º 2
0
 def testNumericError(self):
     with self.assertRaises(exc.NumericError):
         raise exc.NumericError('Failed to converge')