Skip to content

Commit

Permalink
Merge pull request #47 from sdfordham/Fix-predictors_op-type
Browse files Browse the repository at this point in the history
Correct predictors operation type
  • Loading branch information
sdfordham authored Mar 29, 2024
2 parents ffc36d9 + c2e1aff commit 179306c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pysyncon/dataprep.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
from pandas._typing import Axes


PredictorsOp_t = Literal["mean", "std", "median"]
AGG_OP = ("mean", "std", "median", "sum", "count", "max", "min", "var")
PredictorsOp_t = Literal["mean", "std", "median", "sum", "count", "max", "min", "var"]
IsinArg_t = Union[Iterable, pd.Series, dict]
SpecialPredictor_t = Tuple[
Any, Union[pd.Series, pd.DataFrame, Sequence, Mapping], PredictorsOp_t
]

AGG_OP = ["mean", "std", "median", "sum", "count", "max", "min", "var"]


class Dataprep:
"""Helper class that takes in the panel data and all necessary information
Expand Down Expand Up @@ -89,7 +88,7 @@ class Dataprep:
of foo
ValueError
if one of the operators in an element of ``special_predictors`` is not
one of "mean", "std", "median"
one of "mean", "std", "median", "sum", "count", "max", "min" or "var".
"""

def __init__(
Expand Down Expand Up @@ -184,9 +183,10 @@ def __init__(
raise ValueError(
f"{predictor} in special_predictors not in foo columns."
)
if op not in ("mean", "std", "median"):
if op not in AGG_OP:
agg_op_str = ", ".join([f'"{o}"' for o in AGG_OP])
raise ValueError(
f"{op} in special_predictors must be one of mean, std, median."
f"{op} in special_predictors must be one of {agg_op_str}."
)
self.special_predictors = special_predictors

Expand Down

0 comments on commit 179306c

Please sign in to comment.