Skip to content

find_cell fails for a lot of simple input including SPE1 grid generated from flow #1066

@eivindjahren

Description

@eivindjahren

The following fails:

from hypothesis import given
import hypothesis.strategies as st

from resdata.grid import Grid
from resdata.grid import GridGenerator

coordinates = st.integers(min_value=1, max_value=30)
increments = st.integers().filter(lambda x: x != 0)

grids = st.builds(
    GridGen.create_rectangular,
    st.tuples(*([coordinates] * 3)),
    st.tuples(*([increments] * 3)),
)

@given(grids)
def test_that_find_cell_finds_the_center_point_of_each_cell(grid):
    for cell in grid.cells():
        assert cell.valid # succeeds
        assert cell.ijk == grid.find_cell(*cell.coordinate) # fails

failing example is GridGenerator.create_rectangular((1, 1, 1), (1, 1, -1)) and test succeeds for

coordinates = st.integers(min_value=1, max_value=30)
increments = st.integers(min_value=1, max_value=10000)

so this definitely has to do with negative increments.

More worryingly, both the check for valid geometry and find_cell does not work with the SPE1 grid generated from flow:

def test_that_flow_grid_works():
    g = Grid(
        ".../ert/test-data/ert/flow_example/spe1_out/realization-0/iter-0/SPE1.EGRID"
    )
    for cell in g.cells():
        # assert cell.valid # fails
        center_point = cell.coordinate
        assert g.find_cell(*center_point) == cell.ijk  # fails

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions