Closed seb84924 closed 3 years ago
Describe the bug pa.SchemaModel is not able to use custom checks.
pa.SchemaModel
import pandas as pd import pandera as pa from pandera import Field import pandera.extensions as extensions from pandera.typing import Series @extensions.register_check_method(statistics=["min_value", "max_value"]) def is_between(pandas_obj, *, min_value, max_value): return (min_value <= pandas_obj) & (pandas_obj <= max_value) df = pd.DataFrame([10], columns=["col"]) schema = pa.DataFrameSchema( {"col": pa.Column(int, pa.Check.is_between(min_value=1, max_value=9))} ) try: schema.validate(df) except pa.errors.SchemaError: print("fails as expected") class Schema(pa.SchemaModel): col: Series[int] = Field(is_between={"min_value": 1, "max_value": 9}) Schema.validate(df) print("does not fail as expected")
I would expect Schema.validate(df) to cause an error.
Thanks for finding this issue @seb84924! this bug is kind of embarrassing đŸ˜…. #373 should address it. Will release this fix as part of 0.6.1.
0.6.1
Describe the bug
pa.SchemaModel
is not able to use custom checks.Expected behavior
I would expect Schema.validate(df) to cause an error.
Desktop (please complete the following information):