clatlan / cdiutils

A python package to help Coherent Diffraction Imaging (CDI) practitioners in their analysis.
MIT License
10 stars 6 forks source link

Return missing in find_phasing_results #24

Closed Manalorca closed 4 months ago

Manalorca commented 7 months ago

Hi Clement,

I think that there is an issue in the methods find_best_candidates/find_phasing_results of the class BcdiPipeline. In the method find_best_candidates, there is a call of the method find_phasing_results :

line 672 : self.phasing_results = self.find_phasing_results(self.phasing_results)

The signature of the method self.find_phasing_results is find_phasing_results(self) -> list .

So first of all, I think the call line 672 should be :

line 672 : self.phasing_results = self.find_phasing_results()

Then, there is no return in the method find_phasing_results :

    def find_phasing_results(self) -> list:
        """
        Find the last phasing results (.cxi files) and add them to the
        given list if provided, otherwise create the list.
        """
        self.phasing_results = []
        fetched_paths = glob.glob(self.pynx_phasing_dir + "/*Run*.cxi")
        for path in fetched_paths:
            if os.path.isfile(path):
                self.phasing_results.append(path)

So I think a return should be added :


    def find_phasing_results(self) -> list:
        """
        Find the last phasing results (.cxi files) and add them to the
        given list if provided, otherwise create the list.
        """
        self.phasing_results = []
        fetched_paths = glob.glob(self.pynx_phasing_dir + "/*Run*.cxi")
        for path in fetched_paths:
            if os.path.isfile(path):
                self.phasing_results.append(path)
        return self.phasing_results

Have a nice day.

Matthieu

clatlan commented 7 months ago

Hello Matthieu, Thanks for the issue. Actually the method find_best_candidate is deprecated. I think I will remove it from the pipeline. Second, I've changed the way the list of best candidates are managed in the pipeline. The method find_phasing_results should not return anything but rather modify the self.phasing_results attribute.

So for the time being, you can now use the combination of analyze_phasing_results() / select_best_candidates(). The latter can accept either a list best_runs of the run numbers or nb_of_best_sorted_runs (int) the number of best runs you want to consider if you had run the analyze_phasing_results() beforehand.

Tell me if it works like that, if not I will take care of it.