Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add annotations for np.matrix #20105

Merged
merged 2 commits into from
Oct 12, 2021
Merged

ENH: Add annotations for np.matrix #20105

merged 2 commits into from
Oct 12, 2021

Conversation

BvB93
Copy link
Member

@BvB93 BvB93 commented Oct 12, 2021

This PR adds basic annotations for np.matrix.

At this point we've hit to bottom of the barrel as far as annotating the main numpy namespace is concerned.
After this PR only chararray and MachAr remain.

def mean(self, axis: None | _ShapeLike = ..., dtype: DTypeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...

@overload
def std(self, axis: None = ..., dtype: DTypeLike = ..., out: None = ..., ddof: float = ...) -> Any: ...
Copy link
Member

Choose a reason for hiding this comment

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

Do int count as float for ddof?

Copy link
Member

Choose a reason for hiding this comment

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

I see that it works, but it is documented as an int. Maybe that should be changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, int is considered a subtype of float per PEP 484.

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 see that it works, but it is documented as an int. Maybe that should be changed?

There seems to be a pre-existing issue that proposes this change (#18650); based on this I think it might be worthwhile.

Copy link
Member

Choose a reason for hiding this comment

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

It works for floats like 1.5, and, IIRC, that can sometimes be useful. So probably the documentation should be changed.

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

Successfully merging this pull request may close these issues.

None yet

2 participants