Skip to content

Commit

Permalink
Issue #1062: changed return types in docstrings to reflect typing mod…
Browse files Browse the repository at this point in the history
…ule notation.
  • Loading branch information
dilwong committed Apr 22, 2024
1 parent c2c8c91 commit aab8722
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions tsfresh/feature_extraction/feature_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def symmetry_looking(x, param):
:param param: contains dictionaries {"r": x} with x (float) is the percentage of the range to compare with
:type param: list
:return: the value of this feature
:return type: list of tuples of type (str, bool)
:return type: List[Tuple[str, bool]]
"""
if not isinstance(x, (np.ndarray, pd.Series)):
x = np.asarray(x)
Expand Down Expand Up @@ -413,7 +413,7 @@ def agg_autocorrelation(x, param):
autocorrelations. Further, n is an int and the maximal number of lags to consider.
:type param: list
:return: the value of this feature
:return type: list of tuples of type (str, float)
:return type: List[Tuple[str, float]]
"""
# if the time series is longer than the following threshold, we use fft to calculate the acf
THRESHOLD_TO_USE_FFT = 1250
Expand Down Expand Up @@ -468,7 +468,7 @@ def partial_autocorrelation(x, param):
:param param: contains dictionaries {"lag": val} with int val indicating the lag to be returned
:type param: list
:return: the value of this feature
:return type: list of tuples of type (str, float)
:return type: List[Tuple[str, float]]
"""
# Check the difference between demanded lags by param and possible lags to calculate (depends on len(x))
max_demanded_lag = max([lag["lag"] for lag in param])
Expand Down Expand Up @@ -510,7 +510,7 @@ def augmented_dickey_fuller(x, param):
statsmodels).
:type param: list
:return: the value of this feature
:return type: list of tuples of type (str, float)
:return type: List[Tuple[str, float]]
"""

@functools.lru_cache()
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def fft_coefficient(x, param):
"abs", "angle"]
:type param: list
:return: the different feature values
:return type: zip iterable yielding tuples of type (str, float)
:return type: Iterator[Tuple[str, float]]
"""

assert (
Expand Down Expand Up @@ -1130,7 +1130,7 @@ def fft_aggregated(x, param):
"skew", "kurtosis"]
:type param: list
:return: the different feature values
:return type: zip iterable yielding tuples of type (str, float)
:return type: Iterator[Tuple[str, float]]
"""

assert {config["aggtype"] for config in param} <= {
Expand Down Expand Up @@ -1282,7 +1282,7 @@ def index_mass_quantile(x, param):
:param param: contains dictionaries {"q": x} with x float
:type param: list
:return: the different feature values
:return type: list of tuples of type (str, float)
:return type: List[Tuple[str, float]]
"""

x = np.asarray(x)
Expand Down Expand Up @@ -1341,7 +1341,7 @@ def linear_trend(x, param):
:param param: contains dictionaries {"attr": x} with x an string, the attribute name of the regression model
:type param: list
:return: the different feature values
:return type: list of tuples of type (str, float)
:return type: List[Tuple[str, float]]
"""
# todo: we could use the index of the DataFrame here
linReg = linregress(range(len(x)), x)
Expand Down Expand Up @@ -1372,7 +1372,7 @@ def cwt_coefficients(x, param):
:param param: contains dictionaries {"widths":x, "coeff": y, "w": z} with x array of int and y,z int
:type param: list
:return: the different feature values
:return type: zip iterable yielding tuples of type (str, float)
:return type: Iterator[Tuple[str, float]]
"""

calculated_cwt = {}
Expand Down Expand Up @@ -1413,7 +1413,7 @@ def spkt_welch_density(x, param):
:param param: contains dictionaries {"coeff": x} with x int
:type param: list
:return: the different feature values
:return type: zip iterable yielding tuples of type (str, float)
:return type: Iterator[Tuple[str, float]]
"""

freq, pxx = welch(x, nperseg=min(len(x), 256))
Expand Down Expand Up @@ -1458,7 +1458,7 @@ def ar_coefficient(x, param):
:param param: contains dictionaries {"coeff": x, "k": y} with x,y int
:type param: list
:return x: the different feature values
:return type: list of tuples of type (str, float)
:return type: List[Tuple[str, float]]
"""
calculated_ar_params = {}

Expand Down Expand Up @@ -2087,7 +2087,7 @@ def friedrich_coefficients(x, param):
a positive integer corresponding to the returned coefficient
:type param: list
:return: the different feature values
:return type: list of tuples of type (str, float)
:return type: List[Tuple[str, float]]
"""
# calculated is dictionary storing the calculated coefficients {m: {r: friedrich_coefficients}}
calculated = defaultdict(dict)
Expand Down Expand Up @@ -2171,7 +2171,7 @@ def agg_linear_trend(x, param):
:param param: contains dictionaries {"attr": x, "chunk_len": l, "f_agg": f} with x, f an string and l an int
:type param: list
:return: the different feature values
:return type: zip iterable yielding tuples of type (str, float)
:return type: Iterator[Tuple[str, float]]
"""
# todo: we could use the index of the DataFrame here

Expand Down Expand Up @@ -2228,7 +2228,7 @@ def energy_ratio_by_chunks(x, param):
:type x: numpy.ndarray
:param param: contains dictionaries {"num_segments": N, "segment_focus": i} with N, i both ints
:return: the feature values
:return type: list of tuples (index, data)
:return type: List[Tuple[str, float]]
"""
res_data = []
res_index = []
Expand Down Expand Up @@ -2275,7 +2275,7 @@ def linear_trend_timewise(x, param):
:param param: contains dictionaries {"attr": x} with x an string, the attribute name of the regression model
:type param: list
:return: the different feature values
:return type: list
:return type: List[Tuple[str, float]]
"""
ix = x.index

Expand Down Expand Up @@ -2390,7 +2390,7 @@ def matrix_profile(x, param):
and decides which feature of the matrix profile to extract
:type param: list
:return: the different feature values
:return type: list of tuples of type (str, float)
:return type: List[Tuple[str, float]]
"""
if mp is None:
raise ImportError(
Expand Down Expand Up @@ -2485,7 +2485,7 @@ def query_similarity_count(x, param):
`norm` (bool) to `False.
:type param: list
:return x: the different feature values
:return type: list of tuples of type (str, int or np.nan)
:return type: List[Tuple[str, int | np.nan]]
"""
res = {}
T = np.asarray(x).astype(float)
Expand Down

0 comments on commit aab8722

Please sign in to comment.