unionai-oss / pandera

A light-weight, flexible, and expressive statistical data testing library
https://www.union.ai/pandera
MIT License
3.27k stars 305 forks source link

Unsatisfiable when field is nullable and size 0. #634

Closed MikiGrit closed 2 years ago

MikiGrit commented 2 years ago

Describe the bug As in the described in the title, the example code below will throw exception while I believe it should not.

Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandera as pa
import pandera.typing as pt

class MySchema(pa.SchemaModel):
    myval: pt.Series[int] = pa.Field(nullable=True)

    class Config:
        strict = True
        coerce = True

MySchema.example(size=1)  # this passes
MySchema.example(size=0)  # this will throw Unsatisfiable

Desktop (please complete the following information):

cosmicBboy commented 2 years ago

thanks for filing this bug @MikiGrit! looking into this

cosmicBboy commented 2 years ago

638 should address this issue

MikiGrit commented 2 years ago

Thanks, for solving it promptly. Great work! :)