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

Add pep8-naming #94

Merged
merged 3 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdmetrics/multi_table/detection/parent_child.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from sdmetrics.multi_table.detection.base import DetectionMetric
from sdmetrics.single_table.detection import LogisticDetection, SVCDetection
from sdmetrics.utils import NestedAttrsMeta
from sdmetrics.utils import nested_attrs_meta


class ParentChildDetectionMetric(DetectionMetric,
metaclass=NestedAttrsMeta('single_table_metric')):
metaclass=nested_attrs_meta('single_table_metric')):
"""Base class for Multi-table Detection metrics based on parent-child relationships.

These metrics denormalize the parent-child relationships from the dataset and then
Expand Down
4 changes: 2 additions & 2 deletions sdmetrics/multi_table/multi_single_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

from sdmetrics import single_table
from sdmetrics.multi_table.base import MultiTableMetric
from sdmetrics.utils import NestedAttrsMeta
from sdmetrics.utils import nested_attrs_meta


class MultiSingleTableMetric(MultiTableMetric, metaclass=NestedAttrsMeta('single_table_metric')):
class MultiSingleTableMetric(MultiTableMetric, metaclass=nested_attrs_meta('single_table_metric')):
"""MultiTableMetric subclass that applies a SingleTableMetric on each table.

This class can either be used by creating a subclass that inherits from it and
Expand Down
7 changes: 5 additions & 2 deletions sdmetrics/single_table/multi_column_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

from sdmetrics import column_pairs
from sdmetrics.single_table.base import SingleTableMetric
from sdmetrics.utils import NestedAttrsMeta
from sdmetrics.utils import nested_attrs_meta


class MultiColumnPairsMetric(SingleTableMetric, metaclass=NestedAttrsMeta('column_pairs_metric')):
class MultiColumnPairsMetric(
SingleTableMetric,
metaclass=nested_attrs_meta('column_pairs_metric')
):
"""SingleTableMetric subclass that applies a ColumnPairsMetric on each possible column pair.

Attributes:
Expand Down
4 changes: 2 additions & 2 deletions sdmetrics/single_table/multi_single_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

from sdmetrics import single_column
from sdmetrics.single_table.base import SingleTableMetric
from sdmetrics.utils import NestedAttrsMeta
from sdmetrics.utils import nested_attrs_meta


class MultiSingleColumnMetric(SingleTableMetric,
metaclass=NestedAttrsMeta('single_column_metric')):
metaclass=nested_attrs_meta('single_column_metric')):
"""SingleTableMetric subclass that applies a SingleColumnMetric on each column.

This class can either be used by creating a subclass that inherits from it and
Expand Down
4 changes: 2 additions & 2 deletions sdmetrics/single_table/privacy/numerical_sklearn.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.neural_network import MLPRegressor
from sklearn.svm import SVR as svr
from sklearn.svm import SVR

from sdmetrics.single_table.privacy.base import NumericalPrivacyMetric, PrivacyAttackerModel

Expand Down Expand Up @@ -75,7 +75,7 @@ def fit(self, X, Y):
n_labels = Y.shape[1]
for idx in range(n_labels):
Y_col = Y[:, idx]
predictor = svr()
predictor = SVR()
predictor.fit(X, Y_col)
self.predictors.append(predictor)

Expand Down
2 changes: 1 addition & 1 deletion sdmetrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections import Counter


def NestedAttrsMeta(nested):
def nested_attrs_meta(nested):
"""Metaclass factory that defines a Metaclass with a dynamic attribute name."""

class Metaclass(type):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ universal = 1
[flake8]
max-line-length = 99
exclude = docs, .tox, .git, __pycache__, .ipynb_checkpoints
ignore-names = X, Y, X_train, X_test, Y_col
Copy link
Contributor

Choose a reason for hiding this comment

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

Most of this names are very standard and acceptable, but I think this is not true for Y_col.
If it is not a huge change, I'd prefer to remove this from the list and adapt the corresponding code.


[isort]
include_trailing_comment = True
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'flake8>=3.7.7,<4',
'flake8-absolute-import>=1.0,<2',
'isort>=4.3.4,<5',
'pep8-naming>=0.12.1,<0.13',

# fix style issues
'autoflake>=1.1,<2',
Expand Down