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