| 230 | |
| 231 | |
| 232 | def test_schema(): |
| 233 | fields = [ |
| 234 | pa.field('foo', pa.int32()), |
| 235 | pa.field('bar', pa.string()), |
| 236 | pa.field('baz', pa.list_(pa.int8())) |
| 237 | ] |
| 238 | sch = pa.schema(fields) |
| 239 | |
| 240 | assert sch.names == ['foo', 'bar', 'baz'] |
| 241 | assert sch.types == [pa.int32(), pa.string(), pa.list_(pa.int8())] |
| 242 | |
| 243 | assert len(sch) == 3 |
| 244 | assert sch[0].name == 'foo' |
| 245 | assert sch[0].type == fields[0].type |
| 246 | assert sch.field('foo').name == 'foo' |
| 247 | assert sch.field('foo').type == fields[0].type |
| 248 | |
| 249 | assert repr(sch) == """\ |
| 250 | foo: int32 |
| 251 | bar: string |
| 252 | baz: list<item: int8> |
| 253 | child 0, item: int8""" |
| 254 | |
| 255 | with pytest.raises(TypeError): |
| 256 | pa.schema([None]) |
| 257 | |
| 258 | |
| 259 | def test_schema_weakref(): |