Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_live_dangerously(nwalkers=32, nsteps=3000, seed=1234):
warnings.filterwarnings("error")
# Set up the random number generator.
np.random.seed(seed)
state = State(np.random.randn(nwalkers, 2 * nwalkers),
log_prob=np.random.randn(nwalkers))
model = Model(
None,
lambda x: (np.zeros(len(x)), None),
map,
np.random
)
proposal = moves.StretchMove()
# Test to make sure that the error is thrown if there aren't enough
# walkers.
with pytest.raises(RuntimeError):
proposal.propose(model, state)
# Living dangerously...
proposal.live_dangerously = True
proposal.propose(model, state)
def test_nsplits_stretch(**kwargs):
_test_normal(moves.StretchMove(nsplits=5), **kwargs)
def test_randomize_stretch(**kwargs):
_test_normal(moves.StretchMove(randomize_split=True), **kwargs)
def test_uniform_stretch(**kwargs):
_test_uniform(moves.StretchMove(), **kwargs)
def test_normal_stretch(blobs, **kwargs):
kwargs["blobs"] = blobs
_test_normal(moves.StretchMove(), **kwargs)