Skip to content

TST: Fix tests for pandas 3 NA/readonly behavior - #333

Merged
GibranAlfa merged 2 commits into
equinor:mainfrom
GibranAlfa:fix-pandas3
Jan 22, 2026
Merged

TST: Fix tests for pandas 3 NA/readonly behavior#333
GibranAlfa merged 2 commits into
equinor:mainfrom
GibranAlfa:fix-pandas3

Conversation

@GibranAlfa

Copy link
Copy Markdown
Contributor

Resolves #331

Comment on lines +81 to +86
_series_values = pd.Series.values
pd.Series.values = property(lambda self: self.to_numpy(copy=True))
try:
dframe = xtg_well.get_zonation_points(top_prefix="", use_undef=True).copy()
finally:
pd.Series.values = _series_values

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally sure about this. Is this basically working around xtgeo not being up-to-date with pandas? If that is the case, maybe it's more prudent to pin it (or release a patch version of xtgeo with pandas pinned)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is a hack due to xtgeo not up to date with pandas 3. i mean it's easy just to pin pandas, but do we want to update xtgeo to pandas 3 or it doesn't matter and too much work (may turn out not so much work)?

@mferrera mferrera Jan 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm releasing a new version of xtgeo with a pinned pandas. I propose we revert this particular change and just take in the test update to work with pandas 3.

There's not a big rush to update xtgeo to pandas 3 and it seems to affect mostly wells, which @jcrivenaes is working on right now, so there's double messiness in adapting to pandas 3. It's typical in Komodo that when a major version of a major package like this is updated it may be many months before its taken into Komodo (for numpy 2 and pandas 2 it was almost a year)

Comment on lines +160 to +164
assert {"TOP", "MID", "Below_Low_reek"} == set(
pdf.dataframe["ZONE"].dropna().unique()
)

assert {"SAND", "SHALE"} == {
x for x in list(pdf.dataframe["FACIES"].unique()) if x is not None
}
assert {"SAND", "SHALE"} == set(pdf.dataframe["FACIES"].dropna().unique())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fix works for pandas 2 and 3

@GibranAlfa
GibranAlfa merged commit 81fe883 into equinor:main Jan 22, 2026
9 checks passed
@GibranAlfa
GibranAlfa deleted the fix-pandas3 branch January 22, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pandas 3.0.0 failures

2 participants