Refactoring: Type Hints

This commit is contained in:
Petrônio Cândido 2021-08-16 15:01:37 -03:00
parent cee6474034
commit 4fa9d65cdf
20 changed files with 41 additions and 40 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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=";")

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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).

View File

@ -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.

View File

@ -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).

View File

@ -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.

View File

@ -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).

View File

@ -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.