<div dir="ltr"><p dir="ltr">Hi Sebastian, thanks for your reply</p>
<p dir="ltr">I'm glad to hear that you see value in having type annotations. Just to clarify, my question was aimed at surveying if there was interest in accepting the work we're already doing if we contribute it and if it has value for the numpy project. I'm aware there's effort involved; some colleagues and me are already involved doing that at <a href="https://github.com/machinalis/mypy-data" target="_blank">https://github.com/machinalis/mypy-data</a> because it's valuable for ourselves, so the volunteers are already here. You of course are invited to comment on the existing code and try it :) (or joining the effort, goes without saying)</p>
<p dir="ltr">Running the checker on the test suite is probably the best way to validate the annotations (the normal way would be checking the annotations against the code, but that doesn't work with C extensions like numpy). That's something we haven't been doing yet but it's an obvious next step now that some simple examples are working.</p>
<div class="gmail_extra">WRT "<span style="font-size:12.8px">I wonder if all or most of numpy can be easily put into it.", we've covered ndarray (and matrix soon) which are the core types, things built upon that shouldn't be too hard. We found some snags along the way [1] [2], but no of it is a showstopper and I'm quite sure we'll fix those in time. But of course, if someone wants to try it out it will be a better validation than my optimism to see if this makes sense :)</span></div><div class="gmail_extra"><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><span style="font-size:12.8px">Thanks again and I'd be happy to hear more opinions from other numpy devs!</span></div><div class="gmail_extra"><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><span style="font-size:12.8px">Best,</span></div><div class="gmail_extra"><span style="font-size:12.8px">   D.</span></div><div class="gmail_extra"><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><span style="font-size:12.8px">[1] <a href="http://www.machinalis.com/blog/writing-type-stubs-for-numpy/">http://www.machinalis.com/blog/writing-type-stubs-for-numpy/</a></span></div><div class="gmail_extra"><span style="font-size:12.8px">[2] <a href="https://github.com/machinalis/mypy-data/issues">https://github.com/machinalis/mypy-data/issues</a></span></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 Jul 2016 08:31, "Sebastian Berg" <<a href="mailto:sebastian@sipsolutions.net" target="_blank">sebastian@sipsolutions.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On Mi, 2016-07-27 at 20:07 +0100, Daniel Moisset wrote:<br>
><br>
> Hi, <br>
><br>
> I work at Machinalis were we use a lot of numpy (and the pydata stack<br>
> in general). Recently we've also been getting involved with mypy,<br>
> which is a tool to type check (not on runtime, think of it as a<br>
> linter) annotated python code (the way of annotating python types has<br>
> been recently standarized in PEP 484).<br>
><br>
> As part of that involvement we've started creating type annotations<br>
> for the Python libraries we use most, which include numpy. Mypy<br>
> provides a way to specify types with annotations in separate files in<br>
> case you don't have control over a library, so we have created an<br>
> initial proof of concept at [1], and we are actively improving it.<br>
> You can find some additional information about it and some problems<br>
> we've found on the way at this blogpost [2].<br>
><br>
> What I wanted to ask is if the people involved on the numpy project<br>
> are aware of PEP484 and if you have some interest in starting using<br>
> them. The main benefit is that annotations serve as clear (and<br>
> automatically testable) documentation for users, and secondary<br>
> benefits is that users discovers bugs more quickly and that some IDEs<br>
> (like pycharm) are starting to use this information for smart editor<br>
> features (autocompletion, online checking, refactoring tools);<br>
> eventually tools like jupyter could take advantage of these<br>
> annotations in the future. And the cost of writing and including<br>
> these are relatively low.<br>
><br>
<br>
There is currently no plan to do it as far as I know, but with these<br>
things it is often more of a problem that someone volunteers to<br>
maintain it then to convince everyone that it is a good idea.<br>
If there is enough interest we could talk about hosting it on the numpy<br>
github group as a separate project to make it a bit more<br>
visible/obvious that such a project exists.<br>
<br>
For inclusion in numpy, it seems to me that currently this would<br>
probably be better of improved separately? In the long run, would it be<br>
possible to do something like run all numpy tests and then check<br>
whether the definitions cover (almost) everything, or test against the<br>
documentation or so? Otherwise it might get tricky to keep things quite<br>
up to date, at least until these type checks are very widely used. Also<br>
I wonder if all or most of numpy can be easily put into it.<br>
<br>
Anyway, it seems like a great project to have as much support for type<br>
annotations as possible. I have never used them, but with editors<br>
picking up on these things it sounds like it could be very useful in<br>
the future.<br>
<br>
- Sebastian<br>
<br>
<br>
> We're doing the work anyway, but contributing our typespecs back<br>
> could make it easier for users to benefit from this, and for us to<br>
> maintain it and keep it in sync with future releases.<br>
><br>
> If you've never heard about PEP484 or mypy (it happens a lot) I'll be<br>
> happy to clarify anything about it that might helpunderstand this<br>
> situation<br>
><br>
> Thanks!<br>
><br>
> D.<br>
><br>
><br>
> [1] <a href="https://github.com/machinalis/mypy-data" rel="noreferrer" target="_blank">https://github.com/machinalis/mypy-data</a> <br>
> [2] <a href="http://www.machinalis.com/blog/writing-type-stubs-for-numpy/" rel="noreferrer" target="_blank">http://www.machinalis.com/blog/writing-type-stubs-for-numpy/</a><br>
><br>
> -- <br>
> Daniel F. Moisset - UK Country Manager<br>
> <a href="http://www.machinalis.com" rel="noreferrer" target="_blank">www.machinalis.com</a><br>
> Skype: @dmoisset<br>
> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
> <a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div></div>
</div>