Skip to content

Added Stack data structure in linear data structures #11

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

Closed
wants to merge 4 commits into from
Closed

Added Stack data structure in linear data structures #11

wants to merge 4 commits into from

Conversation

Kartikei-12
Copy link

Added stack data structure, with appropriate tests written using unittests python testing framework.

References

Stack data structure

Verified

This commit was signed with the committer’s verified signature.

Verified

This commit was signed with the committer’s verified signature.
…ding to numpy doc format

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@@ -5,5 +5,6 @@ python:
install:
- pip install -r requirements.txt
script:
- python -m unittest discover pydatastructs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed. The current framework of pydatastructs uses pytest for testing. Please remove this

@czgdp1807
Copy link
Member

This PR looks good. Just do one thing rewrite the tests. Follow the pattern given here in this file.
Do not close this PR. Just update the branch.

.replace("<class '", '', 1)\
.replace("<type '", '', 1)\
.replace("'>", '', 1)
_check_type = lambda a, t: isinstance(a, t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import _check_type from the arrays.py file.

max_size : int, optional
Maximum size of stack allowed
type_restriction : list, optional
List of types(as strings) for element which can be inserted into Stack, provide empty list for no restrictions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this line into 2.

>>> my_stack.push(2)
>>> my_stack.pop()
2
>>> print(my_stack)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use print, try using my_stack directly.

"""
Used for printing
"""
return "<Stack length:{}>".format(str(self.stack))
Copy link
Member

@czgdp1807 czgdp1807 Jun 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return the whole stack contents in a standard list format, which can be reused. Something like, return str(self.stack).

"""

def __init__(
self, max_size=10 ** 15, type_restriction=list()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the max size unbounded. We can keep it dependent on the amount of memory available.

@czgdp1807
Copy link
Member

Or, otherwise DO NOT make any changes for now, I will make a PR to your branch with the desired modifications. You can merge that PR there and I will merge it here. Thanks.

@czgdp1807 czgdp1807 mentioned this pull request Jun 25, 2019
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

Successfully merging this pull request may close these issues.

None yet

2 participants