Repository navigation
incorporate o(1) hash table ds and organize tests - #34
Conversation
PR Summary by QodoAdd O(1) AllOne bucket hash table with targeted pytest coverage Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Flaky tie assertions
|
| def test_dec_rebalance(self): | ||
| ao = AllOne() | ||
| ao.inc("a") | ||
| ao.inc("a") | ||
| ao.inc("b") | ||
| ao.inc("b") | ||
| ao.inc("b") | ||
|
|
||
| ao.dec("b") # b becomes 2 | ||
|
|
||
| assert ao.getMaxKey() == "b" | ||
| assert ao.getMinKey() == "b" | ||
|
|
There was a problem hiding this comment.
1. Flaky tie assertions 🐞 Bug ≡ Correctness
test_dec_rebalance asserts getMaxKey()/getMinKey() return "b" even though the operations leave "a" and "b" tied at count=2, so the structure can legitimately return either key and the test may fail depending on set iteration order/hash seed.
Agent Prompt
## Issue description
`test_dec_rebalance` expects a deterministic key ("b") after decrementing `b` to a count that ties with `a`. The implementation returns an arbitrary key from a `set` for ties, so the test is overspecified and can be flaky.
## Issue Context
After the sequence in `test_dec_rebalance`, counts are `a=2` and `b=2`. `getMaxKey()`/`getMinKey()` return `next(iter(bucket.keys))` where `keys` is a `set`, so either key can be returned.
## Fix Focus Areas
- tests/algorithms/test_bucket_hash_table.py[40-52]
## Suggested change
Update the assertions to accept either key when counts are tied, e.g.:
- `assert ao.getMaxKey() in {"a", "b"}`
- `assert ao.getMinKey() in {"a", "b"}`
(Alternatively, change the test setup so there is a unique max/min key before asserting an exact string.)
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
…ature/bucket_hash_table
No description provided.