From a2df4c2363268098e472f305b2e87f35dd208463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Mon, 2 Sep 2024 22:27:33 +0200 Subject: [PATCH] Use GridGenerator in tests Resolving deprecation warning from Grid.createRectangular --- python/tests/rd_tests/test_fault_blocks.py | 22 ++++++++-------- python/tests/rd_tests/test_faults.py | 30 +++++++++++----------- python/tests/rd_tests/test_geertsma.py | 12 ++++----- python/tests/rd_tests/test_grav.py | 4 +-- python/tests/rd_tests/test_grid_equinor.py | 6 ++--- python/tests/rd_tests/test_grid_pandas.py | 10 +++++--- python/tests/rd_tests/test_kw_function.py | 4 +-- python/tests/rd_tests/test_layer.py | 16 ++++++------ python/tests/rd_tests/test_rd_3dkw.py | 20 +++++++-------- python/tests/rd_tests/test_region.py | 6 ++--- 10 files changed, 67 insertions(+), 63 deletions(-) diff --git a/python/tests/rd_tests/test_fault_blocks.py b/python/tests/rd_tests/test_fault_blocks.py index 0fc5734c9..250ea6e1a 100644 --- a/python/tests/rd_tests/test_fault_blocks.py +++ b/python/tests/rd_tests/test_fault_blocks.py @@ -4,7 +4,7 @@ from resdata import ResDataType from resdata.resfile import ResdataKW -from resdata.grid import Grid, ResdataRegion +from resdata.grid import Grid, ResdataRegion, GridGenerator from resdata.grid.faults import FaultBlock, FaultBlockLayer, FaultCollection from resdata.geometry import Polyline, CPolylineCollection from resdata.util.test import TestAreaContext @@ -13,7 +13,7 @@ class FaultBlockTest(ResdataTest): def setUp(self): - self.grid = Grid.createRectangular((10, 10, 10), (1, 1, 1)) + self.grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1)) self.kw = ResdataKW("FAULTBLK", self.grid.getGlobalSize(), ResDataType.RD_INT) self.kw.assign(1) @@ -26,7 +26,7 @@ def setUp(self): self.kw[k * self.grid.getNX() * self.grid.getNY() + 7] = 177 def test_fault_block(self): - grid = Grid.createRectangular((5, 5, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((5, 5, 1), (1, 1, 1)) kw = ResdataKW("FAULTBLK", grid.getGlobalSize(), ResDataType.RD_INT) kw.assign(0) for j in range(1, 4): @@ -55,7 +55,7 @@ def test_get_ijk(self): with cwrap.open("kw.grdecl") as f: kw = ResdataKW.read_grdecl(f, "FAULTBLK", rd_type=ResDataType.RD_INT) - grid = Grid.createRectangular((5, 5, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((5, 5, 1), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) layer.loadKeyword(kw) @@ -85,7 +85,7 @@ def test_neighbours(self): with cwrap.open("kw.grdecl") as f: kw = ResdataKW.read_grdecl(f, "FAULTBLK", rd_type=ResDataType.RD_INT) - grid = Grid.createRectangular((5, 5, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((5, 5, 1), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) layer.loadKeyword(kw) @@ -125,7 +125,7 @@ def test_neighbours2(self): nx = 8 ny = 8 nz = 1 - grid = Grid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) with TestAreaContext("python/FaultBlocks/neighbours"): with open("faultblock.grdecl", "w") as fileH: @@ -189,7 +189,7 @@ def test_neighbours3(self): nx = 8 ny = 8 nz = 1 - grid = Grid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) with TestAreaContext("python/FaultBlocks/neighbours"): with open("faultblock.grdecl", "w") as fileH: @@ -225,7 +225,7 @@ def test_neighbours3(self): self.assertTrue(b2 in nb) def test_fault_block_edge(self): - grid = Grid.createRectangular((5, 5, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((5, 5, 1), (1, 1, 1)) kw = ResdataKW("FAULTBLK", grid.getGlobalSize(), ResDataType.RD_INT) kw.assign(0) for j in range(1, 4): @@ -333,7 +333,7 @@ def test_fault_block_layer(self): self.assertEqual([1, 2, 3], list(fault_block.getRegionList())) def test_add_polyline_barrier1(self): - grid = Grid.createRectangular((4, 1, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((4, 1, 1), (1, 1, 1)) layer = FaultBlockLayer(self.grid, 0) polyline = Polyline(init_points=[(1.99, 0.001), (2.01, 0.99)]) @@ -349,7 +349,7 @@ def test_add_polyline_barrier1(self): self.assertFalse(geo_layer.cellContact(p1, p2)) def test_add_polyline_barrier2(self): - grid = Grid.createRectangular((10, 10, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((10, 10, 1), (1, 1, 1)) layer = FaultBlockLayer(self.grid, 0) polyline = Polyline(init_points=[(0.1, 0.9), (8.9, 0.9), (8.9, 8.9)]) @@ -389,7 +389,7 @@ def test_internal_blocks(self): nx = 8 ny = 8 nz = 1 - grid = Grid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) with TestAreaContext("python/FaultBlocks/internal_blocks"): with open("faultblock.grdecl", "w") as fileH: diff --git a/python/tests/rd_tests/test_faults.py b/python/tests/rd_tests/test_faults.py index abf5dab6a..dab589d2e 100644 --- a/python/tests/rd_tests/test_faults.py +++ b/python/tests/rd_tests/test_faults.py @@ -5,7 +5,7 @@ from resdata import ResDataType from resdata.resfile import ResdataKW -from resdata.grid import Grid +from resdata.grid import Grid, GridGenerator from resdata.grid.faults import ( FaultCollection, Fault, @@ -21,7 +21,7 @@ class FaultTest(ResdataTest): @classmethod def setUpClass(cls): - cls.grid = Grid.createRectangular((151, 100, 50), (1, 1, 1)) + cls.grid = GridGenerator.createRectangular((151, 100, 50), (1, 1, 1)) def setUp(self): self.faults1 = self.createTestPath("local/ECLIPSE/FAULTS/fault1.grdecl") @@ -31,7 +31,7 @@ def test_PolylineIJ(self): nx = 10 ny = 10 nz = 10 - grid = Grid.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1)) f = Fault(grid, "F") f.addRecord(0, 1, 0, 0, 0, 0, "Y-") f.addRecord(2, 2, 0, 1, 0, 0, "X-") @@ -112,7 +112,7 @@ def test_faultLine_center(self): nx = 10 ny = 10 nz = 2 - grid = Grid.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1)) fl = FaultLine(grid, 0) C1 = (nx + 1) * 5 + 3 C2 = C1 + 2 @@ -191,7 +191,7 @@ def test_load(self): faults.load(self.grid, "No/this/does/not/exist") def test_connect_faults(self): - grid = Grid.createRectangular((100, 100, 10), (1, 1, 1)) + grid = GridGenerator.createRectangular((100, 100, 10), (1, 1, 1)) # Fault1 Fault4 # | | @@ -342,7 +342,7 @@ def test_intersect_intRays(self): self.assertEqual(join, [p1, p2]) def test_join_faults(self): - grid = Grid.createRectangular((100, 100, 10), (1, 1, 1)) + grid = GridGenerator.createRectangular((100, 100, 10), (1, 1, 1)) # Fault1 Fault4 # | | @@ -373,7 +373,7 @@ def test_join_faults(self): self.assertEqual(extra, [(2, 10), (2, 6), (5, 6)]) def test_contact(self): - grid = Grid.createRectangular((100, 100, 10), (1, 1, 1)) + grid = GridGenerator.createRectangular((100, 100, 10), (1, 1, 1)) # Fault1 Fault4 # | | @@ -471,7 +471,7 @@ def test_fault_line_order(self): nx = 120 ny = 60 nz = 43 - grid = Grid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (1, 1, 1)) with TestAreaContext("python/faults/line_order"): with open("faults.grdecl", "w") as f: f.write( @@ -509,7 +509,7 @@ def test_neighbour_cells(self): nx = 10 ny = 8 nz = 7 - grid = Grid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (1, 1, 1)) faults_file = self.createTestPath("local/ECLIPSE/FAULTS/faults_nb.grdecl") faults = FaultCollection(grid, faults_file) @@ -570,7 +570,7 @@ def test_neighbour_cells(self): self.assertListEqual(nb_cells1, true_nb_cells1) def test_polyline_intersection(self): - grid = Grid.createRectangular((100, 100, 10), (0.25, 0.25, 1)) + grid = GridGenerator.createRectangular((100, 100, 10), (0.25, 0.25, 1)) # Fault1 Fault4 # | | @@ -609,7 +609,7 @@ def test_num_linesegment(self): nx = 10 ny = 10 nz = 1 - grid = Grid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (1, 1, 1)) with TestAreaContext("python/faults/line_order"): with open("faults.grdecl", "w") as f: f.write( @@ -628,7 +628,7 @@ def test_num_linesegment(self): self.assertEqual(1, f2.numLines(0)) def test_extend_to_polyline(self): - grid = Grid.createRectangular((3, 3, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((3, 3, 1), (1, 1, 1)) # o o o o # @@ -655,7 +655,7 @@ def test_extend_to_polyline(self): self.assertIsNone(end_join) def test_extend_polyline_on(self): - grid = Grid.createRectangular((3, 3, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((3, 3, 1), (1, 1, 1)) # o o o o # @@ -686,7 +686,7 @@ def test_extend_polyline_on(self): self.assertIsNone(points) def test_stepped(self): - grid = Grid.createRectangular((6, 1, 4), (1, 1, 1)) + grid = GridGenerator.createRectangular((6, 1, 4), (1, 1, 1)) f = Fault(grid, "F") f.addRecord(4, 4, 0, 0, 0, 1, "X") f.addRecord(2, 2, 0, 0, 1, 1, "Z") @@ -725,7 +725,7 @@ def test_stepped(self): self.assertFalse(layer3.cellContact((1, 0), (2, 0))) def test_connectWithPolyline(self): - grid = Grid.createRectangular((4, 4, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((4, 4, 1), (1, 1, 1)) # o o o o o # diff --git a/python/tests/rd_tests/test_geertsma.py b/python/tests/rd_tests/test_geertsma.py index 712541a65..bd7268917 100644 --- a/python/tests/rd_tests/test_geertsma.py +++ b/python/tests/rd_tests/test_geertsma.py @@ -2,7 +2,7 @@ import pytest from resdata import ResDataType from resdata.resfile import ResdataKW, openFortIO, FortIO, ResdataFile -from resdata.grid import Grid +from resdata.grid import GridGenerator from resdata.gravimetry import ResdataSubsidence from resdata.util.test import TestAreaContext @@ -27,7 +27,7 @@ def create_init(grid, case): class GeertsmaTest(ResdataTest): @staticmethod def test_geertsma_kernel(): - grid = Grid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) + grid = GridGenerator.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) with TestAreaContext("Subsidence"): p1 = [1] create_restart(grid, "TEST", p1) @@ -67,7 +67,7 @@ def test_geertsma_kernel(): @staticmethod def test_geertsma_kernel_2_source_points_2_vintages(): - grid = Grid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) + grid = GridGenerator.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) with TestAreaContext("Subsidence"): p1 = [1, 10] @@ -109,7 +109,7 @@ def test_geertsma_kernel_2_source_points_2_vintages(): @staticmethod def test_geertsma_kernel_seabed(): - grid = Grid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) + grid = GridGenerator.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) with TestAreaContext("Subsidence"): p1 = [1] create_restart(grid, "TEST", p1) @@ -137,7 +137,7 @@ def test_geertsma_kernel_seabed(): @staticmethod def test_geertsma_kernel_seabed(): - grid = Grid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) + grid = GridGenerator.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) with TestAreaContext("Subsidence"): p1 = [1] create_restart(grid, "TEST", p1) @@ -164,7 +164,7 @@ def test_geertsma_kernel_seabed(): np.testing.assert_almost_equal(dz, 5.819790154474284e-08) def test_geertsma_rporv_kernel_2_source_points_2_vintages(self): - grid = Grid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) + grid = GridGenerator.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) with TestAreaContext("Subsidence"): p1 = [1, 10] diff --git a/python/tests/rd_tests/test_grav.py b/python/tests/rd_tests/test_grav.py index ff7a15725..4a4c37b05 100644 --- a/python/tests/rd_tests/test_grav.py +++ b/python/tests/rd_tests/test_grav.py @@ -1,7 +1,7 @@ import datetime from resdata import ResDataType from resdata.resfile import ResdataKW, ResdataFile, openFortIO, FortIO -from resdata.grid import Grid +from resdata.grid import GridGenerator from resdata.gravimetry import ResdataGrav from resdata.util.test import TestAreaContext from tests import ResdataTest @@ -10,7 +10,7 @@ class ResdataGravTest(ResdataTest): def setUp(self): - self.grid = Grid.createRectangular((10, 10, 10), (1, 1, 1)) + self.grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1)) def test_create(self): kws = [ diff --git a/python/tests/rd_tests/test_grid_equinor.py b/python/tests/rd_tests/test_grid_equinor.py index d433fa8a3..91af5bd84 100755 --- a/python/tests/rd_tests/test_grid_equinor.py +++ b/python/tests/rd_tests/test_grid_equinor.py @@ -119,7 +119,7 @@ def test_rect(self): a1 = 1.0 a2 = 2.0 a3 = 3.0 - grid = Grid.createRectangular((9, 9, 9), (a1, a2, a3)) + grid = GridGenerator.createRectangular((9, 9, 9), (a1, a2, a3)) grid.save_EGRID("rect.EGRID") grid2 = Grid("rect.EGRID") self.assertTrue(grid) @@ -163,7 +163,7 @@ def test_grdecl_load(self): actnum = IntVector(default_value=1, initial_size=1000) actnum[0] = 0 - g1 = Grid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + g1 = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) self.assertEqual(g1.getNumActive(), actnum.elementSum()) g1.save_EGRID("G.EGRID") @@ -220,7 +220,7 @@ def test_raise_IO_error(self): g = Grid("/does/not/exist.EGRID") def test_boundingBox(self): - grid = Grid.createRectangular((10, 10, 10), (1, 1, 1)) + grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1)) with self.assertRaises(ValueError): bbox = grid.getBoundingBox2D(layer=-1) diff --git a/python/tests/rd_tests/test_grid_pandas.py b/python/tests/rd_tests/test_grid_pandas.py index 15158d08e..73dff58a2 100644 --- a/python/tests/rd_tests/test_grid_pandas.py +++ b/python/tests/rd_tests/test_grid_pandas.py @@ -6,14 +6,16 @@ from resdata.resfile import ResdataKW -from resdata.grid import Grid +from resdata.grid import Grid, GridGenerator from tests import ResdataTest class GridPandasTest(ResdataTest): def test_dataframe_actnum(self): - grid = Grid.create_rectangular((2, 3, 1), (1, 1, 1), actnum=[1, 1, 0, 0, 1, 1]) + grid = GridGenerator.create_rectangular( + (2, 3, 1), (1, 1, 1), actnum=[1, 1, 0, 0, 1, 1] + ) df = grid.export_index(True) index_matrix = np.array( [[0, 0, 0, 0], [1, 0, 0, 1], [0, 2, 0, 2], [1, 2, 0, 3]] @@ -70,7 +72,9 @@ def test_dataframe_actnum(self): assert np.array_equal(data, np.array([10.5, 9.25, 2222.0, 2222.0, 2.0, 1.625])) def test_dataframe_grid_data(self): - grid = Grid.create_rectangular((2, 3, 1), (1, 1, 1), actnum=[1, 1, 0, 0, 1, 1]) + grid = GridGenerator.create_rectangular( + (2, 3, 1), (1, 1, 1), actnum=[1, 1, 0, 0, 1, 1] + ) index_frame = grid.export_index() volume_data = grid.export_volume(index_frame) assert len(volume_data) == 6 diff --git a/python/tests/rd_tests/test_kw_function.py b/python/tests/rd_tests/test_kw_function.py index dc1158b19..4f4929ce5 100644 --- a/python/tests/rd_tests/test_kw_function.py +++ b/python/tests/rd_tests/test_kw_function.py @@ -3,7 +3,7 @@ import random from resdata import ResDataType from resdata.resfile import ResdataKW, Resdata3DKW -from resdata.grid import Grid +from resdata.grid import GridGenerator from resdata.util.util import IntVector from tests import ResdataTest @@ -16,7 +16,7 @@ def test_region_filter(self): actnum = IntVector(initial_size=nx * ny * nz, default_value=1) actnum[nx * ny - 1] = 0 - grid = Grid.createRectangular((nx, ny, nz), (1, 1, 1), actnum=actnum) + grid = GridGenerator.createRectangular((nx, ny, nz), (1, 1, 1), actnum=actnum) self.assertEqual(grid.getNumActive(), nx * ny * nz - 1) kw = Resdata3DKW.create("REGIONS", grid, ResDataType.RD_INT, global_active=True) diff --git a/python/tests/rd_tests/test_layer.py b/python/tests/rd_tests/test_layer.py index 62e790c9d..9d4d96d31 100644 --- a/python/tests/rd_tests/test_layer.py +++ b/python/tests/rd_tests/test_layer.py @@ -3,7 +3,7 @@ import time from resdata.util.util import IntVector -from resdata.grid import Grid +from resdata.grid import GridGenerator from resdata.geometry import CPolyline from resdata.grid.faults import Layer, FaultCollection from resdata.util.test import TestAreaContext @@ -36,7 +36,7 @@ def test_contact(self): nx = 20 ny = 10 layer = Layer(nx, ny) - grid = Grid.createRectangular((nx, ny, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, 1), (1, 1, 1)) with self.assertRaises(IndexError): layer.cellContact((-1, 0), (1, 1)) @@ -90,7 +90,7 @@ def test_fault_barrier(self): nx = 120 ny = 60 nz = 43 - grid = Grid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (1, 1, 1)) with TestAreaContext("python/faults/line_order"): with open("faults.grdecl", "w") as f: f.write( @@ -149,7 +149,7 @@ def test_contact2(self): nx = 10 ny = 10 layer = Layer(nx, ny) - grid = Grid.createRectangular((nx, ny, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, 1), (1, 1, 1)) # Too short with self.assertRaises(ValueError): @@ -228,7 +228,7 @@ def test_matching(self): def test_add_polyline_barrier(self): d = 10 layer = Layer(d, d) - grid = Grid.createRectangular((d, d, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((d, d, 1), (1, 1, 1)) pl = CPolyline(init_points=[(0, 0), (d / 2, d / 2), (d, d)]) layer.addPolylineBarrier(pl, grid, 0) for i in range(d): @@ -244,17 +244,17 @@ def test_active(self): self.assertTrue(layer.activeCell(1, 2)) - grid = Grid.createRectangular((d, d + 1, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((d, d + 1, 1), (1, 1, 1)) with self.assertRaises(ValueError): layer.updateActive(grid, 0) - grid = Grid.createRectangular((d, d, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((d, d, 1), (1, 1, 1)) with self.assertRaises(ValueError): layer.updateActive(grid, 10) actnum = IntVector(initial_size=d * d * 1, default_value=1) actnum[0] = 0 - grid = Grid.createRectangular((d, d, 1), (1, 1, 1), actnum=actnum) + grid = GridGenerator.createRectangular((d, d, 1), (1, 1, 1), actnum=actnum) layer.updateActive(grid, 0) self.assertTrue(layer.activeCell(1, 2)) self.assertFalse(layer.activeCell(0, 0)) diff --git a/python/tests/rd_tests/test_rd_3dkw.py b/python/tests/rd_tests/test_rd_3dkw.py index 1ae1f8b9d..6d57d5e1d 100644 --- a/python/tests/rd_tests/test_rd_3dkw.py +++ b/python/tests/rd_tests/test_rd_3dkw.py @@ -5,7 +5,7 @@ from resdata.util.util import IntVector from resdata import ResDataType, FileMode from resdata.resfile import Resdata3DKW, ResdataKW, ResdataFile, FortIO -from resdata.grid import Grid +from resdata.grid import GridGenerator from resdata.util.test import TestAreaContext from tests import ResdataTest @@ -16,7 +16,7 @@ def test_create(self): for i in range(100): actnum[i] = 0 - grid = Grid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) kw = Resdata3DKW("KW", grid, ResDataType.RD_FLOAT) self.assertEqual(len(kw), grid.getNumActive()) @@ -27,7 +27,7 @@ def test_create_global_size(self): for i in range(100): actnum[i] = 0 - grid = Grid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) kw = Resdata3DKW("KW", grid, ResDataType.RD_FLOAT, global_active=True) self.assertEqual(len(kw), grid.getGlobalSize()) @@ -41,7 +41,7 @@ def test_fix_uninitialized(self): nx = 10 ny = 11 nz = 12 - grid = Grid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = GridGenerator.createRectangular((nx, ny, nz), (1, 1, 1)) kw = Resdata3DKW("REGIONS", grid, ResDataType.RD_INT, global_active=True) kw.assign(3) self.assertEqual(3 * nx * ny * nz, sum(kw)) @@ -59,7 +59,7 @@ def test_getitem(self): for i in range(100): actnum[i] = 0 - grid = Grid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) kw = Resdata3DKW("KW", grid, ResDataType.RD_FLOAT, default_value=77) with self.assertRaises(IndexError): @@ -84,7 +84,7 @@ def test_setitem(self): for i in range(100): actnum[i] = 0 - grid = Grid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) kw = Resdata3DKW("KW", grid, ResDataType.RD_FLOAT, default_value=77) with self.assertRaises(IndexError): @@ -114,7 +114,7 @@ def test_cast(self): for i in range(100): actnum[i] = 0 - grid = Grid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) kw_wrong_size = ResdataKW("KW", 27, ResDataType.RD_FLOAT) kw_global_size = ResdataKW("KW", grid.getGlobalSize(), ResDataType.RD_FLOAT) kw_active_size = ResdataKW("KW", grid.getNumActive(), ResDataType.RD_FLOAT) @@ -133,7 +133,7 @@ def test_cast(self): kw_active_size[0, 0, 0] = 88 def test_default(self): - grid = Grid.createRectangular((10, 10, 10), (1, 1, 1)) + grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1)) kw = Resdata3DKW("KW", grid, ResDataType.RD_FLOAT) kw.setDefault(55) self.assertTrue(55, kw.getDefault()) @@ -143,7 +143,7 @@ def test_compressed_copy(self): for i in range(500): actnum[2 * i + 1] = 0 - grid = Grid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) kw = Resdata3DKW("KW", grid, ResDataType.RD_INT, global_active=True) for i in range(len(kw)): kw[i] = i @@ -160,7 +160,7 @@ def test_global_copy(self): for i in range(500): actnum[2 * i + 1] = 0 - grid = Grid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + grid = GridGenerator.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) kw = Resdata3DKW("KW", grid, ResDataType.RD_INT, global_active=False) for i in range(len(kw)): kw[i] = i diff --git a/python/tests/rd_tests/test_region.py b/python/tests/rd_tests/test_region.py index efd7f0a38..6fbfe87e8 100644 --- a/python/tests/rd_tests/test_region.py +++ b/python/tests/rd_tests/test_region.py @@ -2,7 +2,7 @@ import numpy as np import pytest from resdata.resfile import ResdataKW -from resdata.grid import Grid, ResdataRegion +from resdata.grid import Grid, ResdataRegion, GridGenerator from resdata.util.util import IntVector from tests import ResdataTest from resdata.grid.faults import Layer @@ -10,7 +10,7 @@ class RegionTest(ResdataTest): def test_equal(self): - grid = Grid.createRectangular((10, 10, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((10, 10, 1), (1, 1, 1)) kw_int = ResdataKW("INT", grid.getGlobalSize(), ResDataType.RD_INT) kw_float = ResdataKW("FLOAT", grid.getGlobalSize(), ResDataType.RD_FLOAT) @@ -25,7 +25,7 @@ def test_equal(self): region.select_equal(kw_float, 1) def test_sum(self): - grid = Grid.createRectangular((10, 10, 1), (1, 1, 1)) + grid = GridGenerator.createRectangular((10, 10, 1), (1, 1, 1)) kw_mask = ResdataKW("INT", grid.getGlobalSize(), ResDataType.RD_INT) int_value = ResdataKW("INT", grid.getGlobalSize(), ResDataType.RD_INT) float_value = ResdataKW("FLOAT", grid.getGlobalSize(), ResDataType.RD_FLOAT)