-
Notifications
You must be signed in to change notification settings - Fork 508
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
Data Structures and Searching UnitTests Failing #38
Comments
They both work fine for me. I'm using Python 3.5.3 and I installed Does this occur with the changes you made in #37? Maybe the issue is there. |
@MrDupin I think the changes I made caused this |
@MrDupin I've reverted changes in #37 to and test_searching works now. How ever my knowledge of Stacks is essentially none, and test_data_structures is still failing.
# OLD VERSION
return ord(char) >= ord('a') and ord(char) <= ord('z') or ord(char) >= ord('A') and ord(char) <= ord('Z')
# NEW VERISON
return True if ord(char) in [ord(c) for c in list(ascii_letters)] else False |
The above works for me. This is my
I removed the conversion of What is your error message? |
@MrDupin The same as the error above Error
Traceback (most recent call last):
File "C:\Users\doarni\AppData\Local\Continuum\Anaconda3\lib\unittest\case.py", line 58, in testPartExecutor
yield
File "C:\Users\doarni\AppData\Local\Continuum\Anaconda3\lib\unittest\case.py", line 600, in run
testMethod()
File "C:\Users\doarni\Dev\pygorithm\tests\test_data_structure.py", line 39, in test_infix_to_postfix
resultString = result.infix_to_postfix()
File "C:\Users\doarni\Dev\pygorithm\pygorithm\data_structures\stack.py", line 131, in infix_to_postfix
and self.__precedence(self.expression[i] <= self.__precedence(self.my_stack.peek())):
TypeError: unorderable types: str() <= int() |
The error occurs in the |
def infix_to_postfix(self):
"""
function to generate postfix expression from infix expression
"""
postfix = []
for i in range(len(self.expression)):
if self.__is_operand(self.expression[i]):
postfix.append(self.expression[i])
elif self.expression[i] == '(':
self.my_stack.push(self.expression[i])
elif self.expression[i] == ')':
top_operator = self.my_stack.pop()
while not self.my_stack.is_empty() and top_operator != '(':
postfix.append(top_operator)
top_operator = self.my_stack.pop()
else:
while not self.my_stack.is_empty() \
and self.__precedence(self.expression[i] <= self.__precedence(self.my_stack.peek())):
postfix.append(self.my_stack.pop())
self.my_stack.push(self.expression[i])
while not self.my_stack.is_empty():
postfix.append(self.my_stack.pop())
return ' '.join(postfix) |
First of all, you accidentally wrote Second, you removed a parentheses in The tests pass now: https://pastebin.com/vH8KdUEu |
@MrDupin I changed Thank you!!
|
test_data_structures and test_searching.py are failing their UnitTests
test_data_structures
test_searching
The text was updated successfully, but these errors were encountered: