-
-
Notifications
You must be signed in to change notification settings - Fork 47k
Numerous significant improvements Beta #12811
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
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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.
Closing. Removing tests is the exact opposite of what is written in CONTRIBUTING.md.
print(f"> atbash_slow(): {timeit('atbash_slow(printable)', setup=setup)} seconds") | ||
print(f"> atbash(): {timeit('atbash(printable)', setup=setup)} seconds") | ||
# Apply both translation mappings | ||
return text.translate(lowercase_map).translate(uppercase_map) |
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.
The goal of benchmark is to measure the speed of the algorithms. Replacing the algorithm defeats the purpose of this function.
|
||
print(f"Original: {test_string}") | ||
print(f"Encoded: {encoded}") | ||
print(f"Decoded: {decoded}") |
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.
These changes are worse than the code that they replace.
This implementation uses integer-only calculations to avoid floating-point errors | ||
and ensure cryptographic correctness. All matrix operations are performed using | ||
exact integer arithmetic. |
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.
WHY ARE YOU REMOVING DOCUMENTATION?!?
19 | ||
>>> hill_cipher.replace_letters('0') | ||
26 | ||
Convert character to its numerical equivalent. |
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.
Describe your change:
butterfly_pattern.py
hill_cipher.py
local_weighted_learning.py
shuffled_shift_cipher.py
(position - self.__shift_key) % -len(self.__key_list)
to(position - self.__shift_key) % key_len
__passcode_creator
return type from list to string__str__
method: Simplifiedreturn "".join(self.__passcode)
toreturn self.__passcode
temp_list.extend(i)
totemp_list.append(i)
key_len = len(self.__key_list)
in encrypt/decrypti
tochar
for readability''.join()
to convert list to stringpascal_triangle.py
List
→list
everywhereList[List[int]]
→list[list[int]]
typing
module importCallable
import source:typing
→collections.abc
collections.abc
beforetimeit
elif
→if
where possibleabove_to_left_elt
→above_left
above_to_right_elt
→above_right
sum_of_digits.py
minimum_spanning_tree_kruskal2.py
Generic
andTypeVar
imports since they're no longer needed[T]
T = TypeVar("T")
as it's now redundantlru_cache.py
TypeVar
definitions forT
andU
since they're no longer neededclass DoubleLinkedListNode(Generic[T, U])
→class DoubleLinkedListNode[T, U]
class DoubleLinkedList(Generic[T, U])
→class DoubleLinkedList[T, U]
class LRUCache(Generic[T, U])
→class LRUCache[T, U]
lfu_cache.py
DoubleLinkedListNode
,DoubleLinkedList
,andLFUCache
to use modern Python 3.12+ generic syntax.class ClassName(Generic[T, U])
with cleanerclass ClassName[T, U]
.stack_with_doubly_linked_list.py
Generic
import andTypeVar
declaration[T]
syntax instead of subclassingGeneric[T]
skew_heap.py
T
T
withAny
type throughout the implementationcomp
to constructorlambda a, b: a < b
for min-heap behaviorX | None
syntaxtest_digital_image_processing.py
array()
withnp.array()
: Due to removal offrom numpy import array
uint8
withnp.uint8
: Due to removal offrom numpy import uint8
minimum_spanning_tree_prims2.py
for
loop syntaxOptional[T]
toT | None
dict.fromkeys()
items()
matrix_class.py
__hash__
type conflict with base class@final
decorator to mark class as unhashable__hash__
assignmentadd_row()
methodadd_column()
method@final
decorator__future__
annotationsbinary_search_tree.py
diff_views_of_binary_tree.py
avl_tree.py
Fixed Problems
Fixed root turning red after deletion
tree.remove(30)
→ Ensures root remains blackRepaired miscalculation in leaf node handling
tree.black_height()
→ Now returns consistent valuesResolved indentation and syntax issues in property checks
check_color_properties()
→ Passes all syntax validationCorrected documentation examples
>>> tree.check_color_properties()
→ Returns True as documentedFixed method signatures and type annotations
def black_height() -> int | None:
→ Clear return typesNew Features
tree.floor(25)
→ Returns largest value ≤25tree.ceil(25)
→ Returns smallest value ≥25node.grandparent
→ Direct grandparent accessnode.sibling
→ Immediate sibling referencetest_insertion_speed()
→ 300,000 inserts in O(log n) timecheck_color_properties()
→ Full RB tree validationtree.verify()
→ Alias for comprehensive checktree.insert(1).insert(2).remove(1)
→ Single-line modificationslist(tree.preorder_traverse())
→ [root, left, right] sequencelist(tree.postorder_traverse())
→ [left, right, root] sequenceAuto-repairs left-left/right-right imbalances
tree.insert(10).insert(5).insert(1)
→ Auto-balancesHandles complex red-black-red cases
tree.remove(20)
→ Maintains color balanceIntegrated doctests → Self-validating documentation
>>> tree.get_min()
→ Auto-verifies during testsdef insert(label: int) -> RedBlackTree:
→ Clear signaturesExpanded suite → Rotation/deletion/query validation
test_floor_ceil()
→ Range query verificationProper None child treatment →
black_height()
accuracyAuto-blackens root post-deletion →
_remove_repair()
final stepConsistent path checking →
black_height()
recursiontree.check_coloring()
→ False on consecutive red nodesChecklist: