From c3b9d247e0c646d47abd1e17a79606adca4dfea9 Mon Sep 17 00:00:00 2001 From: Artem Veremey Date: Tue, 2 Mar 2021 20:12:48 -0800 Subject: [PATCH] Pylint fixes for gamestonk_terminal/prediction_techniques/regression.py and sma.py --- .../prediction_techniques/pred_menu.py | 9 ------ .../prediction_techniques/regression.py | 27 ++++++++++-------- .../prediction_techniques/sma.py | 28 +++++++++++-------- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/gamestonk_terminal/prediction_techniques/pred_menu.py b/gamestonk_terminal/prediction_techniques/pred_menu.py index dc984ea6b40..73c65ec41ec 100644 --- a/gamestonk_terminal/prediction_techniques/pred_menu.py +++ b/gamestonk_terminal/prediction_techniques/pred_menu.py @@ -1,13 +1,4 @@ -from gamestonk_terminal import config_terminal as cfg import argparse -import datetime -from datetime import datetime -from gamestonk_terminal.helper_funcs import * -import pandas as pd -import matplotlib.pyplot as plt -from pandas.plotting import register_matplotlib_converters - -register_matplotlib_converters() from gamestonk_terminal.prediction_techniques import sma from gamestonk_terminal.prediction_techniques import knn diff --git a/gamestonk_terminal/prediction_techniques/regression.py b/gamestonk_terminal/prediction_techniques/regression.py index c46a253c2c5..8fa1cfb4d94 100644 --- a/gamestonk_terminal/prediction_techniques/regression.py +++ b/gamestonk_terminal/prediction_techniques/regression.py @@ -1,29 +1,32 @@ import argparse -import numpy as np -from gamestonk_terminal.helper_funcs import * -import pandas as pd import matplotlib.pyplot as plt +import pandas as pd from pandas.plotting import register_matplotlib_converters - -register_matplotlib_converters() from TimeSeriesCrossValidation import splitTrain from sklearn import linear_model from sklearn import pipeline from sklearn import preprocessing +from gamestonk_terminal.helper_funcs import check_positive, get_next_stock_market_days + +register_matplotlib_converters() + USER_INPUT = 0 LINEAR = 1 QUADRATIC = 2 CUBIC = 3 # -------------------------------------------------- REGRESSION -------------------------------------------------- +# pylint: disable=unused-argument def regression(l_args, s_ticker, s_interval, df_stock, polynomial): parser = argparse.ArgumentParser( prog="regression", - description="""Regression attempts to model the relationship between - two variables by fitting a linear/quadratic/cubic/other equation to - observed data. One variable is considered to be an explanatory variable, - and the other is considered to be a dependent variable. """, + description=""" + Regression attempts to model the relationship between + two variables by fitting a linear/quadratic/cubic/other equation to + observed data. One variable is considered to be an explanatory variable, + and the other is considered to be a dependent variable. + """, ) parser.add_argument( @@ -126,7 +129,7 @@ def regression(l_args, s_ticker, s_interval, df_stock, polynomial): plt.axvspan( df_stock.index[-1], df_pred.index[-1], facecolor="tab:orange", alpha=0.2 ) - xmin, xmax, ymin, ymax = plt.axis() + _, _, ymin, ymax = plt.axis() plt.vlines( df_stock.index[-1], ymin, ymax, linewidth=1, linestyle="--", color="k" ) @@ -138,6 +141,6 @@ def regression(l_args, s_ticker, s_interval, df_stock, polynomial): print(df_pred.to_string()) print("") - except: + except Exception as e: + print(e) print("") - diff --git a/gamestonk_terminal/prediction_techniques/sma.py b/gamestonk_terminal/prediction_techniques/sma.py index 2358db42b17..834c61ce7cb 100644 --- a/gamestonk_terminal/prediction_techniques/sma.py +++ b/gamestonk_terminal/prediction_techniques/sma.py @@ -1,23 +1,27 @@ import argparse import numpy as np -from gamestonk_terminal.helper_funcs import * -import pandas as pd import matplotlib.pyplot as plt +import pandas as pd from pandas.plotting import register_matplotlib_converters +from gamestonk_terminal.helper_funcs import check_positive, get_next_stock_market_days + register_matplotlib_converters() # ----------------------------------------------------- SMA ----------------------------------------------------- +# pylint: disable=unused-argument def simple_moving_average(l_args, s_ticker, s_interval, df_stock): parser = argparse.ArgumentParser( prog="sma", - description=""" Moving Averages are used to smooth the data in an array to - help eliminate noise and identify trends. The Simple Moving Average is literally - the simplest form of a moving average. Each output value is the average of the - previous n values. In a Simple Moving Average, each value in the time period carries - equal weight, and values outside of the time period are not included in the average. - This makes it less responsive to recent changes in the data, which can be useful for - filtering out those changes. """, + description=""" + Moving Averages are used to smooth the data in an array to + help eliminate noise and identify trends. The Simple Moving Average is literally + the simplest form of a moving average. Each output value is the average of the + previous n values. In a Simple Moving Average, each value in the time period carries + equal weight, and values outside of the time period are not included in the average. + This makes it less responsive to recent changes in the data, which can be useful for + filtering out those changes. + """, ) parser.add_argument( @@ -89,7 +93,7 @@ def simple_moving_average(l_args, s_ticker, s_interval, df_stock): plt.axvspan( df_stock.index[-1], df_pred.index[-1], facecolor="tab:orange", alpha=0.2 ) - xmin, xmax, ymin, ymax = plt.axis() + _, _, ymin, ymax = plt.axis() plt.vlines( df_stock.index[-1], ymin, ymax, linewidth=1, linestyle="--", color="k" ) @@ -101,6 +105,6 @@ def simple_moving_average(l_args, s_ticker, s_interval, df_stock): print(df_pred.to_string()) print("") - except: + except Exception as e: + print(e) print("") -