def test_table_type_cast(): table = wandb.Table(columns=["type_col"]) table.add_data(1) wb_classes = data_types.Classes([ { "id": 1, "name": "cat" }, { "id": 2, "name": "dog" }, { "id": 3, "name": "horse" }, ]) table.cast("type_col", wb_classes.get_type()) table.add_data(2) with pytest.raises(TypeError): table.add_data(4)
def test_classes_type(): wb_classes = data_types.Classes( [ {"id": 1, "name": "cat"}, {"id": 2, "name": "dog"}, {"id": 3, "name": "horse"}, ] ) wb_class_type = data_types._ClassesIdType.from_obj(wb_classes) assert wb_class_type.assign(1) == wb_class_type assert wb_class_type.assign(0) == InvalidType()