Skip to content

Remove return values for asserts #25462

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 20 commits into from
May 7, 2019
Merged

Conversation

samuelsinayoko
Copy link
Contributor

@samuelsinayoko samuelsinayoko commented Feb 27, 2019

Unless they are context managers.

  • closes assert_*_equal issues #25135
  • tests added / passed (not applicable)
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Unless they are context managers.
@WillAyd
Copy link
Member

WillAyd commented Feb 27, 2019

Looks like a slew of test changes as a result of code like assert tm.assert_X_equal which should get updated here.

If you test locally first should make it easier to find up front

@WillAyd WillAyd added Testing pandas testing functions or related to the test suite Clean labels Feb 27, 2019
@WillAyd WillAyd added this to the 0.25.0 milestone Feb 27, 2019
@samuelsinayoko
Copy link
Contributor Author

OK am hoping to fix the tests shortly.

assert either raises or doesn't. If it doesn't tm.assert_* returns None,
and there's no need to assert XXX is None.
@codecov
Copy link

codecov bot commented Mar 3, 2019

Codecov Report

Merging #25462 into master will decrease coverage by 50.01%.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #25462       +/-   ##
===========================================
- Coverage   91.74%   41.72%   -50.02%     
===========================================
  Files         173      173               
  Lines       52923    52922        -1     
===========================================
- Hits        48554    22084    -26470     
- Misses       4369    30838    +26469
Flag Coverage Δ
#multiple ?
#single 41.72% <50%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/util/testing.py 51.57% <50%> (-36%) ⬇️
pandas/io/formats/latex.py 0% <0%> (-100%) ⬇️
pandas/core/categorical.py 0% <0%> (-100%) ⬇️
pandas/io/sas/sas_constants.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/tseries/converter.py 0% <0%> (-100%) ⬇️
pandas/io/formats/html.py 0% <0%> (-99.35%) ⬇️
pandas/core/groupby/categorical.py 0% <0%> (-95.46%) ⬇️
pandas/io/sas/sas7bdat.py 0% <0%> (-91.17%) ⬇️
pandas/io/sas/sas_xport.py 0% <0%> (-90.15%) ⬇️
... and 131 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe1654f...220052a. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 3, 2019

Codecov Report

Merging #25462 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25462      +/-   ##
==========================================
- Coverage   91.98%   91.98%   -0.01%     
==========================================
  Files         175      175              
  Lines       52374    52373       -1     
==========================================
- Hits        48178    48173       -5     
- Misses       4196     4200       +4
Flag Coverage Δ
#multiple 90.53% <100%> (-0.01%) ⬇️
#single 40.72% <44.44%> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/util/testing.py 90.6% <100%> (-0.01%) ⬇️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.9% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94c8c94...f4497fd. Read the comment docs.

@gfyoung
Copy link
Member

gfyoung commented Mar 4, 2019

@samuelsinayoko : This looks much better! I still see a handful of return assert_* statements in that file (assert_almost_equal and assert_series_equal implementations contain the remainder). Can those be removed as well?

@samuelsinayoko
Copy link
Contributor Author

@samuelsinayoko : This looks much better! I still see a handful of return assert_* statements in that file (assert_almost_equal and assert_series_equal implementations contain the remainder). Can those be removed as well?

done in 60ec5ee

@gfyoung
Copy link
Member

gfyoung commented Mar 4, 2019

@samuelsinayoko : I think you only removed the ones in assert_almost_equal. There are still two in assert_series_equal. Were you able to remove those?

@samuelsinayoko
Copy link
Contributor Author

samuelsinayoko commented Mar 4, 2019 via email

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.

lgtm @jreback

@@ -1009,7 +1009,7 @@ def test_fromDict(self):
data = {'a': 0, 'b': 1, 'c': 2, 'd': 3}

series = Series(data)
assert tm.is_sorted(series.index)
tm.is_sorted(series.index)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you rename this routine to tm.assert_is_sorted


elif (is_extension_array_dtype(left) and not is_categorical_dtype(left) and
is_extension_array_dtype(right) and not is_categorical_dtype(right)):
return assert_extension_array_equal(left.array, right.array)
assert_extension_array_equal(left.array, right.array)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

same don't need a return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried this earlier but some of the tests failed so I added the returns back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See 091a00e (this was in response to an earlier PR comment)

@jreback
Copy link
Contributor

jreback commented Mar 26, 2019

can you merge master and update

@samuelsinayoko
Copy link
Contributor Author

samuelsinayoko commented Mar 26, 2019

@jreback have merged master and updated the branch. Don't think I can leave out the return statements as you suggested because that breaks the buil (search back for the build of 091a00e above)

@samuelsinayoko
Copy link
Contributor Author

samuelsinayoko commented Mar 26, 2019 via email

@jreback
Copy link
Contributor

jreback commented Apr 5, 2019

can you merge master and update

@samuelsinayoko
Copy link
Contributor Author

samuelsinayoko commented Apr 5, 2019 via email


elif (is_extension_array_dtype(left) and not is_categorical_dtype(left) and
is_extension_array_dtype(right) and not is_categorical_dtype(right)):
return assert_extension_array_equal(left.array, right.array)
assert_extension_array_equal(left.array, right.array)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

this just returns None which is the same as if you leave the return out, pls remove

@jreback
Copy link
Contributor

jreback commented Apr 20, 2019

can you merge master

@jreback jreback removed this from the 0.25.0 milestone Apr 20, 2019
@WillAyd
Copy link
Member

WillAyd commented Apr 30, 2019

Can you merge and fix up conflicts with master? I think this will be a precursor to #26234

@samuelsinayoko
Copy link
Contributor Author

samuelsinayoko commented Apr 30, 2019 via email

@jreback
Copy link
Contributor

jreback commented May 1, 2019

not exactly sure why, but this surfaced an error in our tests

pushed a patch, let's see

@WillAyd
Copy link
Member

WillAyd commented May 1, 2019

Looks like a test failure in pandas/tests/io/parser/test_textreader.py which is inadvertently expecting a return value from one of the assert functions; if you can take a look

@samuelsinayoko
Copy link
Contributor Author

samuelsinayoko commented May 1, 2019 via email

@jreback
Copy link
Contributor

jreback commented May 5, 2019

i pushed again, let's see

@jreback jreback added this to the 0.25.0 milestone May 7, 2019
@jreback
Copy link
Contributor

jreback commented May 7, 2019

@WillAyd I think we would get a lot of mileage out of typing these assert_* functions, can you create an issue

@jreback jreback merged commit 6df1219 into pandas-dev:master May 7, 2019
@jreback
Copy link
Contributor

jreback commented May 7, 2019

thanks for the patch @samuelsinayoko

@WillAyd
Copy link
Member

WillAyd commented May 7, 2019

@jreback sounds good, though I was actually thinking we'd almost always ignore pandas/tests from static analysis.

In any case opened #26302 so can discuss there as needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assert_*_equal issues
4 participants