Skip to content

Commit 394802a

Browse files
committed
Added Ruff Recommendations
Based on ruff Recommendations - Removed WhiteSpaces - Moved the Import to beginning - Replaced assertTrue with regular assert
1 parent 275dcfd commit 394802a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

data_structures/trie/radix_tree.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import unittest
2+
13
"""
24
A Radix Tree is a data structure that represents a space-optimized
35
trie (prefix tree) in whicheach node that is the only child is merged
46
with its parent [https://en.wikipedia.org/wiki/Radix_tree]
57
"""
6-
import unittest
78

89
class RadixNode:
910
def __init__(self, prefix: str = "", is_leaf: bool = False) -> None:
@@ -204,30 +205,29 @@ def test_trie(self) -> None:
204205
root = RadixNode()
205206
root.insert_many(words)
206207

207-
self.assertTrue(all(root.find(word) for word in words))
208-
self.assertFalse(root.find("bandanas"))
209-
self.assertFalse(root.find("apps"))
208+
assert all(root.find(word) for word in words)
209+
assert not root.find("bandanas")
210+
assert not root.find("apps")
210211
root.delete("all")
211-
self.assertFalse(root.find("all"))
212+
assert not root.find("all")
212213
root.delete("banana")
213-
self.assertFalse(root.find("banana"))
214-
self.assertTrue(root.find("bananas"))
215-
214+
assert not root.find("banana")
215+
assert root.find("bananas")
216216

217217
def test_trie_2(self) -> None:
218218
'''
219219
now add a new test case which inserts
220220
foobbb, fooaaa, foo in the given order and checks for different assertions
221-
'''
221+
'''
222222
words = "foobbb fooaaa foo".split()
223223
root = RadixNode()
224224
root.insert_many(words)
225225

226-
self.assertTrue(all(root.find(word) for word in words))
226+
assert all(root.find(word) for word in words)
227227
root.delete("foo")
228-
self.assertFalse(root.find("foo"))
229-
self.assertTrue(root.find("foobbb"))
230-
self.assertTrue(root.find("fooaaa"))
228+
assert not root.find("foo")
229+
assert root.find("foobbb")
230+
assert root.find("fooaaa")
231231

232232
if __name__ == "__main__":
233233
unittest.main()

0 commit comments

Comments
 (0)