コード例 #1
0
ファイル: test_common.py プロジェクト: agijsberts/pandas
def test_random_state():
    import numpy.random as npr
    # Check with seed
    state = com._random_state(5)
    assert_equal(state.uniform(), npr.RandomState(5).uniform())

    # Check with random state object
    state2 = npr.RandomState(10)
    assert_equal(com._random_state(state2).uniform(), npr.RandomState(10).uniform())

    # check with no arg random state
    assert isinstance(com._random_state(), npr.RandomState)

    # Error for floats or strings
    with tm.assertRaises(ValueError):
        com._random_state('test')

    with tm.assertRaises(ValueError):
        com._random_state(5.5)
コード例 #2
0
ファイル: test_common.py プロジェクト: thekensta/pandas
def test_random_state():
    import numpy.random as npr
    # Check with seed
    state = com._random_state(5)
    assert_equal(state.uniform(), npr.RandomState(5).uniform())

    # Check with random state object
    state2 = npr.RandomState(10)
    assert_equal(com._random_state(state2).uniform(), npr.RandomState(10).uniform())

    # check with no arg random state
    assert isinstance(com._random_state(), npr.RandomState)

    # Error for floats or strings
    with tm.assertRaises(ValueError):
        com._random_state('test')

    with tm.assertRaises(ValueError):
        com._random_state(5.5)
コード例 #3
0
def test_random_state():
    import numpy.random as npr
    # Check with seed
    state = com._random_state(5)
    assert state.uniform() == npr.RandomState(5).uniform()

    # Check with random state object
    state2 = npr.RandomState(10)
    assert com._random_state(state2).uniform() == npr.RandomState(10).uniform()

    # check with no arg random state
    assert com._random_state() is np.random

    # Error for floats or strings
    with pytest.raises(ValueError):
        com._random_state('test')

    with pytest.raises(ValueError):
        com._random_state(5.5)
コード例 #4
0
ファイル: _style.py プロジェクト: mficek/pandas
 def random_color(column):
     """ Returns a random color represented as a list of length 3"""
     # GH17525 use common._random_state to avoid resetting the seed
     rs = _random_state(column)
     return rs.rand(3).tolist()
コード例 #5
0
 def random_color(column):
     """ Returns a random color represented as a list of length 3"""
     # GH17525 use common._random_state to avoid resetting the seed
     rs = com._random_state(column)
     return rs.rand(3).tolist()