| 573 | |
| 574 | |
| 575 | def test_schema_get_fields(): |
| 576 | fields = [ |
| 577 | pa.field('foo', pa.int32()), |
| 578 | pa.field('bar', pa.string()), |
| 579 | pa.field('baz', pa.list_(pa.int8())) |
| 580 | ] |
| 581 | |
| 582 | schema = pa.schema(fields) |
| 583 | |
| 584 | assert schema.field('foo').name == 'foo' |
| 585 | assert schema.field(0).name == 'foo' |
| 586 | assert schema.field(-1).name == 'baz' |
| 587 | |
| 588 | with pytest.raises(KeyError): |
| 589 | schema.field('other') |
| 590 | with pytest.raises(TypeError): |
| 591 | schema.field(0.0) |
| 592 | with pytest.raises(IndexError): |
| 593 | schema.field(4) |
| 594 | |
| 595 | |
| 596 | def test_schema_negative_indexing(): |