Skip to content

Commit

Permalink
Correctly handling single string constraints (#670)
Browse files Browse the repository at this point in the history
* correctly handling single string contraints

* formatted changes with black

* Switch to a more systemic fix | update tests

* including null values for in_range checks

Co-authored-by: Gonzalez Avilés, Ruben <[email protected]>
  • Loading branch information
2 people authored and cosmicBboy committed Nov 11, 2021
1 parent 96415a0 commit 96d6516
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 1 addition & 3 deletions pandera/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ def _wrapper(cls, *args, **kwargs):
args_dict = {**dict(zip(arg_names, args)), **kwargs}
check = class_method(cls, *args, **kwargs)
check.statistics = {
stat: args_dict.get(stat)
for stat in statistics_args
if args_dict.get(stat) is not None
stat: args_dict.get(stat) for stat in statistics_args
}
check.statistics_args = statistics_args
return check
Expand Down
14 changes: 12 additions & 2 deletions tests/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def _create_schema(index="single"):
in_range:
min_value: 0
max_value: 10
include_min: null
include_max: null
unique: false
coerce: false
required: true
Expand All @@ -139,6 +141,8 @@ def _create_schema(index="single"):
in_range:
min_value: -10
max_value: 20
include_min: null
include_max: null
unique: false
coerce: false
required: true
Expand Down Expand Up @@ -763,6 +767,8 @@ def datetime_check(pandas_obj, *, stat):
in_range:
min_value: 10
max_value: 99
include_min: null
include_max: null
unique: true
coerce: true
required: true
Expand Down Expand Up @@ -800,7 +806,9 @@ def datetime_check(pandas_obj, *, stat):
dtype: {STR_DTYPE}
nullable: true
checks:
str_length: 3
str_length:
min_value: 3
max_value: null
unique: false
coerce: true
required: true
Expand All @@ -809,7 +817,9 @@ def datetime_check(pandas_obj, *, stat):
dtype: {STR_DTYPE}
nullable: true
checks:
str_length: 3
str_length:
min_value: null
max_value: 3
unique: false
coerce: true
required: true
Expand Down

0 comments on commit 96d6516

Please sign in to comment.