Skip to content

Conversation

@cmp0xff
Copy link
Contributor

@cmp0xff cmp0xff commented Oct 30, 2025

Comment on lines -19 to +22
) -> tuple[np.ndarray, np.ndarray]: ...
) -> tuple[npt.NDArray[Any], npt.NDArray[Any]]: ...
Copy link
Member

Choose a reason for hiding this comment

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

is this a chance to make this more precise, like

tuple[np_1d_array[np.intp], np_1d_array[np.intp]]

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no insight into this class / this class method, nor is it documented in any detail (personally I don't even know what "window bounds" means). It would be great if you suggest a few tests, or can we leave it in another PR?

Copy link
Member

Choose a reason for hiding this comment

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

sure happy to leave it til later!


class CategoricalIndex(ExtensionIndex[S1], accessor.PandasDelegate):
codes: np.ndarray = ...
codes: npt.NDArray[Any] = ...
Copy link
Member

Choose a reason for hiding this comment

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

np_1d_array[np.intp]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

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

/pandas_nightly

Comment on lines -19 to +22
) -> tuple[np.ndarray, np.ndarray]: ...
) -> tuple[npt.NDArray[Any], npt.NDArray[Any]]: ...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no insight into this class / this class method, nor is it documented in any detail (personally I don't even know what "window bounds" means). It would be great if you suggest a few tests, or can we leave it in another PR?


class CategoricalIndex(ExtensionIndex[S1], accessor.PandasDelegate):
codes: np.ndarray = ...
codes: npt.NDArray[Any] = ...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +69 to +70
mid = _MidDescriptor()
length = _LengthDescriptor()
Copy link
Member

Choose a reason for hiding this comment

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

i'm fairly confused by these , aren't they just float and int respectively? not sure what these descriptors are

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • It seems we cannot overload property-ies
  • For mid, it is float for int and float, but Timestamp for Timestamp, and Timedelta for Timedelta
  • For length, it is float for float, int for int, but Timedelta for Timestamp and Timedelta

@property
def is_monotonic_increasing(self) -> bool: ...
def clear_mapping(self) -> None: ...
class IntervalTree(IntervalMixin): ...
Copy link
Member

Choose a reason for hiding this comment

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

if the above comment is right, this can probably just be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

class IntervalTree is something implemented in pandas with Cython. I don't understand what's happening with Ctyhon, but would like to leave its presence in the stubs, even though it's empty. Please tell me if you have a good argument to remove it completely.

| np_ndarray_float
| np_ndarray_complex
| dict[str, np.ndarray]
| dict[str, np_1darray[Any]]
Copy link
Member

Choose a reason for hiding this comment

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

the general pattern you seem to be following is:

  • for function arguments, don't be restrictive on shape
  • for return types, be as precise as possible

Given that NumListLike is often used as argument, would this one be better as Any shape?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for function arguments, don't be restrictive on shape

This is relevant until the end of python 3.10 because it can only use an old version of numpy, which does not give the correct shape upon construction, i.e. np.array([1, 2, 3]) does not give a 1-d array with that old version, in static typing.

would this one be better as Any shape?

Yep dc85974

Copy link
Contributor Author

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

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

/pandas_nightly

Comment on lines +69 to +70
mid = _MidDescriptor()
length = _LengthDescriptor()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • It seems we cannot overload property-ies
  • For mid, it is float for int and float, but Timestamp for Timestamp, and Timedelta for Timedelta
  • For length, it is float for float, int for int, but Timedelta for Timestamp and Timedelta

@property
def is_monotonic_increasing(self) -> bool: ...
def clear_mapping(self) -> None: ...
class IntervalTree(IntervalMixin): ...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

class IntervalTree is something implemented in pandas with Cython. I don't understand what's happening with Ctyhon, but would like to leave its presence in the stubs, even though it's empty. Please tell me if you have a good argument to remove it completely.

| np_ndarray_float
| np_ndarray_complex
| dict[str, np.ndarray]
| dict[str, np_1darray[Any]]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for function arguments, don't be restrictive on shape

This is relevant until the end of python 3.10 because it can only use an old version of numpy, which does not give the correct shape upon construction, i.e. np.array([1, 2, 3]) does not give a 1-d array with that old version, in static typing.

would this one be better as Any shape?

Yep dc85974

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.

2 participants