Skip to content

TST: Parametrize and cleanup Exception #28478

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

Merged
merged 7 commits into from
Sep 17, 2019

Conversation

jbrockmendel
Copy link
Member

No description provided.

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments. Generally nice improvement

repr(df)
except Exception as e:
assert type(e) != UnboundLocalError
# Note: this used to be a test that any exception that _is_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just delete altogether? Maybe missing the point but I don't see what this was testing previously

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was added in #2201 / #2200, so there was a bug in the index assignment that raised a "wrong" error when asking for the repr. But nowadays we just don't create an invalid MultiIndex. So I think we should either just remove this test, or update it to check df.index with the expected value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove

@@ -332,78 +331,81 @@ def testit():
expr.set_numexpr_threads()
testit()

def test_bool_ops_raise_on_arithmetic(self):
@pytest.mark.parametrize(
"op,name", list(zip(["/", "//", "**"], ["truediv", "floordiv", "pow"]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think would be nicer to follow the opname, op_str convention for consistency


def test_bool_ops_warn_on_arithmetic(self):
@pytest.mark.parametrize(
"op,name", list(zip(["+", "*", "-"], ["add", "mul", "sub"]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done and done

f = getattr(operator, name)
fe = getattr(operator, sub_funcs[subs[op]])

if op == "-":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this even need to be parametrized if we just return?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning on re-visiting this in an upcoming pass to see if it can be made viable.

@WillAyd WillAyd added the Clean label Sep 17, 2019
@WillAyd WillAyd added this to the 1.0 milestone Sep 17, 2019
Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small style nitpick for future rounds of parameterization.

@@ -332,78 +331,81 @@ def testit():
expr.set_numexpr_threads()
testit()

def test_bool_ops_raise_on_arithmetic(self):
@pytest.mark.parametrize(
"op_str,opname", list(zip(["/", "//", "**"], ["truediv", "floordiv", "pow"]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you find list(zip(...) clearer than writing out the pairs?

[('/', 'truediv'), ...]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Will change in next pass.

@TomAugspurger TomAugspurger merged commit 6110608 into pandas-dev:master Sep 17, 2019
@jbrockmendel jbrockmendel deleted the params branch September 17, 2019 18:23
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants