Skip to content

#64 Use comparision by reference for bool type objects #66

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 3 commits into from
Dec 26, 2019
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
16 changes: 8 additions & 8 deletions pydatastructs/linear_data_structures/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class OneDimensionalArray(Array):
__slots__ = ['_size', '_data', '_dtype']

def __new__(cls, dtype=NoneType, *args, **kwargs):
if dtype == NoneType or len(args) not in (1, 2):
if dtype is NoneType or len(args) not in (1, 2):
raise ValueError("1D array cannot be created due to incorrect"
" information.")
obj = object.__new__(cls)
Expand Down Expand Up @@ -206,7 +206,7 @@ class DynamicOneDimensionalArray(DynamicArray, OneDimensionalArray):
def __new__(cls, dtype=NoneType, *args, **kwargs):
obj = super().__new__(cls, dtype, *args, **kwargs)
obj._load_factor = float(kwargs.get('load_factor', 0.25))
obj._num = 0 if obj._size == 0 or obj[0] == None else obj._size
obj._num = 0 if obj._size == 0 or obj[0] is None else obj._size
obj._last_pos_filled = obj._num - 1
return obj

Expand All @@ -219,7 +219,7 @@ def _modify(self):
arr_new = ODA(self._dtype, 2*self._num + 1)
j = 0
for i in range(self._last_pos_filled + 1):
if self[i] != None:
if self[i] is not None:
arr_new[j] = self[i]
j += 1
self._last_pos_filled = j - 1
Expand All @@ -244,7 +244,7 @@ def append(self, el):

def delete(self, idx):
if idx <= self._last_pos_filled and idx >= 0 and \
self[idx] != None:
self[idx] is not None:
self[idx] = None
self._num -= 1
if self._last_pos_filled == idx:
Expand All @@ -270,16 +270,16 @@ def _modify(self):
arr_new = OneDimensionalArray(self._dtype, 2*self._num + 1)
j = 0
for i in range(self._last_pos_filled + 1):
if self[i] != None:
if self[i] is not None:
arr_new[j] = self[i]
new_indices[self[i].key] = j
j += 1
for i in range(j):
if arr_new[i].left != None:
if arr_new[i].left is not None:
arr_new[i].left = new_indices[self[arr_new[i].left].key]
if arr_new[i].right != None:
if arr_new[i].right is not None:
arr_new[i].right = new_indices[self[arr_new[i].right].key]
if arr_new[i].parent != None:
if arr_new[i].parent is not None:
arr_new[i].parent = new_indices[self[arr_new[i].parent].key]
self._last_pos_filled = j - 1
self._data = arr_new._data
Expand Down
2 changes: 1 addition & 1 deletion pydatastructs/miscellaneous_data_structures/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __new__(cls, maxsize=None, top=0, items=None, dtype=int):
raise ValueError("maxsize is missing.")
if not _check_type(top, int):
raise TypeError("top is not of type int.")
if items == None:
if items is None:
items = OneDimensionalArray(dtype, maxsize)
if not _check_type(items, OneDimensionalArray):
raise ValueError("items is not of type, OneDimensionalArray")
Expand Down
Loading