Ejemplo n.º 1
0
    def run(self,
            dataset: Dataset,
            results: af.ResultsCollection = None,
            **kwargs) -> af.Result:
        """
        Run the hyper phase and then the hyper_galaxies phase.

        Parameters
        ----------
        dataset
            Data
        results
            Results from previous phases.
        kwargs

        Returns
        -------
        result
            The result of the phase, with a hyper_galaxies result attached as an attribute with the hyper_name of this
            phase.
        """
        self.save_dataset(dataset=dataset)

        results = (copy.deepcopy(results)
                   if results is not None else af.ResultsCollection())

        result = self.phase.run(dataset, results=results, **kwargs)
        results.add(self.phase.paths.phase_name, result)
        hyper_result = self.run_hyper(dataset=dataset,
                                      results=results,
                                      **kwargs)
        setattr(result, self.hyper_name, hyper_result)
        return result
Ejemplo n.º 2
0
    def run(self,
            dataset,
            mask,
            results: af.ResultsCollection = None,
            positions=None,
            info=None,
            **kwargs) -> af.Result:
        """
        Run the phase followed by the hyper_galaxies phases. Each result of a hyper_galaxies phase is attached to the
        overall result object by the hyper_name of that phase.

        Finally, a phase in run with all of the model results from all the individual hyper_galaxies phases.

        Parameters
        ----------
        positions
        mask
        data
            the dataset
        results
            Results from previous phases
        kwargs

        Returns
        -------
        result
            The result of the phase, with hyper_galaxies results attached by associated hyper_galaxies names
        """
        results = results.copy(
        ) if results is not None else af.ResultsCollection()
        result = self.phase.run(dataset=dataset,
                                mask=mask,
                                results=results,
                                positions=positions,
                                info=info,
                                **kwargs)
        results.add(self.phase.paths.phase_name, result)

        for phase in self.hyper_phases:
            hyper_result = phase.run_hyper(dataset=dataset,
                                           results=results,
                                           info=info,
                                           **kwargs)
            setattr(result, phase.hyper_name, hyper_result)

        setattr(result, self.hyper_name,
                self.run_hyper(dataset=dataset, results=results))
        return result