Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in get_rank method of Hyperedge View #212

Closed
devendragovil opened this issue Aug 6, 2023 · 1 comment
Closed

Bug in get_rank method of Hyperedge View #212

devendragovil opened this issue Aug 6, 2023 · 1 comment

Comments

@devendragovil
Copy link
Contributor

devendragovil commented Aug 6, 2023

What

There were a couple of bugs w.r.t get_rank method in Hyperedge View.

Details

The relevant code is present below

    def get_rank(self, e):
        """Get rank.

        Parameters
        ----------
        e : Iterable, Hashable or HyperEdge

        Returns
        -------
        int, the rank of the hyperedge e
        """
        if isinstance(e, Iterable):
            if len(e) == 0:
                return 0
            else:
                for i in list(self.allranks):
                    if frozenset(e) in self.hyperedge_dict[i]:
                        return i
                raise KeyError(f"hyperedge {e} is not in the complex")

        elif isinstance(e, HyperEdge):

            if len(e) == 0:
                return 0
            else:
                for i in list(self.allranks):

                    if frozenset(e.elements) in self.hyperedge_dict[i]:
                        return i
                raise KeyError(f"hyperedge {e} is not in the complex")

        elif isinstance(e, Hashable) and not isinstance(e, Iterable):

            if e in self.hyperedge_dict[0]:
                return 0
            else:
                raise KeyError(f"hyperedge {e} is not in the complex")

        elif isinstance(e, str):

            if e in self.hyperedge_dict[0]:
                return 0
            else:
                raise KeyError(f"hyperedge {e} is not in the complex")

Bugs

  1. The hyperedge case in the above if-else block is never triggered because hyperedge itself is Iterable.
  2. The str case in the above if-else block is never triggered because str itself is Iterable.
  3. The cases where e is int or str never evaluates to True, because the int/str are not present in hyperedge_dict, but rather frozenset({e}) is
@mhajij mhajij closed this as completed in 0c49ec2 Aug 10, 2023
@mhajij
Copy link
Member

mhajij commented Aug 13, 2023

please open a pull request and fix the above errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants