Skip to content

Commit 58989bf

Browse files
committed
Fix flake8 warnings
1 parent f88c34e commit 58989bf

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

pyindicators/indicators/average_true_range.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ def atr(
4747
# Polars version
4848
df = data.with_columns([
4949
(pl.col("High") - pl.col("Low")).alias("H_L"),
50-
(pl.col("High") - pl.col(source_column).shift(1)).abs().alias("H_Cp"),
51-
(pl.col("Low") - pl.col(source_column).shift(1)).abs().alias("L_Cp"),
50+
(pl.col("High") -
51+
pl.col(source_column).shift(1)).abs().alias("H_Cp"),
52+
(pl.col("Low") -
53+
pl.col(source_column).shift(1)).abs().alias("L_Cp"),
5254
])
5355

5456
# True Range = max of H-L, H-Cprev, L-Cprev

pyindicators/indicators/bollinger_bands.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import Union
22
from pandas import DataFrame as PdDataFrame
33
from polars import DataFrame as PlDataFrame
4-
import pandas as pd
54
import polars as pl
65
from pyindicators.exceptions import PyIndicatorException
76

@@ -42,7 +41,9 @@ def bollinger_bands(
4241
])
4342

4443
else:
45-
raise PyIndicatorException("Input data must be a pandas or polars DataFrame.")
44+
raise PyIndicatorException(
45+
"Input data must be a pandas or polars DataFrame."
46+
)
4647

4748

4849
def bollinger_width(
@@ -71,12 +72,15 @@ def bollinger_width(
7172
if isinstance(data, PdDataFrame):
7273
data[result_column] = data['BB_upper_temp'] - data['BB_lower_temp']
7374
# Drop temporary columns
74-
data = data.drop(columns=['BB_middle_temp', 'BB_upper_temp', 'BB_lower_temp'])
75+
data = data.drop(
76+
columns=['BB_middle_temp', 'BB_upper_temp', 'BB_lower_temp']
77+
)
7578
return data
7679

7780
elif isinstance(data, PlDataFrame):
7881
return data.with_columns(
79-
(pl.col('BB_upper_temp') - pl.col('BB_lower_temp')).alias(result_column)
82+
(pl.col('BB_upper_temp') -
83+
pl.col('BB_lower_temp')).alias(result_column)
8084
).drop(['BB_middle_temp', 'BB_upper_temp', 'BB_lower_temp'])
8185

8286
else:

pyindicators/indicators/divergence.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ def bullish_divergence(
286286
or second_column_lows not in data.columns:
287287

288288
# Check if the two columns are in the data
289-
if first_column not in data.columns or second_column not in data.columns:
289+
if first_column not in data.columns \
290+
or second_column not in data.columns:
290291
raise PyIndicatorException(
291292
f"{first_column} and {second_column} columns "
292293
"are required in the data"
@@ -412,7 +413,8 @@ def bearish_divergence(
412413
or second_column_highs not in data.columns:
413414

414415
# Check if the two columns are in the data
415-
if first_column not in data.columns or second_column not in data.columns:
416+
if first_column not in data.columns \
417+
or second_column not in data.columns:
416418
raise PyIndicatorException(
417419
f"{first_column} and {second_column} columns "
418420
"are required in the data"
@@ -464,6 +466,7 @@ def bearish_divergence(
464466
df[result_column] = result
465467
return pl.DataFrame(df) if is_polars else df
466468

469+
467470
def bearish_divergence_multi_dataframe(
468471
first_df: Union[pd.DataFrame, pl.DataFrame],
469472
second_df: Union[pd.DataFrame, pl.DataFrame],

0 commit comments

Comments
 (0)