Skip to content

Cover CategoricalIndex and EA edge cases#11310

Open
alippai wants to merge 3 commits intopydata:mainfrom
alippai:codex/fix-categoricalindex-problem-and-add-tests
Open

Cover CategoricalIndex and EA edge cases#11310
alippai wants to merge 3 commits intopydata:mainfrom
alippai:codex/fix-categoricalindex-problem-and-add-tests

Conversation

@alippai
Copy link
Copy Markdown

@alippai alippai commented Apr 22, 2026

Description

Checklist

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR. Tools: Codex cloud

@github-actions github-actions Bot added topic-indexing topic-arrays related to flexible array support labels Apr 22, 2026
@alippai
Copy link
Copy Markdown
Author

alippai commented Apr 23, 2026

Cc @ilan-gold

Comment on lines +412 to +418
if isinstance(
condition, pd.api.extensions.ExtensionArray
) and pd.api.types.is_bool_dtype(condition.dtype):
# pandas nullable booleans can contain <NA>, which cannot be cast
# directly to bool. For masking semantics, treat missing condition
# values as False.
condition = condition.fillna(False)
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 would probably just outright error here.

Comment thread xarray/core/indexes.py
Comment on lines 915 to 924
if is_allowed_extension_array_dtype(index.dtype):
return type(self)(index, self.dim)
coord_dtype = np.result_type(self.coord_dtype, other.coord_dtype)
try:
coord_dtype = np.result_type(self.coord_dtype, other.coord_dtype)
except TypeError:
# pandas extension dtypes (e.g., CategoricalDtype) are not always
# compatible with numpy's type promotion even when the resulting
# index dtype is a regular NumPy dtype.
coord_dtype = get_valid_numpy_dtype(index)
return type(self)(index, self.dim, coord_dtype=coord_dtype)
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.

How is this code reached give the above if is_allowed_extension_array_dtype(index.dtype): guard clause?

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.

@pydata/xarray Is there interest in codecov?

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.

Not sure quite sure what you mean by this. We already have codecov set up https://app.codecov.io/gh/pydata/xarray/pull/11310 (it just doesn't comment on PRs - which I like since I find the bot noisy)

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.

Yeah, I suppose I assumed it was not present. Good to know! I like it for exactly this reason, but now that I know it's here, I'll check :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-arrays related to flexible array support topic-indexing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

where/join/concat failures using esoteric dtypes

3 participants