Skip to content

New instruction of find_intersection in document.#465

Merged
sidra-asa merged 2 commits into
ev-flow:masterfrom
LiangPPP:master
Feb 14, 2023
Merged

New instruction of find_intersection in document.#465
sidra-asa merged 2 commits into
ev-flow:masterfrom
LiangPPP:master

Conversation

@LiangPPP

@LiangPPP LiangPPP commented Feb 14, 2023

Copy link
Copy Markdown
Contributor

find_intersection

The algorithm of find_intersection

The find_intersection method takes in two sets, first_method_set and
second_method_set, and finds their intersection using a recursive search algorithm.

Here is the process of find_intersection

1. Check that the input sets are not empty. 
    If one of the sets is empty, raise a ValueError.
  
2. Use the & operator to find the intersection of the two sets. 
    If the intersection is not empty, return the resulting set.
  
3. If the intersection is empty, call the method_recursive_search 
    function with the input sets and a specified maximum depth.
  
4. The method_recursive_search function recursively searches for 
    the intersection of the two input sets up to the specified depth 
    by splitting the sets into subsets and comparing each subset's elements. 
      - If the intersection is found, return the resulting set. 
      - Otherwise, return None.

The code of find_intersection

    def find_intersection(self, first_method_set, second_method_set, depth=1):
        """
        Find the first_method_list ∩ second_method_list.
        [MethodAnalysis, MethodAnalysis,...]
        :param first_method_set: first list that contains each MethodAnalysis.
        :param second_method_set: second list that contains each MethodAnalysis.
        :param depth: maximum number of recursive search functions.
        :return: a set of first_method_list ∩ second_method_list or None.
        """
        # Check both lists are not null
        if not first_method_set or not second_method_set:
            raise ValueError("Set is Null")
        # find ∩
        result = first_method_set & second_method_set
        if result:
            return result
        else:
            return self.method_recursive_search(
                depth, first_method_set, second_method_set
            )

@sidra-asa sidra-asa self-requested a review February 14, 2023 06:28
@sidra-asa sidra-asa added documentation Improvements or additions to documentation work-in-progress The issue or pull request is currently work-in-progress pr-processing-state-04 labels Feb 14, 2023
@LiangPPP LiangPPP changed the title Update quark_method_reference.rst New document file quark_method_reference.rst Feb 14, 2023
@LiangPPP LiangPPP changed the title New document file quark_method_reference.rst New document file quark_method_reference.rst and new instruction of ffind_intersection in document. Feb 14, 2023
@LiangPPP LiangPPP changed the title New document file quark_method_reference.rst and new instruction of ffind_intersection in document. New instruction of find_intersection in document. Feb 14, 2023
@sidra-asa

Copy link
Copy Markdown
Collaborator

@LiangPPP

Welcome!
Could you update the alignment style of the algorithm description?
You can refer to the previous doc.

@pulorsok

Copy link
Copy Markdown
Member

LGTM

@sidra-asa sidra-asa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation pr-processing-state-04 work-in-progress The issue or pull request is currently work-in-progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants