Skip to content

Commit

Permalink
Fixed AttributeError in cont/cat variable type feature
Browse files Browse the repository at this point in the history
  • Loading branch information
CMobley7 committed Aug 2, 2023
1 parent f7af740 commit b07fe5b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pandas_ta/overlap/mama.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ def mama(

# Name and Category
_props = f"_{fastlimit}_{slowlimit}"
mama.category = fama.category = "overlap"
mama.variable_type = fama.variable_type = "continuous"

df = DataFrame({
f"MAMA{_props}": mama,
f"FAMA{_props}": fama,
}, index=close.index)
df[f"MAMA{_props}"].category = df[f"FAMA{_props}"].category = "overlap"
df[f"MAMA{_props}"].variable_type = df[f"FAMA{_props}"].variable_type = "continuous"

df.name = f"MAMA{_props}"
df.category = "overlap"
Expand Down
7 changes: 4 additions & 3 deletions pandas_ta/overlap/pivots.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,15 @@ def pivots(

# Name and Category
_props = f"PIVOTS_{method[:4].upper()}_{anchor}"
tp.category = s1.category = s2.category = s3.category = s4.category = r1.category = r2.category = r3.category = r4.category = "overlap"
tp.variable_type = s1.variable_type = s2.variable_type = s3.variable_type = s4.variable_type = r1.variable_type = r2.variable_type = r3.variable_type = r4.variable_type = "continuous"

df[f"{_props}_P"] = tp
df[f"{_props}_S1"], df[f"{_props}_S2"] = s1, s2
df[f"{_props}_S3"], df[f"{_props}_S4"] = s3, s4
df[f"{_props}_R1"], df[f"{_props}_R2"] = r1, r2
df[f"{_props}_R3"], df[f"{_props}_R4"] = r3, r4

df[f"{_props}_P"].category = df[f"{_props}_S1"].category = df[f"{_props}_S2"].category = df[f"{_props}_S3"].category = df[f"{_props}_S4"].category = df[f"{_props}_R1"].category = df[f"{_props}_R2"].category = df[f"{_props}_R3"].category = df[f"{_props}_R4"].category = "overlap"
df[f"{_props}_P"].variable_type = df[f"{_props}_S1"].variable_type = df[f"{_props}_S2"].variable_type = df[f"{_props}_S3"].variable_type = df[f"{_props}_S4"].variable_type = df[f"{_props}_R1"].variable_type = df[f"{_props}_R2"].variable_type = df[f"{_props}_R3"].variable_type = df[f"{_props}_R4"].variable_type = "continuous"

df.index = df.index + Timedelta(1, anchor.lower())
if freq is not anchor:
Expand All @@ -253,6 +254,6 @@ def pivots(
df.drop(columns=[x for x in df.columns if all(df[x].isna())], inplace=True)

df.name = _props
df.category = tp.category
df.category = "overlap"

return df
7 changes: 4 additions & 3 deletions pandas_ta/overlap/supertrend.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,17 @@ def supertrend(
dir_[:length] = [nan] * length

_props = f"_{length}_{multiplier}"
trend.category = dir_.category = long.category = short.category = "overlap"
trend.variable_type = long.variable_type = short.variable_type = "continuous"
dir_.variable_type = "categorical"

df = DataFrame({
f"SUPERT{_props}": trend,
f"SUPERTd{_props}": dir_,
f"SUPERTl{_props}": long,
f"SUPERTs{_props}": short,
}, index=close.index)

df[f"SUPERT{_props}"].category = df[f"SUPERTd{_props}"].category = df[f"SUPERTl{_props}"].category = df[f"SUPERTs{_props}"].category = "overlap"
df[f"SUPERT{_props}"].variable_type = df[f"SUPERTl{_props}"].variable_type = df[f"SUPERTs{_props}"].variable_type = "continuous"
df[f"SUPERTd{_props}"].variable_type = "categorical"

df.name = f"SUPERT{_props}"
df.category = "overlap"
Expand Down

0 comments on commit b07fe5b

Please sign in to comment.