Skip to content

Fix psf/black issues than fail the build #1935

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

Merged
merged 2 commits into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 9 additions & 4 deletions data_structures/binary_tree/segment_tree_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -131,6 +131,7 @@ class SegmentTree(object):
>>>

"""

def __init__(self, collection: Sequence, function):
self.collection = collection
self.fn = function
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions data_structures/stacks/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -73,4 +73,3 @@ class StackOverflowError(BaseException):
num = 5
if num in stack:
print(f"{num} is in stack")