from nose.tools import assert_equal

import genson

def test_gaussian_random_seed():
    gson = \
    """
    {
        "gaussian_random_seed" : gaussian(0, 1, draws=1, random_seed=42)
    }
    """
    val = genson.loads(gson).next()['gaussian_random_seed']
    assert_equal(val, 0.4967141530112327)


def test_gaussian_uniform_seed():
    gson = \
    """
    {
        "gaussian_uniform_seed" : uniform(0, 1, draws=1, random_seed=42)
    }
    """
    val = genson.loads(gson).next()['gaussian_uniform_seed']
    assert_equal(val, 0.3745401188473625)

from nose.tools import assert_equal

import genson

def test_gaussian_random_seed():
    gson = \
    """
    {
        "gaussian_random_seed" : gaussian(0, 1, draws=2, random_seed=42)
    }
    """
    vals = [val['gaussian_random_seed'] for val in genson.loads(gson)]
    assert_equal(vals[0], 0.4967141530112327)
    assert_equal(vals[1], -0.13826430117118466)


def test_gaussian_uniform_seed():
    gson = \
    """
    {
        "uniform_random_seed" : uniform(0, 1, draws=2, random_seed=42)
    }
    """
    vals = [val['uniform_random_seed'] for val in genson.loads(gson)]
    assert_equal(vals[0], 0.3745401188473625)
    assert_equal(vals[1], 0.9507143064099162)

Add RandomState to help generate different values, with test
Add RandomState to help generate different values, with test

  from nose.tools import assert_equal
  
  import genson
  
  def test_gaussian_random_seed():
      gson = \
      """
      {
-         "gaussian_random_seed" : gaussian(0, 1, draws=1, random_seed=42)
+         "gaussian_random_seed" : gaussian(0, 1, draws=2, random_seed=42)
      }
      """
-     val = genson.loads(gson).next()['gaussian_random_seed']
+     vals = [val['gaussian_random_seed'] for val in genson.loads(gson)]
-     assert_equal(val, 0.4967141530112327)
+     assert_equal(vals[0], 0.4967141530112327)
+     assert_equal(vals[1], -0.13826430117118466)
  
  
  def test_gaussian_uniform_seed():
      gson = \
      """
      {
-         "gaussian_uniform_seed" : uniform(0, 1, draws=1, random_seed=42)
+         "uniform_random_seed" : uniform(0, 1, draws=2, random_seed=42)
      }
      """
-     val = genson.loads(gson).next()['gaussian_uniform_seed']
+     vals = [val['uniform_random_seed'] for val in genson.loads(gson)]
-     assert_equal(val, 0.3745401188473625)
+     assert_equal(vals[0], 0.3745401188473625)
+     assert_equal(vals[1], 0.9507143064099162)
  
Add RandomState to help generate different values, with test
## Code Before:
from nose.tools import assert_equal

import genson

def test_gaussian_random_seed():
    gson = \
    """
    {
        "gaussian_random_seed" : gaussian(0, 1, draws=1, random_seed=42)
    }
    """
    val = genson.loads(gson).next()['gaussian_random_seed']
    assert_equal(val, 0.4967141530112327)


def test_gaussian_uniform_seed():
    gson = \
    """
    {
        "gaussian_uniform_seed" : uniform(0, 1, draws=1, random_seed=42)
    }
    """
    val = genson.loads(gson).next()['gaussian_uniform_seed']
    assert_equal(val, 0.3745401188473625)

## Instruction:
Add RandomState to help generate different values, with test
## Code After:
from nose.tools import assert_equal

import genson

def test_gaussian_random_seed():
    gson = \
    """
    {
        "gaussian_random_seed" : gaussian(0, 1, draws=2, random_seed=42)
    }
    """
    vals = [val['gaussian_random_seed'] for val in genson.loads(gson)]
    assert_equal(vals[0], 0.4967141530112327)
    assert_equal(vals[1], -0.13826430117118466)


def test_gaussian_uniform_seed():
    gson = \
    """
    {
        "uniform_random_seed" : uniform(0, 1, draws=2, random_seed=42)
    }
    """
    vals = [val['uniform_random_seed'] for val in genson.loads(gson)]
    assert_equal(vals[0], 0.3745401188473625)
    assert_equal(vals[1], 0.9507143064099162)
