def test_normalize_integer(): for dtype in ['int', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64']: a = Integer(2, 30, transform="normalize", dtype=dtype) for X in range(2, 31): X_orig = a.inverse_transform(a.transform(X)) assert_array_equal(X_orig, X) for dtype in [int, np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uint32, np.uint64]: a = Integer(2, 30, transform="normalize", dtype=dtype) for X in range(2, 31): X_orig = a.inverse_transform(a.transform(X)) assert_array_equal(X_orig, X) assert isinstance(X_orig, dtype)
def test_integer(): a = Integer(1, 10) for i in range(50): yield (check_limits, a.rvs(random_state=i), 1, 11) random_values = a.rvs(random_state=0, n_samples=10) assert_array_equal(random_values.shape, (10)) assert_array_equal(a.transform(random_values), random_values) assert_array_equal(a.inverse_transform(random_values), random_values)
def test_integer(): a = Integer(1, 10) for i in range(50): r = a.rvs(random_state=i) assert_less_equal(1, r) assert_greater_equal(11, r) assert_true(r in a) random_values = a.rvs(random_state=0, n_samples=10) assert_array_equal(random_values.shape, (10)) assert_array_equal(a.transform(random_values), random_values) assert_array_equal(a.inverse_transform(random_values), random_values)
def test_integer(): a = Integer(1, 10) for i in range(50): r = a.rvs(random_state=i) assert 1 <= r assert 11 >= r assert r in a random_values = a.rvs(random_state=0, n_samples=10) assert_array_equal(random_values.shape, (10)) assert_array_equal(a.transform(random_values), random_values) assert_array_equal(a.inverse_transform(random_values), random_values)
def test_normalize_integer(): a = Integer(2, 30, transform="normalize") for i in range(50): check_limits(a.rvs(random_state=i), 2, 30) assert_array_equal(a.transformed_bounds, (0, 1)) X = rng.randint(2, 31, dtype=np.int64) # Check transformed values are in [0, 1] assert np.all(a.transform(X) <= np.ones_like(X)) assert np.all(np.zeros_like(X) <= a.transform(X)) # Check inverse transform X_orig = a.inverse_transform(a.transform(X)) assert isinstance(X_orig, np.int64) assert_array_equal(X_orig, X) a = Integer(2, 30, transform="normalize", dtype=int) X = rng.randint(2, 31, dtype=int) # Check inverse transform X_orig = a.inverse_transform(a.transform(X)) assert isinstance(X_orig, int) a = Integer(2, 30, transform="normalize", dtype='int') X = rng.randint(2, 31, dtype=int) # Check inverse transform X_orig = a.inverse_transform(a.transform(X)) assert isinstance(X_orig, int) a = Integer(2, 30, prior="log-uniform", base=2, transform="normalize", dtype=int) for i in range(50): check_limits(a.rvs(random_state=i), 2, 30) assert_array_equal(a.transformed_bounds, (0, 1)) X = rng.randint(2, 31, dtype=int) # Check transformed values are in [0, 1] assert np.all(a.transform(X) <= np.ones_like(X)) assert np.all(np.zeros_like(X) <= a.transform(X)) # Check inverse transform X_orig = a.inverse_transform(a.transform(X)) assert isinstance(X_orig, int) assert_array_equal(X_orig, X)