diff --git a/.pylintrc b/.pylintrc index 3474cf618..7797e69f3 100644 --- a/.pylintrc +++ b/.pylintrc @@ -11,7 +11,7 @@ argument-rgx=^[a-z_][_a-z0-9]+((_[a-z0-9]+)*)?$ dummy-variables-rgx=^_+[a-z0-9]*?$|dummy [TYPECHECK] -generated-members=np.*, numpy.*, pd.*, pandas.*, cxtgeo.*, matplotlib.* +generated-members=np.*, numpy.*, pd.*, pandas.*, cxtgeo.*, matplotlib.*, xtgeo.* [FORMAT] max-line-length=88 diff --git a/src/xtgeo/well/_well_oper.py b/src/xtgeo/well/_well_oper.py index 1506ef372..8e472b7ab 100644 --- a/src/xtgeo/well/_well_oper.py +++ b/src/xtgeo/well/_well_oper.py @@ -1,5 +1,7 @@ """Operations along a well, private module.""" +from copy import deepcopy + import numpy as np import pandas as pd @@ -319,13 +321,14 @@ def get_gridproperties(self, gridprops, grid=("ICELL", "JCELL", "KCELL"), prop_i arr[np.isnan(xind)] = np.nan pname = prop.name + prop_id dfr[pname] = arr - pnames[pname] = (prop.isdiscrete, prop.codes) + pnames[pname] = (prop.isdiscrete, deepcopy(prop.codes)) wcopy.set_dataframe(dfr) for pname, isdiscrete_codes in pnames.items(): isdiscrete, codes = isdiscrete_codes if isdiscrete: wcopy.set_logtype(pname, _AttrType.DISC.value) + print("\nXXXXXX", codes) wcopy.set_logrecord(pname, codes) else: wcopy.set_logtype(pname, _AttrType.CONT.value) diff --git a/src/xtgeo/xyz/_xyz_data.py b/src/xtgeo/xyz/_xyz_data.py index 9d63d5b0a..05648e51c 100644 --- a/src/xtgeo/xyz/_xyz_data.py +++ b/src/xtgeo/xyz/_xyz_data.py @@ -319,14 +319,14 @@ def ensure_consistency(self) -> bool: occured, hence no consistency checks are done """ - # the purpose of this hash check is to avoid psending time on consistency + # the purpose of this hash check is to avoid spending time on consistency # checks if no changes hash_proposed = ( jhash(self._df), jhash(self._attr_types), jhash(self._attr_records), ) - + print("XXXX hashes", self._hash, hash_proposed, list(self._df.columns[3:])) if self._hash == hash_proposed: return False @@ -337,6 +337,7 @@ def ensure_consistency(self) -> bool: ) # order matters: + print("XXXXXY -- need to check") self._ensure_consistency_attr_types() self._ensure_consistency_attr_records() self._ensure_consistency_df_dtypes() diff --git a/tests/test_well/test_well_vs_grid.py b/tests/test_well/test_well_vs_grid.py index 6496d6c2e..98da6b284 100644 --- a/tests/test_well/test_well_vs_grid.py +++ b/tests/test_well/test_well_vs_grid.py @@ -85,3 +85,24 @@ def test_well_get_gridprops(tmpdir, loadwell1, loadgrid1, loadporo1): assert mywell.dataframe.iloc[4775]["PORO_model"] == pytest.approx(0.2741, abs=0.001) assert mywell.dataframe.iloc[4775]["ACTNUM_model"] == 1 assert mywell.isdiscrete("ACTNUM_model") is True + + +def test_well_gridprops_zone(): + """Test getting logrecords from discrete gridzones""" + grid = xtgeo.grid_from_file("../xtgeo-testdata/3dgrids/reek/reek_sim_grid.roff") + gridzones = xtgeo.gridproperty_from_file( + "../xtgeo-testdata/3dgrids/reek/reek_sim_zone.roff", grid=grid + ) + gridzones.name = "Zone" + + print("00XXXXXX read well") + well = xtgeo.well_from_file("../xtgeo-testdata/wells/reek/1/OP_1.w") + print("00XXXXXX get gridprops") + well.get_gridproperties(gridzones, grid) + + print("00XXXXXX assert") + assert well.get_logrecord("Zone_model") == { + 1: "Below_Top_reek", + 2: "Below_Mid_reek", + 3: "Below_Low_reek", + }