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