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

balance wrong property #2

Closed
alexeykarnachev opened this issue Aug 22, 2017 · 2 comments
Closed

balance wrong property #2

alexeykarnachev opened this issue Aug 22, 2017 · 2 comments

Comments

@alexeykarnachev
Copy link

It looks like a typo in lob.py (436:447).

    if self.balance_factor > 1:
        # right is heavier
        if self.right_child.balance < 0:
            # right_child.left is heavier, RL case
            self._rl_case()
        elif self.right_child.balance > 0:
            # right_child.right is heavier, RR case
            self._rr_case()
    elif self.balance_factor < -1:
        # left is heavier
        if self.left_child.balance < 0:
            # left_child.left is heavier, LL case
            self._ll_case()
        elif self.left_child.balance > 0:
            # left_child.right is heavier, LR case
            self._lr_case()

Should be changed to

    if self.balance_factor > 1:
        # right is heavier
        if self.right_child.balance_factor < 0:
            # right_child.left is heavier, RL case
            self._rl_case()
        elif self.right_child.balance_factor > 0:
            # right_child.right is heavier, RR case
            self._rr_case()
    elif self.balance_factor < -1:
        # left is heavier
        if self.left_child.balance_factor < 0:
            # left_child.left is heavier, LL case
            self._ll_case()
        elif self.left_child.balance_factor > 0:
            # left_child.right is heavier, LR case
            self._lr_case()

Because there is no such property "balance", but only "balance_factor"

@deepbrook
Copy link
Collaborator

You are correct. Thanks for reporting! I'll get on it right away.

@deepbrook
Copy link
Collaborator

Fixed

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