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
DOC: Typed NumPY API usage #19875
Comments
Thank you so much for putting in the effort of writing such a good issue! Would you be interested in writing/reviewing such a document? (It is on our list of things-to-be-done) If this interests you feel free to connect - we have a documentation team that can help and we do hold open meetings. Cheers! |
Yup. Absolutely on both accounts. What I lack in sufficient free time I compensate for with unquenchable thirst and awkward enthusiasm. My initial thoughts were leading to simplicity and terseness – because the perfect is the enemy of the usable and it would be great to have something where currently we have nothing. Would submitting a PR appending or prepending a new draft subsection to the existing typed API expose be a reasonable starting place? NumPy documentation is vast and sprawling and spreads like a tentacular horror from the Gulf of Mexico across multiple tutorials, manuals, references, quickstarters, API discussions, embedded docstrings, and even more inscrutable sources. As a cretaceous fish out of water, I leave everything up to your discriminating judgement. Thanks for the prompt reply, Melissa. NumPy devs always the best devs. 😺 |
Hi @leycec, if you're interested in contributing you're more than welcome to do so! While I'm not too familiar with the current state of runtime type checkers, I can provide some insight about static checkers: Namely, numpy's annotations are based on what was introduced in PEP 484 and the subsequent typing-related peps, standards which static type checkers are expected to (eventually) support. It is definetelly possible that different type checkers might produce (slightly) different results though, be it either due to bugs/features and/or the reality that numpy is pushing the current typing system somewhat to its limits. An exception to this general rule is, of course, the mypy plugin. As the name implies, this one is exclusively available for mypy.
I agree, this sounds like a reasonably place to add more typing documentation. |
Superb. When I find a free moment, ...a geek can dream I'll submit a draft PR and ping you both onto it. Thanks for the rapid and enthusiastic turnaround here, too. Lovin' it! 😄
Yes. Absolutely. I was initially shocked (in a pleasant way) by the depth of the That said, The pivotal This is why an exhaustive list of static and runtime type checkers that explicitly support Thanks again for all the vivacious discussion, everyone. Let's type-check this! |
Update: I still have done nothing. That said, I noted this most recent comment on the NumPy gitter:
...clearly, we have work to do. 😓 |
PyCharm still complains loudly when typed NumPy API is used, did anybody find a solution to it? |
...ugh. Regretfully, I wasn't able to commit any meaningful resources to this. 2022 is looking equally dense with work, too. I'll happily review anything anyone readies for PR submission, though! This is a non-trivial topic and confusion abounds. Let's set the record straight next year. 😉 @sarimmehdi: PyCharm complaints are orthogonal (although related) to this issue, which is specific to documentation. Would you mind opening up a separate issue for that – assuming there isn't already one? |
Hey there! I am interested to work on this guide ! Looking forward to contribute! |
Update
Can someone kindly confirm?
Otherwise, loved how superfluous and diversely functional |
@ssanya942 you’re completely right about point 2, but I don’t quite understand what you’re talking about with point 1; |
Documentation
The well-documented Typing subsection exhaustively details our typed NumPy API (which is great), complete with concise examples (which is even greater). With one notable exception pertaining to mypy, however, this subsection lacks a substantive discussion of actual usage – how NumPy type hints are actually used, applied, and enforced in real-world practice (which is less than great).
A trailing subsubsection briefly enumerating usage practicalities could prove useful, especially if doing so curtails discussion churn elsewhere (e.g., on Gitter or this issue tracker).
Since NumPy itself and Python interpreters in general silently ignore annotations, NumPy type hints have no force or effect in and of themselves; by design, they reduce to noops in the absence of external third-party support. There only exist two PEP-compliant type checkers explicitly supporting the typed NumPy API. ...to my limited knowledge Usage of NumPy type hints thus presupposes use of one or both of these type checkers.
Drumroll, please. These are...
Static Type Checking
Static type checkers explicitly supporting the typed NumPy API include:
There exist three other well-maintained static type checkers, but it's unclear whether they currently support the typed NumPy API:
They probably don't (yet), but probably will (eventually). A simple list or table enumerating which of these checkers support NumPy type hints – and as of which checker version – would go a long way to addressing usage. Likewise...
Runtime Type Checking
Runtime type checkers explicitly supporting the typed NumPy API include:
There exist two other well-maintained runtime type checkers that sadly both fail to support the typed NumPy API:
Again, a simple list or table enumerating which of these checkers support NumPy type hints – and as of which checker version – would simplify everyone's hectic focus on revolutionizing the world with NumPy.
That's All the Data Scientist Wrote
Thanks for all the jaw-dropping volunteerism, NumPy doco evangelists! I remain in awe of your commitment to sound data science in Python, the language of AI. Everyone here deserves all the thunderous applause I have to give. Sadly, these emoji will have to do.
👏 ⚡ 👏
The text was updated successfully, but these errors were encountered: