diff --git a/src/xtgeo/surface/regular_surface.py b/src/xtgeo/surface/regular_surface.py index 2b7ebe223..1778bfce2 100644 --- a/src/xtgeo/surface/regular_surface.py +++ b/src/xtgeo/surface/regular_surface.py @@ -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() diff --git a/tests/test_surface/test_regular_surface.py b/tests/test_surface/test_regular_surface.py index e35872797..c989d9ec8 100644 --- a/tests/test_surface/test_regular_surface.py +++ b/tests/test_surface/test_regular_surface.py @@ -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."""