Skip to content

Commit

Permalink
BUG: fix that a surface copy retains isloaded status.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes committed Jun 10, 2024
1 parent a101de4 commit 7095d1b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/xtgeo/surface/regular_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,7 @@ def copy(self):
)

xsurf._values = self._values.copy()
xsurf._isloaded = self._isloaded

xsurf.ilines = self._ilines.copy()
xsurf.xlines = self._xlines.copy()
Expand Down
17 changes: 17 additions & 0 deletions tests/test_surface/test_regular_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ def test_values(default_surface):
srf.values = "text"


def test_regularsurface_copy():
"""Test copying a surface instance."""
values = np.random.normal(2000, 50, size=12)
srf = xtgeo.RegularSurface(ncol=3, nrow=4, xinc=20, yinc=20, values=values)
assert srf.nactive == 12
new = srf.copy()
assert srf.nactive == new.nactive

np.testing.assert_array_equal(srf.values, new.values)
assert new.xori == srf.xori
assert new.xinc == srf.xinc
assert new.yori == srf.yori
assert new.xinc == srf.xinc
assert new.rotation == srf.rotation
assert new.yflip == srf.yflip


@pytest.mark.filterwarnings("ignore:Default values*")
def test_set_values1d(default_surface):
"""Test behaviour of set_values1d method."""
Expand Down

0 comments on commit 7095d1b

Please sign in to comment.