### Re: [Numpy-discussion] Type annotations for NumPy

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 >

### Re: [Numpy-discussion] What is the pythonic way to write a function that handles arrays and scalars?

On minor thing that instead of 'ret' there should be 'x'. With kind regards, -gdg On Dec 12, 2017 22:51, "Joe" wrote: Hi, the best example I found was this one: https://stackoverflow.com/a/29319864/7919597 def func_for_scalars_or_vectors(x): x = np.asarray(x)

### Re: [Numpy-discussion] What is the pythonic way to write a function that handles arrays and scalars?

Oh, sorry for noise... With kind regards, -gdg On Dec 12, 2017 23:05, "Robert Kern" <robert.k...@gmail.com> wrote: > On Wed, Dec 13, 2017 at 5:00 AM, Kirill Balunov <kirillbalu...@gmail.com> > wrote: > > > > On minor thing that instead of 'ret' there

### [Numpy-discussion] Sorting of an array row-by-row?

Hi, I was trying to sort an array (N, 3) by rows, and firstly come with this solution: N = 100 arr = np.random.randint(-100, 100, size=(N, 3)) dt = np.dtype([('x', int),('y', int),('z', int)]) *arr.view(dtype=dt).sort(axis=0)* Then I found another way using lexsort function *:* *idx =

### Re: [Numpy-discussion] Sorting of an array row-by-row?

h is 1D. 1D arrays do not have an axis=1. You actually > want to iterate over the columns, so np.lexsort(a.T) is the correct > phrasing of that. No idea about the speed difference. > >-Joe > > On Fri, Oct 20, 2017 at 6:00 AM, Kirill Balunov <kirillbalu...@gmail.com> >

### [Numpy-discussion] dtype argument description for np.array

Currently in docstring the description of dtype argument for np.array says this: dtype : data-type, optional > The desired data-type for the array. If not given, then the type will > be determined as the minimum type required to hold the objects in the > sequence. This argument can

### [Numpy-discussion] type promotion rules for integers

What considerations formed the basis for choosing the next type promotion behavior in numpy: In[2] : a = np.array([10], dtype=np.int64) b = np.array([10], dtype=np.uint64) (a+b).dtype Out[2]: dtype('float64') Why the `object` dtype was not chosen for the resulting dtype? Are