Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/core/test_curator_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,39 @@ def test_nullable():
disease.delete(permanent=True)


def test_curator_partial_null_bool_int():
flag = ln.Feature(name="cur-flag", dtype=bool, nullable=True).save()
count = ln.Feature(name="cur-count", dtype=int, nullable=True).save()
schema = ln.Schema(features=[flag, count]).save()

# Case 1: properly-typed nullable columns -> should PASS
# This is what a well-behaved user supplies, and what our _feature_manager fix
# produces after the cast. We are asserting the curator accepts these dtypes.
df_good = pd.DataFrame(
{
"cur-flag": pd.array([True, None, False], dtype="boolean"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

"cur-count": pd.array([1, None, 3], dtype="Int64"),
}
)
assert ln.curators.DataFrameCurator(df_good, schema).validate() is None

# Case 2: degraded dtypes (what pd.DataFrame(prepared_rows) produces internally)
# bool + null -> object, int + null -> float64.
# Should FAIL — this is correct curator behaviour, not a bug.
df_degraded = pd.DataFrame(
{
"cur-flag": [True, None, False], # object
"cur-count": [1, None, 3], # float64
}
)
with pytest.raises(ln.errors.ValidationError):
ln.curators.DataFrameCurator(df_degraded, schema).validate()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a test that makes evident which error message is raised here?


schema.delete(permanent=True)
flag.delete(permanent=True)
count.delete(permanent=True)


def test_pandera_dataframe_schema(
df,
df_missing_sample_type_column,
Expand Down
Loading