Esempio n. 1
0
def test_not_a_grid(roff_grid):
    buff = io.BytesIO()
    roff_grid.to_file(buff)
    buff.seek(0)
    values = roffio.read(buff)
    values["filedata"]["filetype"] = "notgrid"
    buff.seek(0)
    roffio.write(buff, values)
    buff.seek(0)
    with pytest.raises(ValueError, match="did not have filetype set to grid"):
        RoffGrid.from_file(buff)
Esempio n. 2
0
def test_default_values(roff_grid):
    buff = io.BytesIO()
    roff_grid.to_file(buff)
    buff.seek(0)
    values = roffio.read(buff)

    del values["translate"]
    del values["scale"]
    if "subgrids" in values:
        del values["subgrids"]
    del values["active"]

    buff2 = io.BytesIO()
    roffio.write(buff2, values)
    buff2.seek(0)
    roff_grid2 = RoffGrid.from_file(buff2)

    assert roff_grid2.xoffset == 0.0
    assert roff_grid2.yoffset == 0.0
    assert roff_grid2.zoffset == 0.0

    assert roff_grid2.xscale == 1.0
    assert roff_grid2.yscale == 1.0
    assert roff_grid2.zscale == -1.0

    assert roff_grid2.subgrids is None

    assert np.array_equal(
        roff_grid2.active,
        np.ones(roff_grid.nx * roff_grid.ny * roff_grid.nz, dtype=np.bool_),
    )
Esempio n. 3
0
def test_missing_non_optionals():
    buff = io.BytesIO()
    roffio.write(buff, {"filedata": {"filetype": "grid"}})
    buff.seek(0)
    with pytest.raises(ValueError, match="Missing non-optional"):
        RoffGrid.from_file(buff)
Esempio n. 4
0
def test_roff_grid_read_write(rgrid):
    buff = io.BytesIO()
    rgrid.to_file(buff)

    buff.seek(0)
    assert RoffGrid.from_file(buff) == rgrid