def default_selector(self):
     sel = SpringShootingSelector(delta_max=1,
                                  k_spring=0,
                                  initial_guess=self.initial_guess)
     sel._fw_prob_list = [1.0, 0.0, 0.0]
     sel._bw_prob_list = [0.0, 0.0, 1.0]
     sel._total_bias = 1.0
     return sel
 def setup(self):
     super(MoverTest, self).setup()
     sel = SpringShootingSelector(delta_max=1, k_spring=0)
     sel._fw_prob_list = [1.0, 0.0, 0.0]
     sel._bw_prob_list = [0.0, 0.0, 1.0]
     sel._total_bias = 1.0
     self.sel = sel
     self.samp = self.ges.samples[0]
 def test_probability_ratio():
     sel = SpringShootingSelector(delta_max=1, k_spring=1)
     sel._acceptable_snapshot = True
     ratio = sel.probability_ratio(None, None, None)
     assert ratio == 1.0
     sel._acceptable_snapshot = False
     ratio = sel.probability_ratio(None, None, None)
     assert ratio == 0.0
 def test_probability_ratio():
     sel = SpringShootingSelector(delta_max=1, k_spring=1)
     sel._acceptable_snapshot = True
     # TODO OPS 2.0:  Last value here is not None to silence deprecation
     # warnings, should be set to None after the completion
     ratio = sel.probability_ratio(None, None, None, 1)
     assert ratio == 1.0
     sel._acceptable_snapshot = False
     # TODO OPS 2.0:  Last value here is not None to silence deprecation
     # warnings, should be set to None after the completion
     ratio = sel.probability_ratio(None, None, None, 1)
     assert ratio == 0.0
 def test_correct_loading():
     sel = SpringShootingSelector(delta_max=1, k_spring=0, initial_guess=3)
     details = Details(initial_trajectory='foo',
                       last_accepted_shooting_index='bar',
                       shooting_index=13,
                       direction='forward')
     step = FakeStep(details)
     sel.restart_from_step(step)
     assert sel.previous_trajectory == 'foo'
     assert sel.previous_snapshot == 'bar'
     assert sel.trial_snapshot == 13
     details.direction = 'backward'
     step = FakeStep(details)
     sel.restart_from_step(step)
     assert sel.trial_snapshot == 10
 def test_sanity_breaking_total():
     sel = SpringShootingSelector(delta_max=1, k_spring=1)
     sel._total_bias = sum([0, 0, 0])
     with pytest.raises(RuntimeError):
         sel.check_sanity()
    def test_sanity_breaking_bw():
        sel = SpringShootingSelector(delta_max=1, k_spring=1)
        sel._bw_prob_list = [0, 0, 0]

        with pytest.raises(RuntimeError):
            sel.check_sanity()
 def test_pos_k():
     sel = SpringShootingSelector(delta_max=1, k_spring=1)
     assert sel.k_spring == 1
 def test_0_k():
     sel = SpringShootingSelector(delta_max=1, k_spring=0)
     ref_list = [1.0, 1.0, 1.0]
     assert sel.k_spring == 0
     assert sel._fw_prob_list == ref_list
     assert sel._bw_prob_list == ref_list
 def test_neg_k():
     with pytest.raises(ValueError):
         SpringShootingSelector(delta_max=1, k_spring=-1)
 def test_pos_delta():
     delta_max = 1
     sel = SpringShootingSelector(delta_max=delta_max, k_spring=0.1)
     assert sel.delta_max == delta_max
     assert len(sel._fw_prob_list) == 2 * delta_max + 1
     assert len(sel._bw_prob_list) == 2 * delta_max + 1
 def test_0_delta():
     with pytest.raises(ValueError):
         SpringShootingSelector(delta_max=0, k_spring=0.1)
 def test_sanity_breaking_bw_pick(self):
     sel = SpringShootingSelector(delta_max=1, k_spring=1)
     sel._bw_prob_list = [0, 0, 0]
     with pytest.raises(RuntimeError):
         sel.pick(trajectory=self.mytraj, direction='forward')
 def test_failed_loading():
     sel = SpringShootingSelector(delta_max=1, k_spring=0, initial_guess=3)
     details = Details(foo='bar')
     step = FakeStep(details)
     with pytest.raises(RuntimeError):
         sel.restart_from_step(step)
 def test_sanity_breaking_total_pick(self):
     sel = SpringShootingSelector(delta_max=1, k_spring=1)
     sel._total_bias = sum([0, 0, 0])
     with pytest.raises(RuntimeError):
         sel.pick(trajectory=self.mytraj, direction='forward')
 def test_impossible_pick(self):
     sel = SpringShootingSelector(delta_max=1, k_spring=1, initial_guess=12)
     sel.pick(trajectory=self.mytraj, direction='forward')
     assert sel._acceptable_snapshot is False
 def test_pick_direction(self):
     sel = SpringShootingSelector(delta_max=1, k_spring=1)
     with pytest.raises(RuntimeError):
         sel.pick(trajectory=self.mytraj)
 def test_initial_guess():
     sel = SpringShootingSelector(delta_max=1, k_spring=1, initial_guess=12)
     assert sel.trial_snapshot == 12
     assert sel.previous_snapshot == 12