Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/arrays/masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ def equals(self, other) -> bool:
return array_equivalent(left, right, dtype_equal=True)

def _quantile(
self: BaseMaskedArrayT, qs: npt.NDArray[np.float64], interpolation: str
self, qs: npt.NDArray[np.float64], interpolation: str
) -> BaseMaskedArray:
Copy link
Member Author

Choose a reason for hiding this comment

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

Pyright didn't previously find this. I assume the return value can be any BaseMaskedArray.

Copy link
Member

Choose a reason for hiding this comment

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

yep. maybe add type annotations to _maybe_mask_result also.

Copy link
Member

Choose a reason for hiding this comment

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

can be follow-on. I suspect that _maybe_mask_result should probably return the same type, but since we use explicit Subclass constructors this would not be the case if we subclass further.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will leave this out - it would require quite a few ignore comments if we do something like:

    @overload
    def _maybe_mask_result(self, result: ArrayLike, mask: ArrayLike) -> ArrayLike:
        ...

    @overload
    def _maybe_mask_result(
        self, result: tuple[ArrayLike, ArrayLike], mask: ArrayLike
    ) -> tuple[ArrayLike, ArrayLike]:
        ...

    def _maybe_mask_result(
        self, result: ArrayLike | tuple[ArrayLike, ArrayLike], mask: ArrayLike
    ) -> ArrayLike | tuple[ArrayLike, ArrayLike]:

For example FloatingArray and BooleanArray require an ndarray not an ExtensionArray.

"""
Dispatch to quantile_with_mask, needed because we do not have
Expand Down