How to use the openpathsampling.SampleSet function in openpathsampling

To help you get started, we’ve selected a few openpathsampling examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openpathsampling / openpathsampling / openpathsampling / engines / external / testexternal_engine.py View on Github external
def test_in_shooting_move(self):
        import glob
        for testfile in glob.glob("test*out") + glob.glob("test*inp"):
            os.remove(testfile)
        ens10 = paths.LengthEnsemble(10)
        init_traj = self.fast_engine.generate_forward(self.template, ens10)
        assert_equal(ens10(init_traj), True)
        init_conds = paths.SampleSet([
            paths.Sample(replica=0, ensemble=ens10, trajectory=init_traj)
        ])
        shooter = paths.OneWayShootingMover(ensemble=ens10,
                                            selector=paths.UniformSelector(),
                                            engine=self.fast_engine)
        prev_sample_set = init_conds
        default_traj = [[[0.0]], [[1.0]], [[2.0]], [[3.0]], [[4.0]],
                        [[5.0]], [[6.0]], [[7.0]], [[8.0]], [[9.0]]]
        assert_items_equal(init_conds[0].trajectory.xyz, default_traj)
        for step in range(10):
            assert_equal(len(prev_sample_set), 1)
            change = shooter.move(prev_sample_set)
            new_sample_set = prev_sample_set.apply_samples(change.results)
            assert_items_equal(new_sample_set[0].trajectory.xyz,
                               default_traj)
            prev_traj = prev_sample_set[0].trajectory
github openpathsampling / openpathsampling / openpathsampling / high_level / move_scheme.py View on Github external
Returns
        -------
        :class:`.SampleSet`
            sampleset with samples for every initial ensemble for this
            scheme that could be satisfied by the given trajectories

        See Also
        --------
        list_initial_ensembles
        check_initial_conditions
        assert_initial_conditions
        """

        if sample_set is None:
            sample_set = paths.SampleSet([])

        ensembles = self.list_initial_ensembles()

        sample_set = sample_set.generate_from_trajectories(
            ensembles,
            trajectories,
            preconditions,
            strategies,
            reuse_strategy,
            engine
        )
        refresh_output(self.initial_conditions_report(sample_set),
                       ipynb_display_only=True, print_anyway=False)
        return sample_set
github openpathsampling / openpathsampling / openpathsampling / sample.py View on Github external
Returns
        -------
        missing : list of list of :class:`.Ensemble`
            ensembles needed by the move scheme and missing in the sample
            set, in the format used by `list_initial_ensembles`
        extra : list of :class:`.Ensemble`
            ensembles in the sampleset that are not used by the

        See Also
        --------
        MoveScheme.list_initial_ensembles
        MoveScheme.assert_initial_conditions
        MoveScheme.initial_conditions_report
        """
        samples = paths.SampleSet(self)  # to make a copy
        missing = []
        for ens_list in ensembles:
            if type(ens_list) is not list:
                ens_list = [ens_list]
            sample = None
            for ens in ens_list:
                if ens in samples.ensemble_list():
                    sample = samples[ens]
                    break
            if sample is not None:
                del samples[sample]
            else:
                missing.append(ens_list)

        # missing, extra
        return missing, samples.ensemble_list()
github openpathsampling / openpathsampling / openpathsampling / movepath.py View on Github external
def apply_to(self, other):
        """
        Standard apply is to apply the list of samples contained
        """
        return paths.SampleSet(other).apply_samples(self._local_samples)
github openpathsampling / openpathsampling / openpathsampling / movepath.py View on Github external
def apply_to(self, other):
        """
        Standard apply is to apply the list of samples contained
        """
        new_sampleset = paths.SampleSet(other).apply_samples(self.samples)
        new_sampleset.movepath = self
github openpathsampling / openpathsampling / openpathsampling / pathmover.py View on Github external
def move(self, globalstate):
        filtered_gs = paths.SampleSet(
            [s for s in globalstate if s.replica in self.replicas]
        )
        return self.mover.move(filtered_gs)
github openpathsampling / openpathsampling / openpathsampling / movepath.py View on Github external
Example
        -------
        Assume that you run 3 shooting moves for replica #1. Then only the
        last of the three really matters for the target sample_set since #1
        will be replaced by #2 which will be replaced by #3. So this function
        will return only the last sample.

        See also
        --------
        MovePath.closed
        MovePath.reduced()

        """
        if self._collapsed_samples is None:
            s = paths.SampleSet([]).apply_samples(self.samples)

            # keep order just for being thorough
            self._collapsed_samples = [
                samp for samp in self.samples
                if samp in s
            ]

        return self._collapsed_samples
github openpathsampling / openpathsampling / openpathsampling / movechange.py View on Github external
Return a collapsed set of samples with non used samples removed

        This is the minimum required set of samples to keep the `MoveChange`
        correct and allow to target sampleset to be correctly created.
        These are the samples used by `.closed`

        Examples
        --------
        Assume that you run 3 shooting moves for replica #1. Then only the
        last of the three really matters for the target sample_set since #1
        will be replaced by #2 which will be replaced by #3. So this function
        will return only the last sample.

        """
        if self._collapsed is None:
            s = paths.SampleSet([]).apply_samples(self.results)

            # keep order just for being thorough
            self._collapsed = [
                samp for samp in self.results
                if samp in s
            ]

        return self._collapsed