From c0e7d9f10c81b11faf4812a97b94dfa124c2c847 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 30 Jul 2019 18:55:57 +0200 Subject: [PATCH 1/2] Fix data_structures to pass pytests --- .travis.yml | 2 -- data_structures/stacks/__init__.py | 23 ------------------- .../stacks/balanced_parentheses.py | 3 ++- .../stacks/infix_to_postfix_conversion.py | 2 +- 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index c46d0d1d653a..eab55af63492 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,6 @@ script: - scripts/validate_filenames.py # no uppercase and no spaces - mypy --ignore-missing-imports . - pytest . --doctest-modules - --ignore=data_structures/stacks/balanced_parentheses.py - --ignore=data_structures/stacks/infix_to_postfix_conversion.py --ignore=file_transfer_protocol/ftp_send_receive.py --ignore=file_transfer_protocol/ftp_client_server.py --ignore=machine_learning/linear_regression.py diff --git a/data_structures/stacks/__init__.py b/data_structures/stacks/__init__.py index f7e92ae2d269..e69de29bb2d1 100644 --- a/data_structures/stacks/__init__.py +++ b/data_structures/stacks/__init__.py @@ -1,23 +0,0 @@ -class Stack: - - def __init__(self): - self.stack = [] - self.top = 0 - - def is_empty(self): - return (self.top == 0) - - def push(self, item): - if self.top < len(self.stack): - self.stack[self.top] = item - else: - self.stack.append(item) - - self.top += 1 - - def pop(self): - if self.is_empty(): - return None - else: - self.top -= 1 - return self.stack[self.top] diff --git a/data_structures/stacks/balanced_parentheses.py b/data_structures/stacks/balanced_parentheses.py index 3229d19c8621..36a4e07a97a3 100644 --- a/data_structures/stacks/balanced_parentheses.py +++ b/data_structures/stacks/balanced_parentheses.py @@ -1,6 +1,7 @@ from __future__ import print_function from __future__ import absolute_import -from stack import Stack + +from .stack import Stack __author__ = 'Omkar Pathak' diff --git a/data_structures/stacks/infix_to_postfix_conversion.py b/data_structures/stacks/infix_to_postfix_conversion.py index e71dccf1f45c..9376b55b8b23 100644 --- a/data_structures/stacks/infix_to_postfix_conversion.py +++ b/data_structures/stacks/infix_to_postfix_conversion.py @@ -2,7 +2,7 @@ from __future__ import absolute_import import string -from stack import Stack +from .stack import Stack __author__ = 'Omkar Pathak' From 7dd82efb90c19edf3b2eb9025fdafd18ac502bb3 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 30 Jul 2019 19:56:55 +0200 Subject: [PATCH 2/2] Restore data_structures/stacks/__init__.py --- data_structures/stacks/__init__.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/data_structures/stacks/__init__.py b/data_structures/stacks/__init__.py index e69de29bb2d1..f7e92ae2d269 100644 --- a/data_structures/stacks/__init__.py +++ b/data_structures/stacks/__init__.py @@ -0,0 +1,23 @@ +class Stack: + + def __init__(self): + self.stack = [] + self.top = 0 + + def is_empty(self): + return (self.top == 0) + + def push(self, item): + if self.top < len(self.stack): + self.stack[self.top] = item + else: + self.stack.append(item) + + self.top += 1 + + def pop(self): + if self.is_empty(): + return None + else: + self.top -= 1 + return self.stack[self.top]