Re: [Numpy-discussion] Type annotations for NumPy

2017-12-05 Thread Stephan Hoyer
OK, in that case let's get to work over in https://github.com/numpy/numpy_stubs! On Tue, Dec 5, 2017 at 2:43 PM Fernando Perez wrote: > On Tue, Dec 5, 2017 at 2:19 PM, Nathaniel Smith wrote: > >> On Tue, Dec 5, 2017 at 10:04 AM, Stephan Hoyer wrote: >> > This discussion has died down, but I do

Re: [Numpy-discussion] Type annotations for NumPy

2017-12-05 Thread Fernando Perez
On Tue, Dec 5, 2017 at 2:19 PM, Nathaniel Smith wrote: > On Tue, Dec 5, 2017 at 10:04 AM, Stephan Hoyer wrote: > > This discussion has died down, but I don't want to lose momentum . > > > > It sounds like there is at least strong interest from a subset of our > > community in type annotations. A

Re: [Numpy-discussion] Type annotations for NumPy

2017-12-05 Thread Nathaniel Smith
On Tue, Dec 5, 2017 at 10:04 AM, Stephan Hoyer wrote: > This discussion has died down, but I don't want to lose momentum . > > It sounds like there is at least strong interest from a subset of our > community in type annotations. Are there any objections to the first part of > my plan, to start de

Re: [Numpy-discussion] Type annotations for NumPy

2017-12-05 Thread Stephan Hoyer
This discussion has died down, but I don't want to lose momentum . It sounds like there is at least strong interest from a subset of our community in type annotations. Are there any objections to the first part of my plan, to start developing type stubs for NumPy in separate repository? We'll com

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-28 Thread Chris Barker - NOAA Federal
(a) it would be good if NumPy type annotations could include an “array_like” type that allows lists, tuples, etc. I think that would be a sequence — already supported by the Typing system. (b) I’ve always thought (since PEP561) that it would be cool for type annotations to replace compiler type

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-28 Thread Chris Barker - NOAA Federal
On Nov 25, 2017, at 3:35 PM, Matthew Rocklin wrote: Thoughts on basing this on a more generic Array type rather than the np.ndarray? This would actually be more consistent with the current python typing approach. I can imagine other nd-array libraries (XArray, Tensorflow, Dask.array) wanting t

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-28 Thread Robert T. McGibbon
Here's the code: https://github.com/rmcgibbo/numpy-mypy. It's not 100% working yet, but it can do simple stuff, like inferring the shape of arrays created from np.zeros(literal_tuple), and fixing out the shape of the result of an indexing operation (i.e. https://github.com/rmcgibbo/numpy-mypy/blob

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-28 Thread Stephan Hoyer
On Tue, Nov 28, 2017 at 5:11 PM Robert T. McGibbon wrote: > I'm strongly in support of this proposal. Type annotations have really > helped me write more correct code. > > I started working on numpy type stubs a few months ago. I needed a mypy > plugin to support shape-aware functions. Those who

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-28 Thread Robert T. McGibbon
I'm strongly in support of this proposal. Type annotations have really helped me write more correct code. I started working on numpy type stubs a few months ago. I needed a mypy plugin to support shape-aware functions. Those whole thing is pretty tricky. Still very WIP, but I'll clean them up a l

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-26 Thread Stephan Hoyer
On Sat, Nov 25, 2017 at 3:34 PM Matthew Rocklin wrote: > Thoughts on basing this on a more generic Array type rather than the > np.ndarray? I can imagine other nd-array libraries (XArray, Tensorflow, > Dask.array) wanting to reuse this work. For dask.array in particular we > would want to copy

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-26 Thread Jelle Zijlstra
2017-11-26 6:00 GMT-05:00 Kirill Balunov : > Hi! > > 2017-11-26 4:31 GMT+03:00 Juan Nunez-Iglesias : > >> >> On 26 Nov 2017, 12:27 PM +1100, Nathaniel Smith , wrote: >> >> It turns out that the PEP 484 type system is *mostly* not useful for >> this. They're really designed for checking consistency

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-26 Thread Kirill Balunov
Hi! 2017-11-26 4:31 GMT+03:00 Juan Nunez-Iglesias : > > On 26 Nov 2017, 12:27 PM +1100, Nathaniel Smith , wrote: > > It turns out that the PEP 484 type system is *mostly* not useful for > this. They're really designed for checking consistency across a large > code-base, not for enabling compiler

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-25 Thread Juan Nunez-Iglesias
On 26 Nov 2017, 12:27 PM +1100, Nathaniel Smith , wrote: > It turns out that the PEP 484 type system is *mostly* not useful for > this. They're really designed for checking consistency across a large > code-base, not for enabling compiler speedups. For example, if you > annotate something as an in

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-25 Thread Nathaniel Smith
On Sat, Nov 25, 2017 at 3:09 PM, Juan Nunez-Iglesias wrote: > This is a complete outsider’s perspective but > > (a) it would be good if NumPy type annotations could include an “array_like” > type that allows lists, tuples, etc. I'm sure this will exist. > (b) I’ve always thought (since PEP561) t

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-25 Thread Matthew Rocklin
Thoughts on basing this on a more generic Array type rather than the np.ndarray? I can imagine other nd-array libraries (XArray, Tensorflow, Dask.array) wanting to reuse this work. For dask.array in particular we would want to copy this entirely, but we probably can't specify that dask.arrays are

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-25 Thread Matthew Rocklin
Can you make a case for the usefulness numpy annotations? What benefits to you want to achieve and how will annotation aid in getting there. 1. Error checking on large codebases with systems like MyPy 2. Hinting and error checking at code-writing time with systems like Jedi "Hey, this fu

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-25 Thread Stephan Hoyer
On Sat, Nov 25, 2017 at 7:21 AM Marten van Kerkwijk < m.h.vankerkw...@gmail.com> wrote: > A question of perhaps broader scope than what you were asking for, and > more out of curiosity than anything else, but can one mix type > annotations with others? E.g., in astropy, we have a decorator that >

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-25 Thread Juan Nunez-Iglesias
This is a complete outsider’s perspective but (a) it would be good if NumPy type annotations could include an “array_like” type that allows lists, tuples, etc. (b) I’ve always thought (since PEP561) that it would be cool for type annotations to replace compiler type annotations for e.g. Cython a

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-25 Thread Charles R Harris
On Sat, Nov 25, 2017 at 1:14 AM, Stephan Hoyer wrote: > There's been growing interest in supporting PEP-484 style type annotations > in NumPy: https://github.com/numpy/numpy/issues/7370 > > This would allow NumPy users to add type-annotations to their code that > uses NumPy, which they could chec

Re: [Numpy-discussion] Type annotations for NumPy

2017-11-25 Thread Marten van Kerkwijk
Hi Stephan, A question of perhaps broader scope than what you were asking for, and more out of curiosity than anything else, but can one mix type annotations with others? E.g., in astropy, we have a decorator that looks for units in the annotations (not dissimilar from dtype, I guess). Could one m

[Numpy-discussion] Type annotations for NumPy

2017-11-25 Thread Stephan Hoyer
There's been growing interest in supporting PEP-484 style type annotations in NumPy: https://github.com/numpy/numpy/issues/7370 This would allow NumPy users to add type-annotations to their code that uses NumPy, which they could check with mypy, pycharm or pytype. For example: def f(x: np.ndarray