Ejemplo n.º 1
0
def test_add_fields_fixed_size_setter():
    ds = FieldDataset("node", fixed_size=False)
    ds.set_value("air_temperature", [0, 0, 0])
    ds.set_value("air_temperature", [1, 1, 1, 1])
    ds.fixed_size = True
    with pytest.raises(ValueError):
        ds.set_value("air_temperature", [1, 1, 1])
    assert ds.size == 4
    ds.fixed_size = False
    ds.set_value("air_temperature", [1, 1, 1])
    assert ds.size == 3
Ejemplo n.º 2
0
def test_size_setter():
    ds = FieldDataset("node", fixed_size=True)
    assert ds.size is None

    ds.size = 3
    assert ds.size == 3
    with pytest.raises(ValueError):
        ds.size = 4
    ds.size = 3

    ds.fixed_size = False
    ds.size = 4
    assert ds.size == 4

    with pytest.raises(ValueError):
        ds.size = 1.1
    with pytest.raises(ValueError):
        ds.size = -1