From 4fa9d65cdf513d5e11d5fdda20e78f45f7f45243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Mon, 16 Aug 2021 15:01:37 -0300 Subject: [PATCH] Refactoring: Type Hints --- pyFTS/data/Bitcoin.py | 5 +++-- pyFTS/data/DowJones.py | 4 ++-- pyFTS/data/EURGBP.py | 4 ++-- pyFTS/data/EURUSD.py | 4 ++-- pyFTS/data/Enrollments.py | 4 ++-- pyFTS/data/Ethereum.py | 4 ++-- pyFTS/data/GBPUSD.py | 4 ++-- pyFTS/data/INMET.py | 2 +- pyFTS/data/Malaysia.py | 4 ++-- pyFTS/data/NASDAQ.py | 4 ++-- pyFTS/data/SONDA.py | 4 ++-- pyFTS/data/SP500.py | 4 ++-- pyFTS/data/TAIEX.py | 4 ++-- pyFTS/data/artificial.py | 2 +- pyFTS/data/henon.py | 4 ++-- pyFTS/data/logistic_map.py | 2 +- pyFTS/data/lorentz.py | 8 ++++---- pyFTS/data/mackey_glass.py | 2 +- pyFTS/data/rossler.py | 8 ++++---- pyFTS/data/sunspots.py | 4 ++-- 20 files changed, 41 insertions(+), 40 deletions(-) diff --git a/pyFTS/data/Bitcoin.py b/pyFTS/data/Bitcoin.py index bdd4e74..615102d 100644 --- a/pyFTS/data/Bitcoin.py +++ b/pyFTS/data/Bitcoin.py @@ -12,7 +12,7 @@ import pandas as pd import numpy as np -def get_data(field='AVG'): +def get_data(field:str='AVG') -> np.ndarray: """ Get the univariate time series data. @@ -22,7 +22,8 @@ def get_data(field='AVG'): dat = get_dataframe() return np.array(dat[field]) -def get_dataframe(): + +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/DowJones.py b/pyFTS/data/DowJones.py index 867ed90..de20c81 100644 --- a/pyFTS/data/DowJones.py +++ b/pyFTS/data/DowJones.py @@ -12,7 +12,7 @@ import pandas as pd import numpy as np -def get_data(field='AVG'): +def get_data(field:str='AVG') -> np.ndarray: """ Get the univariate time series data. @@ -23,7 +23,7 @@ def get_data(field='AVG'): return np.array(dat[field]) -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/EURGBP.py b/pyFTS/data/EURGBP.py index 1be77af..628c0cc 100644 --- a/pyFTS/data/EURGBP.py +++ b/pyFTS/data/EURGBP.py @@ -10,7 +10,7 @@ import pandas as pd import numpy as np -def get_data(field='avg'): +def get_data(field:str='avg') -> np.ndarray: """ Get the univariate time series data. @@ -21,7 +21,7 @@ def get_data(field='avg'): return np.array(dat[field]) -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/EURUSD.py b/pyFTS/data/EURUSD.py index a0fe18d..1d4df30 100644 --- a/pyFTS/data/EURUSD.py +++ b/pyFTS/data/EURUSD.py @@ -10,7 +10,7 @@ import pandas as pd import numpy as np -def get_data(field='avg'): +def get_data(field: str='avg') -> np.ndarray: """ Get the univariate time series data. @@ -21,7 +21,7 @@ def get_data(field='avg'): return np.array(dat[field]) -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/Enrollments.py b/pyFTS/data/Enrollments.py index 5ab942a..ab7faf7 100644 --- a/pyFTS/data/Enrollments.py +++ b/pyFTS/data/Enrollments.py @@ -7,7 +7,7 @@ import pandas as pd import numpy as np -def get_data(): +def get_data() -> np.ndarray: """ Get a simple univariate time series data. @@ -18,7 +18,7 @@ def get_data(): return dat -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: dat = common.get_dataframe('Enrollments.csv', 'https://github.com/petroniocandido/pyFTS/raw/8f20f3634aa6a8f58083bdcd1bbf93795e6ed767/pyFTS/data/Enrollments.csv', sep=";") diff --git a/pyFTS/data/Ethereum.py b/pyFTS/data/Ethereum.py index 97dd4c7..eaad661 100644 --- a/pyFTS/data/Ethereum.py +++ b/pyFTS/data/Ethereum.py @@ -12,7 +12,7 @@ import pandas as pd import numpy as np -def get_data(field='AVG'): +def get_data(field: str='AVG') -> np.ndarray: """ Get the univariate time series data. @@ -23,7 +23,7 @@ def get_data(field='AVG'): return np.array(dat[field]) -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/GBPUSD.py b/pyFTS/data/GBPUSD.py index d8f4e39..20cbb42 100644 --- a/pyFTS/data/GBPUSD.py +++ b/pyFTS/data/GBPUSD.py @@ -10,7 +10,7 @@ import pandas as pd import numpy as np -def get_data(field='avg'): +def get_data(field: str='avg') -> np.ndarray: """ Get the univariate time series data. @@ -21,7 +21,7 @@ def get_data(field='avg'): return np.array(dat[field]) -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/INMET.py b/pyFTS/data/INMET.py index a3e5ccc..93e46e2 100644 --- a/pyFTS/data/INMET.py +++ b/pyFTS/data/INMET.py @@ -10,7 +10,7 @@ from pyFTS.data import common import pandas as pd -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/Malaysia.py b/pyFTS/data/Malaysia.py index 0d794b1..0ed8183 100644 --- a/pyFTS/data/Malaysia.py +++ b/pyFTS/data/Malaysia.py @@ -8,7 +8,7 @@ import pandas as pd import numpy as np -def get_data(field='load'): +def get_data(field: str='load') -> np.ndarray: """ Get the univariate time series data. @@ -19,7 +19,7 @@ def get_data(field='load'): return np.array(dat[field]) -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/NASDAQ.py b/pyFTS/data/NASDAQ.py index c5519db..b1a69d0 100644 --- a/pyFTS/data/NASDAQ.py +++ b/pyFTS/data/NASDAQ.py @@ -11,7 +11,7 @@ import pandas as pd import numpy as np -def get_data(field="avg"): +def get_data(field: str="avg") -> np.ndarray: """ Get a simple univariate time series data. @@ -23,7 +23,7 @@ def get_data(field="avg"): return dat -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/SONDA.py b/pyFTS/data/SONDA.py index 4f4887f..948963d 100644 --- a/pyFTS/data/SONDA.py +++ b/pyFTS/data/SONDA.py @@ -11,7 +11,7 @@ import pandas as pd import numpy as np -def get_data(field): +def get_data(field:str) -> np.ndarray: """ Get a simple univariate time series data. @@ -23,7 +23,7 @@ def get_data(field): return dat -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/SP500.py b/pyFTS/data/SP500.py index 9eb907a..758fa7d 100644 --- a/pyFTS/data/SP500.py +++ b/pyFTS/data/SP500.py @@ -11,7 +11,7 @@ import pandas as pd import numpy as np -def get_data(): +def get_data() -> np.ndarray: """ Get the univariate time series data. @@ -21,7 +21,7 @@ def get_data(): return np.array(dat["Avg"]) -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/TAIEX.py b/pyFTS/data/TAIEX.py index 396c0a6..bfc3b34 100644 --- a/pyFTS/data/TAIEX.py +++ b/pyFTS/data/TAIEX.py @@ -10,7 +10,7 @@ import pandas as pd import numpy as np -def get_data(): +def get_data() -> np.ndarray: """ Get the univariate time series data. @@ -21,7 +21,7 @@ def get_data(): return dat -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data. diff --git a/pyFTS/data/artificial.py b/pyFTS/data/artificial.py index 3878c0c..38f3618 100644 --- a/pyFTS/data/artificial.py +++ b/pyFTS/data/artificial.py @@ -54,7 +54,7 @@ class SignalEmulator(object): 'parameters': parameters, 'args': kwargs}) return self - def periodic_gaussian(self, type, period, mu_min, sigma_min, mu_max, sigma_max, **kwargs): + def periodic_gaussian(self, type:str, period:int, mu_min:float, sigma_min:float, mu_max:float, sigma_max:float, **kwargs): """ Creates an additive periodic gaussian interference on a previous signal diff --git a/pyFTS/data/henon.py b/pyFTS/data/henon.py index c8c22fb..ced3fb6 100644 --- a/pyFTS/data/henon.py +++ b/pyFTS/data/henon.py @@ -9,7 +9,7 @@ import numpy as np import pandas as pd -def get_data(var, a=1.4, b=0.3, initial_values = [1, 1], iterations=1000): +def get_data(var: str, a:float=1.4, b:float=0.3, initial_values: list[float] = [1, 1], iterations:int=1000) -> pd.DataFrame: """ Get a simple univariate time series data. @@ -19,7 +19,7 @@ def get_data(var, a=1.4, b=0.3, initial_values = [1, 1], iterations=1000): return get_dataframe(a,b, initial_values, iterations)[var].values -def get_dataframe(a=1.4, b=0.3, initial_values = [1, 1], iterations=1000): +def get_dataframe(a:float=1.4, b:float=0.3, initial_values: list[float] = [1, 1], iterations:int=1000) -> pd.DataFrame: ''' Return a dataframe with the bivariate Henon Map time series (x, y). diff --git a/pyFTS/data/logistic_map.py b/pyFTS/data/logistic_map.py index 8f65a31..b2de82c 100644 --- a/pyFTS/data/logistic_map.py +++ b/pyFTS/data/logistic_map.py @@ -8,7 +8,7 @@ x(t) = r * x(t-1) * (1 - x(t -1) ) import numpy as np -def get_data(r = 4, initial_value = 0.3, iterations=100): +def get_data(r: float = 4, initial_value: float = 0.3, iterations: int=100) -> list: ''' Return a list with the logistic map chaotic time series. diff --git a/pyFTS/data/lorentz.py b/pyFTS/data/lorentz.py index 956f4e6..b589907 100644 --- a/pyFTS/data/lorentz.py +++ b/pyFTS/data/lorentz.py @@ -11,8 +11,8 @@ import numpy as np import pandas as pd -def get_data(var, a = 10.0, b = 28.0, c = 8.0 / 3.0, dt = 0.01, - initial_values = [0.1, 0, 0], iterations=1000): +def get_data(var: str, a: float = 10.0, b: float = 28.0, c: float = 8.0 / 3.0, dt: float = 0.01, + initial_values: list[float] = [0.1, 0, 0], iterations: int=1000) -> pd.DataFrame: """ Get a simple univariate time series data. @@ -22,8 +22,8 @@ def get_data(var, a = 10.0, b = 28.0, c = 8.0 / 3.0, dt = 0.01, return get_dataframe(a, b, c, dt, initial_values, iterations)[var].values -def get_dataframe(a = 10.0, b = 28.0, c = 8.0 / 3.0, dt = 0.01, - initial_values = [0.1, 0, 0], iterations=1000): +def get_dataframe(a: float = 10.0, b: float = 28.0, c: float = 8.0 / 3.0, dt: float = 0.01, + initial_values: list[float] = [0.1, 0, 0], iterations: int=1000)-> pd.DataFrame: ''' Return a dataframe with the multivariate Lorenz Map time series (x, y, z). diff --git a/pyFTS/data/mackey_glass.py b/pyFTS/data/mackey_glass.py index 86e515e..762cad1 100644 --- a/pyFTS/data/mackey_glass.py +++ b/pyFTS/data/mackey_glass.py @@ -8,7 +8,7 @@ dy/dt = -by(t)+ cy(t - tau) / 1+y(t-tau)^10 import numpy as np -def get_data(b=0.1, c=0.2, tau=17, initial_values = np.linspace(0.5,1.5, 18), iterations=1000): +def get_data(b: float=0.1, c: float=0.2, tau: float =17, initial_values: np.ndarray = np.linspace(0.5,1.5, 18), iterations: int=1000) -> list: ''' Return a list with the Mackey-Glass chaotic time series. diff --git a/pyFTS/data/rossler.py b/pyFTS/data/rossler.py index cfc9e21..370cd21 100644 --- a/pyFTS/data/rossler.py +++ b/pyFTS/data/rossler.py @@ -11,8 +11,8 @@ import numpy as np import pandas as pd -def get_data(var, a = 0.2, b = 0.2, c = 5.7, dt = 0.01, - initial_values = [0.001, 0.001, 0.001], iterations=5000): +def get_data(var: str, a: float = 0.2, b: float = 0.2, c: float = 5.7, dt: float = 0.01, + initial_values: np.ndarray = [0.001, 0.001, 0.001], iterations: int=5000) -> np.ndarray: """ Get a simple univariate time series data. @@ -22,8 +22,8 @@ def get_data(var, a = 0.2, b = 0.2, c = 5.7, dt = 0.01, return get_dataframe(a, b, c, dt, initial_values, iterations)[var].values -def get_dataframe(a = 0.2, b = 0.2, c = 5.7, dt = 0.01, - initial_values = [0.001, 0.001, 0.001], iterations=5000): +def get_dataframe(a: float = 0.2, b: float = 0.2, c: float = 5.7, dt: float = 0.01, + initial_values: np.ndarray = [0.001, 0.001, 0.001], iterations: int=5000) -> pd.DataFrame: ''' Return a dataframe with the multivariate Rössler Map time series (x, y, z). diff --git a/pyFTS/data/sunspots.py b/pyFTS/data/sunspots.py index 9d59f1d..f8d37be 100644 --- a/pyFTS/data/sunspots.py +++ b/pyFTS/data/sunspots.py @@ -8,7 +8,7 @@ from pyFTS.data import common import pandas as pd import numpy as np -def get_data(): +def get_data() -> np.ndarray: """ Get a simple univariate time series data. @@ -18,7 +18,7 @@ def get_data(): dat = np.array(dat["SUNACTIVITY"]) return dat -def get_dataframe(): +def get_dataframe() -> pd.DataFrame: """ Get the complete multivariate time series data.