Skip to content

Commit 0ab766d

Browse files
committed
Fix most PEP8 issues
I don't know how to truncate remaining long lines without loosing information.
1 parent 7cc4d53 commit 0ab766d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

pandas/tests/groupby/test_custom_metadata.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""
22
Test metadata propagation in groupby
33
4-
The PandasTable class below is implemented according to the [guidelines], and as such would
5-
expect `__finalize__` to always be called so that the `_pandastable_metadata` is always populated.
4+
The PandasTable class below is implemented according to the [guidelines],
5+
and as such would expect `__finalize__` to always be called so that the
6+
`_pandastable_metadata` is always populated.
67
78
[guidelines]: https://pandas.pydata.org/pandas-docs/stable/development/extending.html#override-constructor-properties
89
"""
@@ -38,19 +39,21 @@ def __finalize__(self, other, method=None, **kwargs):
3839
"""
3940
This method is responsible for populating metadata when creating new Table-object.
4041
41-
The method argument is subject to change, and a robust handling of this is implemented
42+
The method argument is subject to change, and a robust handling of this
43+
is implemented.
4244
"""
43-
src = [other] #more logic here in actual implementation
44-
metadata = _combine_metadata([d.get_metadata() for d in src if isinstance(d, PandasTable)])
45+
src = [other] # more logic here in actual implementation
46+
metadata = _combine_metadata(
47+
[d.get_metadata() for d in src if isinstance(d, PandasTable)])
4548

4649
if not metadata:
47-
warn('__finalize__ unable to combine metadata for method "{method}", falling back to DataFrame')
50+
warn('__finalize__ unable to combine metadata for method "{method}", '
51+
'falling back to DataFrame')
4852
return pd.DataFrame(self)
4953
object.__setattr__(self, _TABLE_METADATA_FIELD_NAME, metadata)
5054
return self
5155

5256
def get_metadata(self):
53-
#return object.__getattribute__(self, _TABLE_METADATA_FIELD_NAME)
5457
metadata = getattr(self, _TABLE_METADATA_FIELD_NAME, None)
5558
if metadata is None:
5659
warn('PandasTable object not correctly initialized: no metadata')
@@ -65,16 +68,16 @@ def from_table_data(df: pd.DataFrame, metadata) -> 'PandasTable':
6568

6669
@pytest.fixture
6770
def dft():
68-
df = pd.DataFrame([[11, 12, 0], [21, 22, 0], [31, 32, 1]], columns={'a','b','g'})
69-
return PandasTable.from_table_data(df, 'My metadata')
71+
df = pd.DataFrame([[11, 12, 0], [21, 22, 0], [31, 32, 1]], columns={'a', 'b', 'g'})
72+
return PandasTable.from_table_data(df, 'My metadata')
7073

7174

7275
def test_initial_metadata(dft):
7376
assert dft.get_metadata() == 'My metadata'
7477

7578

7679
def test_basic_propagation(dft):
77-
gg = dft.loc[dft.g==0, :]
80+
gg = dft.loc[dft.g == 0, :]
7881
assert gg.get_metadata() == 'My metadata'
7982

8083

0 commit comments

Comments
 (0)