@@ -87,7 +87,8 @@ def test_pydantic_from_pandas(sample_data):
8787
8888 # Now test that the document model actually works
8989 # Should permit dict-like key access
90- rows = [row .to_dict () for _ , row in sample_data .iterrows ()]
90+ sanitized = sample_data .replace ({np .nan : None })
91+ rows = [row .to_dict () for _ , row in sanitized .iterrows ()]
9192 docs = [
9293 base_model (
9394 ** {camel_col : row_dict [old_col ] for old_col , camel_col in col_map .items ()}
@@ -101,10 +102,10 @@ def test_pydantic_from_pandas(sample_data):
101102 for old_col , camel_col in col_map .items ():
102103 if camel_col in (expected_col_types ):
103104 assert [doc [camel_col ] for doc in docs ] == pytest .approx (
104- sample_data [old_col ].tolist ()
105+ sanitized [old_col ].tolist ()
105106 )
106107 else :
107- assert [doc [camel_col ] for doc in docs ] == sample_data [old_col ].tolist ()
108+ assert [doc [camel_col ] for doc in docs ] == sanitized [old_col ].tolist ()
108109
109110
110111def test_contrib_submission_from_pandas (sample_data ):
@@ -141,6 +142,7 @@ def test_contrib_submission_from_pandas(sample_data):
141142 contrib ["data" ][k ] == sample_data [new_to_old_col [k ]][idx ]
142143 for idx , contrib in enumerate (contributions )
143144 for k in ("IsStable" , "Interpretation" )
145+ if not pd .isna (sample_data [new_to_old_col [k ]][idx ])
144146 )
145147
146148 # Test that these are JSONable
0 commit comments