-
Notifications
You must be signed in to change notification settings - Fork 273
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
Added '__slots__' in classes #29 #30
Conversation
Codecov Report
@@ Coverage Diff @@
## master #30 +/- ##
=============================================
+ Coverage 98.203% 98.207% +0.004%
=============================================
Files 15 15
Lines 835 837 +2
=============================================
+ Hits 820 822 +2
Misses 15 15
|
Thanks for the PR. LGTM. Will merge it after some review. |
@@ -84,6 +84,8 @@ def peek(self): | |||
|
|||
class ArrayStack(Stack): | |||
|
|||
__slots__ = ['maxsize', 'top', 'items'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add dtype
to the list as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't make this change.
I will give you a diff
by tonight, which you can apply on top of your changes and push them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I will wait for your changes.
In future PRs, make sure that you do not use |
@udhayacommits Please apply the following diff on your master, diff --git a/pydatastructs/linear_data_structures/arrays.py b/pydatastructs/linear_data_structures/arrays.py
index bf96ee5..cc92c93 100644
--- a/pydatastructs/linear_data_structures/arrays.py
+++ b/pydatastructs/linear_data_structures/arrays.py
@@ -63,9 +63,9 @@ class OneDimensionalArray(Array):
.. [1] https://en.wikipedia.org/wiki/Array_data_structure#One-dimensional_arrays
'''
-
- __slots__ = ['_size', '_data']
-
+
+ __slots__ = ['_size', '_data', '_dtype']
+
def __new__(cls, dtype=NoneType, *args, **kwargs):
if dtype == NoneType or len(args) not in (1, 2):
raise ValueError("1D array cannot be created due to incorrect"
diff --git a/pydatastructs/miscellaneous_data_structures/stack.py b/pydatastructs/miscellaneous_data_structures/stack.py
index e7f75a8..9b82ca4 100644
--- a/pydatastructs/miscellaneous_data_structures/stack.py
+++ b/pydatastructs/miscellaneous_data_structures/stack.py
@@ -84,8 +84,8 @@ class Stack(object):
class ArrayStack(Stack):
- __slots__ = ['maxsize', 'top', 'items']
-
+ __slots__ = ['maxsize', 'top', 'items', 'dtype']
+
def __new__(cls, maxsize=None, top=0, items=None, dtype=int):
if not _check_type(maxsize, int):
raise ValueError("maxsize is missing.")
diff --git a/pydatastructs/trees/binary_trees.py b/pydatastructs/trees/binary_trees.py
index a1d2aec..e8fb820 100644
--- a/pydatastructs/trees/binary_trees.py
+++ b/pydatastructs/trees/binary_trees.py
@@ -182,9 +182,7 @@ class BinarySearchTree(BinaryTree):
pydatastructs.trees.binary_tree.BinaryTree
"""
-
- __slots__ = ['root_idx', 'comparator', 'tree', 'size']
-
+
def insert(self, key, data):
walk = self.root_idx
if self.tree[walk].key == None:
@@ -305,9 +303,6 @@ class AVLTree(BinarySearchTree):
balance_factor = lambda self, node: self.right_height(node) - \
self.left_height(node)
-
- __slots__ = ['root_idx', 'comparator', 'tree', 'size']
-
def _right_rotate(self, j, k):
y = self.tree[k].right
if y != None: Use pds_diff.txt if the above doesn't work. |
@czgdp1807 Please let me know how to apply the diff. I am only getting errors when trying using the text file. |
Are you using |
@czgdp1807 , I was using TortoiseGit that did not work. But the command worked. thanks. |
References to other Issues or PRs or Relevant literature
Fixes #29
Brief description of what is fixed or changed
Added slots to all the classes
http://book.pythontips.com/en/latest/__slots__magic.html
Other comments