Added doctest to heap.py#11129
Conversation
|
Hey @cclauss , @tianyizheng02 can you please review this PR I am unable to make more contributions as I have reached the limit of 5 open PR |
| return the parent index of given child | ||
|
|
||
| >>> h = Heap() | ||
| >>> h.build_max_heap([103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5]) |
There was a problem hiding this comment.
Let's test with zero, negative integers, floating point numbers, and strings.
Let's test h.parent_index(12) which is NOT in the heap.
We want to test how the algorithm works but also how it fails when given bad input.
|
@cclauss done with the changes |
|
hey @cclauss can you review this please. Thanks! |
cclauss
left a comment
There was a problem hiding this comment.
These tests prove that parent heap is buggy. It returns None when it should be raising a ValueError and it returns float when its type hints promised that it would only return int | None. These bugs should be fixed in a future pull request.
* Added doctest to heap.py * Update heap.py
Describe your change:
Contributes to #9943
Checklist: