Skip to content

Commit

Permalink
from_pydict -> from_pylist.
Browse files Browse the repository at this point in the history
  • Loading branch information
tompollard committed Jan 8, 2024
1 parent 920e8ee commit 016e2f9
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,40 @@ def test_patient_schema():
"""
Test that mock patient data follows the patient_schema schema.
"""
patient_data = {
"patient_id": [123],
"events": [[{ # Nested list for events
"time": datetime.datetime(2020, 1, 1, 12, 0, 0),
"measurements": [{ # Nested list for measurements
"code": "some_code",
"text_value": "Example",
"numeric_value": 10.0,
"datetime_value": datetime.datetime(2020, 1, 1, 12, 0, 0),
"metadata": None
# Each element in the list is a row in the table
patient_data = [
{
"patient_id": 123,
"events": [{ # Nested list for events
"time": datetime.datetime(2020, 1, 1, 12, 0, 0),
"measurements": [{ # Nested list for measurements
"code": "some_code",
"text_value": "Example",
"numeric_value": 10.0,
"datetime_value": datetime.datetime(2020, 1, 1, 12, 0, 0),
"metadata": None
}]
}]
}]]
}
}
]

patient_table = pa.Table.from_pydict(patient_data, schema=patient_schema())
patient_table = pa.Table.from_pylist(patient_data, schema=patient_schema())
assert patient_table.schema.equals(patient_schema()), "Patient schema does not match"

def test_label_schema():
"""
Test that mock label data follows the label schema.
"""
label_data = {
"patient_id": [123],
"prediction_time": [datetime.datetime(2020, 1, 1, 12, 0, 0)],
"boolean_value": [True]
}
# Each element in the list is a row in the table
label_data = [
{
"patient_id": 123,
"prediction_time": datetime.datetime(2020, 1, 1, 12, 0, 0),
"boolean_value": True
}
]

label_table = pa.Table.from_pydict(label_data, schema=label)
label_table = pa.Table.from_pylist(label_data, schema=label)
assert label_table.schema.equals(label), "Label schema does not match"

def test_dataset_metadata_schema():
Expand Down

0 comments on commit 016e2f9

Please sign in to comment.