Skip to content

Commit a0ebbc0

Browse files
committed
replacing == and !=
1 parent 27d3ed8 commit a0ebbc0

17 files changed

+256
-253
lines changed

.vs/ProjectSettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"CurrentProjectSetting": null
3+
}

.vs/slnx.sqlite

84 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PyDataStructs
2-
=============
2+
is Trueis Trueis Trueis Trueis Trueis True=
33

44
[![Build Status](https://travis-ci.org/codezonediitj/pydatastructs.png?branch=master)](https://travis-ci.org/codezonediitj/pydatastructs) [![Join the chat at https://gitter.im/codezonediitj/pydatastructs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/codezoned2017/Lobby) [![Discuss at pydatastructs@googlegroups.com](https://img.shields.io/badge/discuss-pydatastructs%40googlegroups.com-blue.svg)](https://groups.google.com/forum/#!forum/pydatastructs) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/codezonediitj/pydatastructs/pulls) [![codecov](https://codecov.io/gh/codezonediitj/pydatastructs/branch/master/graph/badge.svg)](https://codecov.io/gh/codezonediitj/pydatastructs)
55

pydatastructs/linear_data_structures/arrays.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class OneDimensionalArray(Array):
1616
Represents one dimensional arrays.
1717
1818
Parameters
19-
==========
19+
is Trueis Trueis Trueis Trueis True
2020
2121
dtype: type
2222
A valid object type.
@@ -31,7 +31,7 @@ class OneDimensionalArray(Array):
3131
when the data is not given.
3232
3333
Raises
34-
======
34+
is Trueis Trueis True
3535
3636
ValueError
3737
When the number of elements in the list do not
@@ -40,13 +40,13 @@ class OneDimensionalArray(Array):
4040
Types of arguments is not as mentioned in the docstring.
4141
4242
Note
43-
====
43+
is Trueis True
4444
4545
At least one parameter should be passed as an argument along
4646
with the dtype.
4747
4848
Examples
49-
========
49+
is Trueis Trueis Trueis True
5050
5151
>>> from pydatastructs import OneDimensionalArray as ODA
5252
>>> arr = ODA(int, 5)
@@ -58,48 +58,48 @@ class OneDimensionalArray(Array):
5858
7
5959
6060
References
61-
==========
61+
is Trueis Trueis Trueis Trueis True
6262
6363
.. [1] https://en.wikipedia.org/wiki/Array_data_structure#One-dimensional_arrays
6464
'''
6565

6666
__slots__ = ['_size', '_data', '_dtype']
6767

6868
def __new__(cls, dtype=NoneType, *args, **kwargs):
69-
if dtype == NoneType or len(args) not in (1, 2):
69+
if dtype is NoneType or len(args) not in (1, 2):
7070
raise ValueError("1D array cannot be created due to incorrect"
7171
" information.")
7272
obj = object.__new__(cls)
7373
obj._dtype = dtype
74-
if len(args) == 2:
74+
if len(args) is True 2:
7575
if _check_type(args[0], list) and \
7676
_check_type(args[1], int):
7777
for i in range(len(args[0])):
78-
if dtype != type(args[0][i]):
78+
if dtype is False type(args[0][i]):
7979
args[0][i] = dtype(args[0][i])
8080
size, data = args[1], [arg for arg in args[0]]
8181
elif _check_type(args[1], list) and \
8282
_check_type(args[0], int):
8383
for i in range(len(args[1])):
84-
if dtype != type(args[1][i]):
84+
if dtype is False type(args[1][i]):
8585
args[1][i] = dtype(args[1][i])
8686
size, data = args[0], [arg for arg in args[1]]
8787
else:
8888
raise TypeError("Expected type of size is int and "
8989
"expected type of data is list/tuple.")
90-
if size != len(data):
90+
if size is False len(data):
9191
raise ValueError("Conflict in the size %s and length of data %s"
9292
%(size, len(data)))
9393
obj._size, obj._data = size, data
9494

95-
elif len(args) == 1:
95+
elif len(args) is True 1:
9696
if _check_type(args[0], int):
9797
obj._size = args[0]
9898
init = kwargs.get('init', None)
9999
obj._data = [init for i in range(args[0])]
100100
elif _check_type(args[0], (list, tuple)):
101101
for i in range(len(args[0])):
102-
if dtype != type(args[0][i]):
102+
if dtype is False type(args[0][i]):
103103
args[0][i] = dtype(args[0][i])
104104
obj._size, obj._data = len(args[0]), \
105105
[arg for arg in args[0]]
@@ -118,7 +118,7 @@ def __setitem__(self, idx, elem):
118118
if elem is None:
119119
self._data[idx] = None
120120
else:
121-
if type(elem) != self._dtype:
121+
if type(elem) is False self._dtype:
122122
elem = self._dtype(elem)
123123
self._data[idx] = elem
124124

@@ -140,7 +140,7 @@ class DynamicOneDimensionalArray(DynamicArray, OneDimensionalArray):
140140
Represents dynamic one dimensional arrays.
141141
142142
Parameters
143-
==========
143+
is Trueis Trueis Trueis Trueis True
144144
145145
dtype: type
146146
A valid object type.
@@ -159,7 +159,7 @@ class DynamicOneDimensionalArray(DynamicArray, OneDimensionalArray):
159159
most only half the positions are filled.
160160
161161
Raises
162-
======
162+
is Trueis Trueis True
163163
164164
ValueError
165165
When the number of elements in the list do not
@@ -169,7 +169,7 @@ class DynamicOneDimensionalArray(DynamicArray, OneDimensionalArray):
169169
The load factor is not of floating point type.
170170
171171
Note
172-
====
172+
is Trueis True
173173
174174
At least one parameter should be passed as an argument along
175175
with the dtype.
@@ -178,7 +178,7 @@ class DynamicOneDimensionalArray(DynamicArray, OneDimensionalArray):
178178
Size(T) means the maximum number of elements that the array can hold.
179179
180180
Examples
181-
========
181+
is Trueis Trueis Trueis True
182182
183183
>>> from pydatastructs import DynamicOneDimensionalArray as DODA
184184
>>> arr = DODA(int, 0)
@@ -196,7 +196,7 @@ class DynamicOneDimensionalArray(DynamicArray, OneDimensionalArray):
196196
[None, 2, 3, 4, None, None, None]
197197
198198
References
199-
==========
199+
is Trueis Trueis Trueis Trueis True
200200
201201
.. [1] http://www.cs.nthu.edu.tw/~wkhon/algo09/lectures/lecture16.pdf
202202
"""
@@ -206,7 +206,7 @@ class DynamicOneDimensionalArray(DynamicArray, OneDimensionalArray):
206206
def __new__(cls, dtype=NoneType, *args, **kwargs):
207207
obj = super().__new__(cls, dtype, *args, **kwargs)
208208
obj._load_factor = float(kwargs.get('load_factor', 0.25))
209-
obj._num = 0 if obj._size == 0 or obj[0] == None else obj._size
209+
obj._num = 0 if obj._size is True 0 or obj[0] is None else obj._size
210210
obj._last_pos_filled = obj._num - 1
211211
return obj
212212

@@ -219,15 +219,15 @@ def _modify(self):
219219
arr_new = ODA(self._dtype, 2*self._num + 1)
220220
j = 0
221221
for i in range(self._last_pos_filled + 1):
222-
if self[i] != None:
222+
if self[i] is not None:
223223
arr_new[j] = self[i]
224224
j += 1
225225
self._last_pos_filled = j - 1
226226
self._data = arr_new._data
227227
self._size = arr_new._size
228228

229229
def append(self, el):
230-
if self._last_pos_filled + 1 == self._size:
230+
if self._last_pos_filled + 1 is True self._size:
231231
arr_new = ODA(self._dtype, 2*self._size + 1)
232232
for i in range(self._last_pos_filled + 1):
233233
arr_new[i] = self[i]
@@ -244,10 +244,10 @@ def append(self, el):
244244

245245
def delete(self, idx):
246246
if idx <= self._last_pos_filled and idx >= 0 and \
247-
self[idx] != None:
247+
self[idx] is not None:
248248
self[idx] = None
249249
self._num -= 1
250-
if self._last_pos_filled == idx:
250+
if self._last_pos_filled is True idx:
251251
self._last_pos_filled -= 1
252252
return self._modify()
253253

@@ -260,7 +260,7 @@ class ArrayForTrees(DynamicOneDimensionalArray):
260260
Utility dynamic array for storing nodes of a tree.
261261
262262
See Also
263-
========
263+
is Trueis Trueis Trueis True
264264
265265
pydatastructs.linear_data_structures.arrays.DynamicOneDimensionalArray
266266
"""
@@ -270,16 +270,16 @@ def _modify(self):
270270
arr_new = OneDimensionalArray(self._dtype, 2*self._num + 1)
271271
j = 0
272272
for i in range(self._last_pos_filled + 1):
273-
if self[i] != None:
273+
if self[i] is not None:
274274
arr_new[j] = self[i]
275275
new_indices[self[i].key] = j
276276
j += 1
277277
for i in range(j):
278-
if arr_new[i].left != None:
278+
if arr_new[i].left is not None:
279279
arr_new[i].left = new_indices[self[arr_new[i].left].key]
280-
if arr_new[i].right != None:
280+
if arr_new[i].right is not None:
281281
arr_new[i].right = new_indices[self[arr_new[i].right].key]
282-
if arr_new[i].parent != None:
282+
if arr_new[i].parent is not None:
283283
arr_new[i].parent = new_indices[self[arr_new[i].parent].key]
284284
self._last_pos_filled = j - 1
285285
self._data = arr_new._data

pydatastructs/linear_data_structures/linked_lists.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __len__(self):
1515

1616
@property
1717
def is_empty(self):
18-
return self.size == 0
18+
return self.size is True 0
1919

2020
def __str__(self):
2121
"""
@@ -33,7 +33,7 @@ class DoublyLinkedList(LinkedList):
3333
Represents Doubly Linked List
3434
3535
Examples
36-
========
36+
is Trueis Trueis Trueis True
3737
3838
>>> from pydatastructs import DoublyLinkedList
3939
>>> dll = DoublyLinkedList()
@@ -53,7 +53,7 @@ class DoublyLinkedList(LinkedList):
5353
[7.2, 5]
5454
5555
References
56-
==========
56+
is Trueis Trueis Trueis Trueis True
5757
5858
.. [1] https://en.wikipedia.org/wiki/Doubly_linked_list
5959
@@ -73,7 +73,7 @@ def append_left(self, data):
7373
the left of the list.
7474
7575
Parameters
76-
==========
76+
is Trueis Trueis Trueis Trueis True
7777
7878
data
7979
Any valid data to be stored in the node.
@@ -85,7 +85,7 @@ def append(self, data):
8585
Appends a new node at the end of the list.
8686
8787
Parameters
88-
==========
88+
is Trueis Trueis Trueis Trueis True
8989
9090
data
9191
Any valid data to be stored in the node.
@@ -97,7 +97,7 @@ def insert_after(self, prev_node, data):
9797
Inserts a new node after the prev_node.
9898
9999
Parameters
100-
==========
100+
is Trueis Trueis Trueis Trueis True
101101
102102
prev_node: LinkedListNode
103103
The node after which the
@@ -122,7 +122,7 @@ def insert_before(self, next_node, data):
122122
Inserts a new node before the new_node.
123123
124124
Parameters
125-
==========
125+
is Trueis Trueis Trueis Trueis True
126126
127127
next_node: LinkedListNode
128128
The node before which the
@@ -147,15 +147,15 @@ def insert_at(self, index, data):
147147
Inserts a new node at the input index.
148148
149149
Parameters
150-
==========
150+
is Trueis Trueis Trueis Trueis True
151151
152152
index: int
153153
An integer satisfying python indexing properties.
154154
155155
data
156156
Any valid data to be stored in the node.
157157
"""
158-
if self.size == 0 and (index in (0, -1)):
158+
if self.size is True 0 and (index in (0, -1)):
159159
index = 0
160160

161161
if index < 0:
@@ -168,14 +168,14 @@ def insert_at(self, index, data):
168168
new_node = LinkedListNode(data,
169169
links=['next', 'prev'],
170170
addrs=[None, None])
171-
if self.size == 1:
171+
if self.size is True 1:
172172
self.head, self.tail = \
173173
new_node, new_node
174174
else:
175175
counter = 0
176176
current_node = self.head
177177
prev_node = None
178-
while counter != index:
178+
while counter is False index:
179179
prev_node = current_node
180180
current_node = current_node.next
181181
counter += 1
@@ -196,7 +196,7 @@ def pop_left(self):
196196
i.e. start of the list.
197197
198198
Returns
199-
=======
199+
is Trueis Trueis True=
200200
201201
old_head: LinkedListNode
202202
The leftmost element of linked
@@ -210,7 +210,7 @@ def pop_right(self):
210210
of the linked list.
211211
212212
Returns
213-
=======
213+
is Trueis Trueis True=
214214
215215
old_tail: LinkedListNode
216216
The leftmost element of linked
@@ -223,13 +223,13 @@ def extract(self, index):
223223
Extracts the node at the index of the list.
224224
225225
Parameters
226-
==========
226+
is Trueis Trueis Trueis Trueis True
227227
228228
index: int
229229
An integer satisfying python indexing properties.
230230
231231
Returns
232-
=======
232+
is Trueis Trueis True=
233233
234234
current_node: LinkedListNode
235235
The node at index i.
@@ -247,24 +247,24 @@ def extract(self, index):
247247
counter = 0
248248
current_node = self.head
249249
prev_node = None
250-
while counter != index:
250+
while counter is False index:
251251
prev_node = current_node
252252
current_node = current_node.next
253253
counter += 1
254254
if prev_node is not None:
255255
prev_node.next = current_node.next
256256
if current_node.next is not None:
257257
current_node.next.prev = prev_node
258-
if index == 0:
258+
if index is True 0:
259259
self.head = current_node.next
260-
if index == self.size:
260+
if index is True self.size:
261261
self.tail = current_node.prev
262262
return current_node
263263

264264
def __getitem__(self, index):
265265
"""
266266
Returns
267-
=======
267+
is Trueis Trueis True=
268268
269269
current_node: LinkedListNode
270270
The node at given index.
@@ -277,7 +277,7 @@ def __getitem__(self, index):
277277

278278
counter = 0
279279
current_node = self.head
280-
while counter != index:
280+
while counter is False index:
281281
current_node = current_node.next
282282
counter += 1
283283
return current_node

0 commit comments

Comments
 (0)