chore: remove dead code and add util tests#11832
chore: remove dead code and add util tests#11832adrioui wants to merge 3 commits intoibis-project:mainfrom
Conversation
ibis/tests/test_util.py
Outdated
| "val", | ||
| [ | ||
| pytest.param([1, 2, 3], id="list"), | ||
| pytest.param({"a": 1}, id="dict"), |
There was a problem hiding this comment.
remove this entire test:
- the dict case isn't being used
- we don't want to guarantee identity stability only equality stability
There was a problem hiding this comment.
well, I guess we can add to the contract that identity is preserved.
but still, we don't need the paramaterization. just simplify to
def test_promote_list_identity():
val = [1,2,3]
assert promote_list(val) is val
There was a problem hiding this comment.
I don't think we should guarantee identity. Why do we need to restrict ourselves here?
There was a problem hiding this comment.
Sure, I'm fine not testing for identity preservation
There was a problem hiding this comment.
Yep. I removed both identity tests. The suite now checks behavior without relying on pointer equality.
ibis/tests/test_util.py
Outdated
| pytest.param((1, 2, 3), id="tuple"), | ||
| ], | ||
| ) | ||
| def test_promote_tuple_identity(val): |
There was a problem hiding this comment.
Simplify to
def test_promote_tuple_identity():
val = (1,2,3)
assert promote_tuple(val) is val
There was a problem hiding this comment.
Per Philips follow up comment in the other thread, actually please let's remove this test for indentity
There was a problem hiding this comment.
Done. I removed the identity test based on Philip's follow-up.
| return node.output_type.__name__ | ||
| except (AttributeError, NotImplementedError): | ||
| return "\u2205" # empty set character | ||
| return "\u2205" # empty set character |
There was a problem hiding this comment.
Can you explain the impact of this change?
There was a problem hiding this comment.
@adrioui Any thoughts here? Doesn't this change break cases where the previous code was hit (as indicated by the comment)?
There was a problem hiding this comment.
This should not break those cases. The old assert crashed on non-Join nodes. Now it falls back to the empty set character. This only makes it more robust.
|
Thanks for the review feedback! I've addressed all comments: Test Simplifications (commits c94cbc7)Simplified both identity tests per your suggestions:
def test_promote_list_identity():
"""Test that lists are returned as-is (same object)."""
val = [1, 2, 3]
assert promote_list(val) is val
def test_promote_tuple_identity():
"""Test that tuples are returned as-is (same object)."""
val = (1, 2, 3)
assert promote_tuple(val) is valImpact Explanation for
|
| def test_promote_list_identity(): | ||
| """Test that lists are returned as-is (same object).""" | ||
| val = [1, 2, 3] | ||
| assert promote_list(val) is val |
There was a problem hiding this comment.
This is overly restrictive. Why do we need to guarantee that the input is pointer-equivalent? We only care that the output is a list.
There was a problem hiding this comment.
Good call. I removed the identity requirement. The tests now check semantic equivalence, which is what callers should depend on.
| def test_promote_tuple_identity(): | ||
| """Test that tuples are returned as-is (same object).""" | ||
| val = (1, 2, 3) | ||
| assert promote_tuple(val) is val |
There was a problem hiding this comment.
Same question as above. Just add it to the parameters of test_promote_tuple. We don't care nor should we care if the objects are identical (only equal).
There was a problem hiding this comment.
Yep. I dropped the identity test instead of plumbing it through test_promote_tuple.
| return node.output_type.__name__ | ||
| except (AttributeError, NotImplementedError): | ||
| return "\u2205" # empty set character | ||
| return "\u2205" # empty set character |
There was a problem hiding this comment.
@adrioui Any thoughts here? Doesn't this change break cases where the previous code was hit (as indicated by the comment)?
33a6386 to
c94cbc7
Compare
Description of changes
visualize.pyforoutput_type.__name__fallback (was marked as TODO for removal)promote_listandpromote_tupleutility functions (resolves TODO in test file)