Skip to content
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

CLN: Clean-up use of super() in instance methods. #26177

Merged
merged 1 commit into from
Apr 24, 2019

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Apr 21, 2019

Simplifies the use of simple uses of super by converting to use python3 idioms. This is a quite big PR, but only deals with converting super(MyClass, self) to super() so it's very simple.

In addition to the uses of super dealt with in this PR, there are some more advanced uses of super in the code base, e.g. in classmethods and using super to jump to a specific point in the MRO-chain. I'd like to tackle those in a seperate PR in order to keep the the current large PR very simple.

@codecov
Copy link

codecov bot commented Apr 21, 2019

Codecov Report

Merging #26177 into master will decrease coverage by <.01%.
The diff coverage is 90.67%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26177      +/-   ##
==========================================
- Coverage   91.98%   91.98%   -0.01%     
==========================================
  Files         175      175              
  Lines       52371    52371              
==========================================
- Hits        48175    48171       -4     
- Misses       4196     4200       +4
Flag Coverage Δ
#multiple 90.53% <88.13%> (ø) ⬆️
#single 40.71% <27.54%> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/io/clipboard/exceptions.py 71.42% <0%> (ø) ⬆️
pandas/io/clipboard/windows.py 11.11% <0%> (ø) ⬆️
pandas/core/base.py 98.2% <100%> (ø) ⬆️
pandas/core/resample.py 97.22% <100%> (ø) ⬆️
pandas/io/packers.py 88.08% <100%> (ø) ⬆️
pandas/core/algorithms.py 94.78% <100%> (ø) ⬆️
pandas/io/excel/_openpyxl.py 84.71% <100%> (ø) ⬆️
pandas/io/formats/format.py 97.91% <100%> (ø) ⬆️
pandas/io/excel/_xlwt.py 98.48% <100%> (ø) ⬆️
pandas/core/arrays/datetimelike.py 97.69% <100%> (ø) ⬆️
... and 46 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 bbcfc7f...972c8d6. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 21, 2019

Codecov Report

Merging #26177 into master will decrease coverage by <.01%.
The diff coverage is 90.67%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26177      +/-   ##
==========================================
- Coverage   91.98%   91.98%   -0.01%     
==========================================
  Files         175      175              
  Lines       52372    52372              
==========================================
- Hits        48177    48173       -4     
- Misses       4195     4199       +4
Flag Coverage Δ
#multiple 90.53% <88.13%> (ø) ⬆️
#single 40.7% <27.54%> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/io/clipboard/exceptions.py 71.42% <0%> (ø) ⬆️
pandas/io/clipboard/windows.py 11.11% <0%> (ø) ⬆️
pandas/core/base.py 98.2% <100%> (ø) ⬆️
pandas/core/resample.py 97.22% <100%> (ø) ⬆️
pandas/io/packers.py 88.08% <100%> (ø) ⬆️
pandas/core/algorithms.py 94.8% <100%> (ø) ⬆️
pandas/io/excel/_openpyxl.py 84.71% <100%> (ø) ⬆️
pandas/io/formats/format.py 97.91% <100%> (ø) ⬆️
pandas/io/excel/_xlwt.py 98.48% <100%> (ø) ⬆️
pandas/core/arrays/datetimelike.py 97.69% <100%> (ø) ⬆️
... and 46 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 b62e9ae...0d9555c. Read the comment docs.

@jreback jreback added this to the 0.25.0 milestone Apr 21, 2019
@jreback
Copy link
Contributor

jreback commented Apr 21, 2019

lgtm, will merge after I fixup master.

can you do a followup to prohitbit the old style in code-checks (or push to this one ok too)

@topper-123
Copy link
Contributor Author

I can add that to the follow-up, where I take the rest of super.

@WillAyd
Copy link
Member

WillAyd commented Apr 23, 2019

@topper-123 can you merge master?

@topper-123
Copy link
Contributor Author

The failure seems unrelated, don't know what's going on:

  @pytest.mark.parametrize('cache', [True, False])
    def test_string_na_nat_conversion(self, cache):
        # GH #999, #858
    
        strings = np.array(['1/1/2000', '1/2/2000', np.nan,
                            '1/4/2000, 12:34:56'], dtype=object)
    
        expected = np.empty(4, dtype='M8[ns]')
        for i, val in enumerate(strings):
            if isna(val):
                expected[i] = iNaT
            else:
                expected[i] = parse(val)
    
        result = tslib.array_to_datetime(strings)[0]
        tm.assert_almost_equal(result, expected)
    
        result2 = to_datetime(strings, cache=cache)
        assert isinstance(result2, DatetimeIndex)
        tm.assert_numpy_array_equal(result, result2.values)
    
        malformed = np.array(['1/100/2000', np.nan], dtype=object)
    
        # GH 10636, default is now 'raise'
        msg = (r"\(u?'Unknown string format:', '1/100/2000'\)|"
               "day is out of range for month")
        with pytest.raises(ValueError, match=msg):
>           to_datetime(malformed, errors='raise', cache=cache)
E           AssertionError: Pattern '\(u?'Unknown string format:', '1/100/2000'\)|day is out of range for month' not found in 'Unknown string format: 1/100/2000'

@WillAyd
Copy link
Member

WillAyd commented Apr 23, 2019

Certainly strange. Looks like it is a result of this PR though. Maybe revert the changes to pandas/_libs/tslibs/strptime.pyx (or other cython modules) and see if the error disappears - could certainly be differences with how Cython handles super calls versus Python

@topper-123
Copy link
Contributor Author

This error message shows up in #22511 also, so must be something else. If its only my code, its very strange. Ill look into that.

@jreback jreback merged commit 88062f7 into pandas-dev:master Apr 24, 2019
@jreback
Copy link
Contributor

jreback commented Apr 24, 2019

thanks @topper-123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants