Skip to content

Commit 55157ac

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4eaf6d8 commit 55157ac

File tree

6 files changed

+209
-231
lines changed

6 files changed

+209
-231
lines changed

pylint_ml/checkers/numpy/numpy_parameter.py

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,56 +22,51 @@ class NumPyParameterChecker(BaseChecker):
2222

2323
REQUIRED_PARAMS = {
2424
# Array Creation
25-
'array': ['object'],
26-
'zeros': ['shape'],
27-
'ones': ['shape'],
28-
'full': ['shape', 'fill_value'],
29-
'empty': ['shape'],
30-
'arange': ['start'],
31-
'linspace': ['start', 'stop'],
32-
'logspace': ['start', 'stop'],
33-
'eye': ['N'],
34-
'identity': ['n'],
35-
25+
"array": ["object"],
26+
"zeros": ["shape"],
27+
"ones": ["shape"],
28+
"full": ["shape", "fill_value"],
29+
"empty": ["shape"],
30+
"arange": ["start"],
31+
"linspace": ["start", "stop"],
32+
"logspace": ["start", "stop"],
33+
"eye": ["N"],
34+
"identity": ["n"],
3635
# Random Sampling
37-
'random.rand': ['d0'],
38-
'random.randn': ['d0'],
39-
'random.randint': ['low', 'high'],
40-
'random.choice': ['a'],
41-
'random.uniform': ['low', 'high'],
42-
'random.normal': ['loc', 'scale'],
43-
36+
"random.rand": ["d0"],
37+
"random.randn": ["d0"],
38+
"random.randint": ["low", "high"],
39+
"random.choice": ["a"],
40+
"random.uniform": ["low", "high"],
41+
"random.normal": ["loc", "scale"],
4442
# Mathematical Functions
45-
'sum': ['a'],
46-
'mean': ['a'],
47-
'median': ['a'],
48-
'std': ['a'],
49-
'var': ['a'],
50-
'prod': ['a'],
51-
'min': ['a'],
52-
'max': ['a'],
53-
'ptp': ['a'],
54-
43+
"sum": ["a"],
44+
"mean": ["a"],
45+
"median": ["a"],
46+
"std": ["a"],
47+
"var": ["a"],
48+
"prod": ["a"],
49+
"min": ["a"],
50+
"max": ["a"],
51+
"ptp": ["a"],
5552
# Array Manipulation
56-
'reshape': ['newshape'],
57-
'transpose': [],
58-
'concatenate': ['arrays'],
59-
'stack': ['arrays'],
60-
'vstack': ['arrays'],
61-
'hstack': ['arrays'],
62-
53+
"reshape": ["newshape"],
54+
"transpose": [],
55+
"concatenate": ["arrays"],
56+
"stack": ["arrays"],
57+
"vstack": ["arrays"],
58+
"hstack": ["arrays"],
6359
# Linear Algebra
64-
'dot': ['a', 'b'],
65-
'matmul': ['a', 'b'],
66-
'linalg.inv': ['a'],
67-
'linalg.eig': ['a'],
68-
'linalg.solve': ['a', 'b'],
69-
60+
"dot": ["a", "b"],
61+
"matmul": ["a", "b"],
62+
"linalg.inv": ["a"],
63+
"linalg.eig": ["a"],
64+
"linalg.solve": ["a", "b"],
7065
# Statistical Functions
71-
'percentile': ['a', 'q'],
72-
'quantile': ['a', 'q'],
73-
'corrcoef': ['x'],
74-
'cov': ['m'],
66+
"percentile": ["a", "q"],
67+
"quantile": ["a", "q"],
68+
"corrcoef": ["x"],
69+
"cov": ["m"],
7570
}
7671

7772
@only_required_for_messages("numpy-parameter")
@@ -105,6 +100,5 @@ def _get_full_method_name(node: nodes.Call) -> str:
105100

106101
# Check if the root of the chain is "np" (as NumPy functions are expected to use np. prefix)
107102
if isinstance(func, nodes.Name) and func.name == "np":
108-
return '.'.join(method_chain)
103+
return ".".join(method_chain)
109104
return ""
110-

pylint_ml/checkers/pandas/pandas_parameter.py

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,53 +23,43 @@ class PandasParameterChecker(BaseChecker):
2323
# Define required parameters for specific Pandas classes and methods
2424
REQUIRED_PARAMS = {
2525
# DataFrame creation
26-
'DataFrame': ['data'], # The primary input data for DataFrame creation
27-
26+
"DataFrame": ["data"], # The primary input data for DataFrame creation
2827
# Concatenation
29-
'concat': ['objs'], # The list or dictionary of DataFrames/Series to concatenate
30-
28+
"concat": ["objs"], # The list or dictionary of DataFrames/Series to concatenate
3129
# DataFrame I/O (Input/Output)
32-
'read_csv': ['filepath_or_buffer', 'dtype'], # Path to CSV file or file-like object; column data types
33-
'read_excel': ['io', 'dtype'], # Path to Excel file or file-like object; column data types
34-
'read_table': ['filepath_or_buffer', 'dtype'], # Path to delimited text-file or file object; column data types
35-
'to_csv': ['path_or_buf'], # File path or buffer to write the DataFrame to
36-
'to_excel': ['excel_writer'], # File path or ExcelWriter object to write the data to
37-
30+
"read_csv": ["filepath_or_buffer", "dtype"], # Path to CSV file or file-like object; column data types
31+
"read_excel": ["io", "dtype"], # Path to Excel file or file-like object; column data types
32+
"read_table": ["filepath_or_buffer", "dtype"], # Path to delimited text-file or file object; column data types
33+
"to_csv": ["path_or_buf"], # File path or buffer to write the DataFrame to
34+
"to_excel": ["excel_writer"], # File path or ExcelWriter object to write the data to
3835
# Merging and Joining
39-
'merge': ['right', 'how', 'on', 'validate'], # The DataFrame or Serie to merge with
40-
'join': ['other'], # The DataFrame or Series to join
41-
36+
"merge": ["right", "how", "on", "validate"], # The DataFrame or Serie to merge with
37+
"join": ["other"], # The DataFrame or Series to join
4238
# DataFrame Operations
43-
'pivot_table': ['index'], # The column to pivot on (values and columns have defaults)
44-
'groupby': ['by'], # The key or list of keys to group by
45-
'resample': ['rule'], # The frequency rule to resample by
46-
39+
"pivot_table": ["index"], # The column to pivot on (values and columns have defaults)
40+
"groupby": ["by"], # The key or list of keys to group by
41+
"resample": ["rule"], # The frequency rule to resample by
4742
# Data Cleaning and Transformation
48-
'fillna': ['value'], # Value to use to fill NA/NaN values
49-
'drop': ['labels'], # Labels to drop
50-
'drop_duplicates': ['subset'], # Subset of columns to consider when dropping duplicates
51-
'replace': ['to_replace'], # Values to replace
52-
43+
"fillna": ["value"], # Value to use to fill NA/NaN values
44+
"drop": ["labels"], # Labels to drop
45+
"drop_duplicates": ["subset"], # Subset of columns to consider when dropping duplicates
46+
"replace": ["to_replace"], # Values to replace
5347
# Plotting
54-
'plot': ['x'], # x-values or index for plotting
55-
'hist': ['column'], # Column to plot the histogram for
56-
'boxplot': ['column'], # Column(s) to plot boxplot for
57-
48+
"plot": ["x"], # x-values or index for plotting
49+
"hist": ["column"], # Column to plot the histogram for
50+
"boxplot": ["column"], # Column(s) to plot boxplot for
5851
# DataFrame Sorting
59-
'sort_values': ['by'], # Column(s) to sort by
60-
'sort_index': ['axis'], # Axis to sort along (index=0, columns=1)
61-
52+
"sort_values": ["by"], # Column(s) to sort by
53+
"sort_index": ["axis"], # Axis to sort along (index=0, columns=1)
6254
# Statistical Functions
63-
'corr': ['method'], # Method to use for correlation ('pearson', 'kendall', 'spearman')
64-
'describe': [], # No required parameters, but additional ones could be specified
65-
55+
"corr": ["method"], # Method to use for correlation ('pearson', 'kendall', 'spearman')
56+
"describe": [], # No required parameters, but additional ones could be specified
6657
# Windowing/Resampling Functions
67-
'rolling': ['window'], # Size of the moving window
68-
'ewm': ['span'], # Span for exponentially weighted calculations
69-
58+
"rolling": ["window"], # Size of the moving window
59+
"ewm": ["span"], # Span for exponentially weighted calculations
7060
# Miscellaneous Functions
71-
'apply': ['func'], # Function to apply to the data
72-
'agg': ['func'], # Function or list of functions for aggregation
61+
"apply": ["func"], # Function to apply to the data
62+
"agg": ["func"], # Function or list of functions for aggregation
7363
}
7464

7565
@only_required_for_messages("pandas-parameter")

pylint_ml/checkers/scipy/scipy_parameter.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,21 @@ class ScipyParameterChecker(BaseChecker):
2323
# Define required parameters for specific Scipy classes and methods
2424
REQUIRED_PARAMS = {
2525
# scipy.optimize
26-
'minimize': ['fun', 'x0'],
27-
'curve_fit': ['f', 'xdata', 'ydata'],
28-
'root': ['fun', 'x0'],
29-
26+
"minimize": ["fun", "x0"],
27+
"curve_fit": ["f", "xdata", "ydata"],
28+
"root": ["fun", "x0"],
3029
# scipy.integrate
31-
'quad': ['func', 'a', 'b'],
32-
'dblquad': ['func', 'a', 'b', 'gfun', 'hfun'],
33-
'solve_ivp': ['fun', 't_span', 'y0'],
34-
30+
"quad": ["func", "a", "b"],
31+
"dblquad": ["func", "a", "b", "gfun", "hfun"],
32+
"solve_ivp": ["fun", "t_span", "y0"],
3533
# scipy.stats
36-
'ttest_ind': ['a', 'b'],
37-
'ttest_rel': ['a', 'b'],
38-
'norm.pdf': ['x'],
39-
34+
"ttest_ind": ["a", "b"],
35+
"ttest_rel": ["a", "b"],
36+
"norm.pdf": ["x"],
4037
# scipy.spatial
41-
'distance.euclidean': ['u', 'v'], # Full chain
42-
'euclidean': ['u', 'v'], # Direct import of euclidean
43-
'KDTree.query': ['x'],
38+
"distance.euclidean": ["u", "v"], # Full chain
39+
"euclidean": ["u", "v"], # Direct import of euclidean
40+
"KDTree.query": ["x"],
4441
}
4542

4643
@only_required_for_messages("scipy-parameter")
@@ -75,4 +72,4 @@ def _get_full_method_name(self, node: nodes.Call) -> str:
7572
if isinstance(func, nodes.Name):
7673
method_chain.insert(0, func.name)
7774

78-
return '.'.join(method_chain)
75+
return ".".join(method_chain)

tests/checkers/test_numpy/test_numpy_parameter.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ def test_array_missing_object(self):
1919
array_call = node.value
2020

2121
with self.assertAddsMessages(
22-
pylint.testutils.MessageTest(
23-
msg_id="numpy-parameter",
24-
confidence=HIGH,
25-
node=array_call,
26-
args=("object", "array"),
27-
),
28-
ignore_position=True,
22+
pylint.testutils.MessageTest(
23+
msg_id="numpy-parameter",
24+
confidence=HIGH,
25+
node=array_call,
26+
args=("object", "array"),
27+
),
28+
ignore_position=True,
2929
):
3030
self.checker.visit_call(array_call)
3131

@@ -40,13 +40,13 @@ def test_zeros_without_shape(self):
4040
zeros_call = node.value
4141

4242
with self.assertAddsMessages(
43-
pylint.testutils.MessageTest(
44-
msg_id="numpy-parameter",
45-
confidence=HIGH,
46-
node=zeros_call,
47-
args=("shape", "zeros"),
48-
),
49-
ignore_position=True,
43+
pylint.testutils.MessageTest(
44+
msg_id="numpy-parameter",
45+
confidence=HIGH,
46+
node=zeros_call,
47+
args=("shape", "zeros"),
48+
),
49+
ignore_position=True,
5050
):
5151
self.checker.visit_call(zeros_call)
5252

@@ -61,13 +61,13 @@ def test_random_rand_without_shape(self):
6161
rand_call = node.value
6262

6363
with self.assertAddsMessages(
64-
pylint.testutils.MessageTest(
65-
msg_id="numpy-parameter",
66-
confidence=HIGH,
67-
node=rand_call,
68-
args=("d0", "random.rand"),
69-
),
70-
ignore_position=True,
64+
pylint.testutils.MessageTest(
65+
msg_id="numpy-parameter",
66+
confidence=HIGH,
67+
node=rand_call,
68+
args=("d0", "random.rand"),
69+
),
70+
ignore_position=True,
7171
):
7272
self.checker.visit_call(rand_call)
7373

@@ -82,13 +82,13 @@ def test_dot_without_b(self):
8282
dot_call = node.value
8383

8484
with self.assertAddsMessages(
85-
pylint.testutils.MessageTest(
86-
msg_id="numpy-parameter",
87-
confidence=HIGH,
88-
node=dot_call,
89-
args=("b", "dot"),
90-
),
91-
ignore_position=True,
85+
pylint.testutils.MessageTest(
86+
msg_id="numpy-parameter",
87+
confidence=HIGH,
88+
node=dot_call,
89+
args=("b", "dot"),
90+
),
91+
ignore_position=True,
9292
):
9393
self.checker.visit_call(dot_call)
9494

@@ -103,12 +103,12 @@ def test_percentile_without_q(self):
103103
percentile_call = node.value
104104

105105
with self.assertAddsMessages(
106-
pylint.testutils.MessageTest(
107-
msg_id="numpy-parameter",
108-
confidence=HIGH,
109-
node=percentile_call,
110-
args=("q", "percentile"),
111-
),
112-
ignore_position=True,
106+
pylint.testutils.MessageTest(
107+
msg_id="numpy-parameter",
108+
confidence=HIGH,
109+
node=percentile_call,
110+
args=("q", "percentile"),
111+
),
112+
ignore_position=True,
113113
):
114114
self.checker.visit_call(percentile_call)

0 commit comments

Comments
 (0)