The Wayback Machine - https://web.archive.org/web/20200914221334/https://github.com/TheAlgorithms/Python/commit/d1b25760bc92d41032a123cb0bbdbd0aff8caadb
Skip to content
Permalink
Browse files

Fix psf/black issues than fail the build (#1935)

* Fix psf/black issues than fail the build

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
  • Loading branch information
cclauss and github-actions committed May 3, 2020
1 parent 9b2d65b commit d1b25760bc92d41032a123cb0bbdbd0aff8caadb
Showing with 12 additions and 8 deletions.
  1. +1 −1 README.md
  2. +9 −4 data_structures/binary_tree/segment_tree_other.py
  3. +2 −3 data_structures/stacks/stack.py
@@ -18,7 +18,7 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.

## Community Channel

We're on [Gitter](https://gitter.im/TheAlgorithms)! Please join us.
We're on [Gitter](https://gitter.im/TheAlgorithms)! Please join us.

## List of Algorithms

@@ -18,7 +18,7 @@ def __init__(self, start, end, val, left=None, right=None):
self.right = right

def __str__(self):
return 'val: %s, start: %s, end: %s' % (self.val, self.start, self.end)
return "val: %s, start: %s, end: %s" % (self.val, self.start, self.end)


class SegmentTree(object):
@@ -131,6 +131,7 @@ class SegmentTree(object):
>>>
"""

def __init__(self, collection: Sequence, function):
self.collection = collection
self.fn = function
@@ -197,7 +198,10 @@ def _query_range(self, node, i, j):
return self._query_range(node.left, i, j)
else:
# range in left child tree and right child tree
return self.fn(self._query_range(node.left, i, node.mid), self._query_range(node.right, node.mid + 1, j))
return self.fn(
self._query_range(node.left, i, node.mid),
self._query_range(node.right, node.mid + 1, j),
)
else:
# range in right child tree
return self._query_range(node.right, i, j)
@@ -217,10 +221,11 @@ def traverse(self):
queue.put(node.right)


if __name__ == '__main__':
if __name__ == "__main__":
import operator

for fn in [operator.add, max, min]:
print('*' * 50)
print("*" * 50)
arr = SegmentTree([2, 1, 5, 3, 4], fn)
for node in arr.traverse():
print(node)
@@ -46,11 +46,11 @@ def is_empty(self):
def size(self):
""" Return the size of the stack."""
return len(self.stack)

def __contains__(self, item) -> bool:
"""Check if item is in stack"""
return item in self.stack


class StackOverflowError(BaseException):
pass
@@ -73,4 +73,3 @@ class StackOverflowError(BaseException):
num = 5
if num in stack:
print(f"{num} is in stack")

0 comments on commit d1b2576

Please sign in to comment.
You can’t perform that action at this time.