Re: [Numpy-discussion] Type casting problems with numpy.take

2013-02-08 Thread Jaime Fernández del Río
On Fri, Feb 8, 2013 at 6:44 PM, Charles R Harris charlesr.har...@gmail.comwrote: My money is on 'five year old bug'. A bug indeed it seems to be. I have cloned the source code, and in item_selection.c, in function PyArray_TakeFrom, when 'out' is an argument in the call, the code is actually

Re: [Numpy-discussion] View on sliced array without copy

2013-02-12 Thread Jaime Fernández del Río
On Tue, Feb 12, 2013 at 9:53 AM, Nicolas Rougier nicolas.roug...@inria.frwrote: Did I do something wrong or is it expected behavior ? Try: print (Z.view('f4'))[:50].base.base is Z # True print Z[:50].view('f4').base.base is Z # True This weird behaviour is fixed in the just-released numpy

Re: [Numpy-discussion] Apply transform to many small matrices

2013-02-27 Thread Jaime Fernández del Río
On Wed, Feb 27, 2013 at 5:41 AM, Jorge Scandaliaris jorgesmbox...@yahoo.eswrote: Jorge Scandaliaris jorgesmbox-ml at yahoo.es writes: I have an ndarray A of shape (M,2,2) representing M 2 x 2 matrices. Now I want to apply a transform T of shape (2,2) to each of matrix. np.einsum makes a

[Numpy-discussion] polyfit with fixed points

2013-03-04 Thread Jaime Fernández del Río
A couple of days back, answering a question in StackExchange ( http://stackoverflow.com/a/15196628/110026), I found myself using Lagrange multipliers to fit a polynomial with least squares to data, making sure it went through some fixed points. This time it was relatively easy, because some 5

Re: [Numpy-discussion] polyfit with fixed points

2013-03-04 Thread Jaime Fernández del Río
of the Lagrange multipliers calculated during the fit. Jaime A On Mon, Mar 4, 2013 at 7:23 PM, Jaime Fernández del Río jaime.f...@gmail.com wrote: A couple of days back, answering a question in StackExchange ( http://stackoverflow.com/a/15196628/110026), I found myself using Lagrange

Re: [Numpy-discussion] polyfit with fixed points

2013-03-04 Thread Jaime Fernández del Río
On Mon, Mar 4, 2013 at 8:37 PM, Charles R Harris charlesr.har...@gmail.comwrote: There are actually seven versions of polynomial fit, two for the usual polynomial basis, and one each for Legendre, Chebyshev, Hermite, Hermite_e, and Laguerre ;) Correct me if I am wrong, but the fitted

Re: [Numpy-discussion] polyfit with fixed points

2013-03-06 Thread Jaime Fernández del Río
On Tue, Mar 5, 2013 at 5:23 AM, Charles R Harris charlesr.har...@gmail.comwrote: On Tue, Mar 5, 2013 at 12:41 AM, Jaime Fernández del Río jaime.f...@gmail.com wrote: On Mon, Mar 4, 2013 at 8:37 PM, Charles R Harris charlesr.har...@gmail.com wrote: There are actually seven versions

[Numpy-discussion] Generalized inner?

2013-03-24 Thread Jaime Fernández del Río
The other day I found myself finding trailing edges in binary images doing something like this: arr = np.random.randint(2, size=1000).astype(np.int8) pattern = np.array([1, 1, 1, 1, 0, 0]) arr_match = 2*arr - 1 pat_match = 2*pattern - 1 from numpy.lib.stride_tricks import as_strided arr_win =

Re: [Numpy-discussion] Indexing bug?

2013-03-30 Thread Jaime Fernández del Río
On Sat, Mar 30, 2013 at 11:01 AM, Ivan Oseledets ivan.oseled...@gmail.comwrote: I am using numpy 1.6.1, and encountered a wierd fancy indexing bug: import numpy as np c = np.random.randn(10,200,10); In [29]: print c[[0,1],:200,:2].shape (2, 200, 2) In [30]: print

[Numpy-discussion] Will transpose ever need to copy data?

2013-06-11 Thread Jaime Fernández del Río
I noticed today that the documentation for np.transpose states, for the return value, that A view is returned whenever possible. Is there really any situation where swapping axes around could trigger the need to copy data, or will a view always be returned no matter what? I can't think of any

Re: [Numpy-discussion] Will transpose ever need to copy data?

2013-06-12 Thread Jaime Fernández del Río
On Wed, Jun 12, 2013 at 6:48 AM, Nathaniel Smith n...@pobox.com wrote: Sounds like a doc bug. (Probably someone being over-careful -- the default for many operations in numpy is that it's undefined whether they return a view or not, so if it makes a difference to you you need to take an

[Numpy-discussion] Questions on GUFUNCS

2013-08-04 Thread Jaime Fernández del Río
Hi! I have spent the last couple of weeks playing around with GUFUNCS, and am literally blown away by the power that a C compiler and NumPy put at the tip of my fingers! I still have many questions, but the following ones are the most pressing in my current state of amazed ignorance: 1. **The

[Numpy-discussion] Bug in gufuncs affecting umath_linalg

2013-08-06 Thread Jaime Fernández del Río
Hi, I think I have found an undocumented feature of the gufuncs machinery. I have filed a bug report: https://github.com/numpy/numpy/issues/3582 Some more background on what i am seeing... I have coded a gufunc with signature '(r,c,p),(g,g,g,q)-(r,c,q)'. It is a color map, i.e. a

Re: [Numpy-discussion] Error occurance on Skimage 0.9.0 version

2013-09-05 Thread Jaime Fernández del Río
I haven't tried to compile skimage, but the easiest way to get set up for compilation with Windows and MSVC is to follow the instructions in the Cython wiki. It is routinely spammed, so here's a link to the last non-corrupt version as of right now:

[Numpy-discussion] Weird behavior of gufuncs

2013-09-05 Thread Jaime Fernández del Río
Hi all, I am seeing some very weird behavior on a gufunc I coded. It has a pretty complicated signature: '(r,c,p),(i,j,k,n),(u,v),(d),(n,q)-(q,r,c)' And a single registered loop function, for types: uint8, uint16, uint16, uintp, uint8-uint8. In general it performs beautifully well, returning

Re: [Numpy-discussion] Indexing changes/deprecations

2013-09-27 Thread Jaime Fernández del Río
On Fri, Sep 27, 2013 at 5:27 AM, Sebastian Berg sebast...@sipsolutions.netwrote: And most importantly, is there any behaviour thing in the index machinery that is bugging you, which I may have forgotten until now? I find this behavior of boolean indexing a little bit annoying: a =

Re: [Numpy-discussion] subsampling arrays without loops

2013-10-03 Thread Jaime Fernández del Río
On Thu, Oct 3, 2013 at 4:05 PM, Moroney, Catherine M (398D) catherine.m.moro...@jpl.nasa.gov wrote: I know I have a lot yet to learn about array striding tricks, so please pardon the triviality of this question. Here is the problem both in words and dumb python: I have a large NxM array

Re: [Numpy-discussion] Efficient square distance computation

2013-10-08 Thread Jaime Fernández del Río
On Tue, Oct 8, 2013 at 4:38 AM, Ke Sun sunk...@gmail.com wrote: On Tue, Oct 08, 2013 at 01:49:14AM -0700, Matthew Brett wrote: Hi, On Tue, Oct 8, 2013 at 1:06 AM, Ke Sun sunk...@gmail.com wrote: Dear all, I have written the following function to compute the square distances of a

[Numpy-discussion] vectorizing recursive sequences

2013-10-25 Thread Jaime Fernández del Río
I recently came up with a way of vectorizing some recursive sequence calculations. While it works, I am afraid it is relying on implementation details potentially subject to change. The basic idea is illustrated by this function, calculating the first n items of the Fibonacci sequence: def

Re: [Numpy-discussion] c api, ndarray creation

2013-11-05 Thread Jaime Fernández del Río
On Tue, Nov 5, 2013 at 10:10 AM, Sergey Petrov qweqwe...@yahoo.com wrote: Rather stupid question here, but I can't figure out by myself: Why does the following c program segfaults? And how can I avoid it? You need to call import_array before using the C-API, see here:

[Numpy-discussion] numpy.lib functions as gufuncs

2013-11-11 Thread Jaime Fernández del Río
Hi, Inspired by the great rewrite of numpy.linalg in 1.8, I've spent the last couple of days coding a couple of the functions in numpy.lib as gufuncs, namely np.interp and np.bincount. I want to do something along the same lines to np.digitize, but haven't started on it just yet. I'm currently

Re: [Numpy-discussion] strange runtimes of numpy fft

2013-11-14 Thread Jaime Fernández del Río
On Thu, Nov 14, 2013 at 9:37 AM, David Cournapeau courn...@gmail.comwrote: You can for example compare np.fft.fft(a) for 2**16 and 2**16+1 (and 2**16-1 that while bad is not prime, so only 1 order of magnitude slower). I actually did... Each step of a FFT basically splits a DFT of size N =

[Numpy-discussion] Using np.partition to extract n largest/smallest items from an array

2013-12-12 Thread Jaime Fernández del Río
With the new np.partition functionality, there is a more efficient, but also less obvious, way of extracting the n largest (or smallest) elements from an array, i.e.: def smallest_n(a, n): return np.sort(np.partition(a, n)[:n]) def argsmallest_n(a, n): ret = np.argpartition(a, n)[:n]

Re: [Numpy-discussion] an indexing question

2014-01-08 Thread Jaime Fernández del Río
On Wed, Jan 8, 2014 at 11:12 AM, Neal Becker ndbeck...@gmail.com wrote: I have a 1d vector d. I want compute the means of subsets of this vector. The subsets are selected by looking at another vector s or same shape as d. This can be done as: [np.mean (d[s == i]) for i in range (size)]

[Numpy-discussion] ENH: add a 'return_counts=' keyword argument to `np.unique`

2014-01-09 Thread Jaime Fernández del Río
Hi, I have just sent a PR, adding a `return_counts` keyword argument to `np.unique` that does exactly what the name suggests: counting the number of times each unique time comes up in the array. It reuses the `flag` array that is constructed whenever any optional index is requested, extracts the

[Numpy-discussion] ENH: Type specific binary search functions for `searchsorted`

2014-01-29 Thread Jaime Fernández del Río
Hi, I have just added a new PR: https://github.com/numpy/numpy/pull/4244 From the commit message: This PR replaces the generic binary search functions used by `searchsorted` with type specific ones for numeric types. This results in a speed-up of calls to `searchsorted` which is highly

Re: [Numpy-discussion] Fast decrementation of indices

2014-02-02 Thread Jaime Fernández del Río
Cannot test right now, but np.unique(b, return_inverse=True)[1].reshape(2, -1) should do what you are after, I think. On Feb 2, 2014 11:58 AM, Mads Ipsen mads.ip...@gmail.com wrote: Hi, I have run into a potential 'for loop' bottleneck. Let me outline: The following array describes bonds

Re: [Numpy-discussion] Proposal: Chaining np.dot with mdot helper function

2014-02-17 Thread Jaime Fernández del Río
Perhaps you could reuse np.dot, by giving its second argument a default None value, and passing a tuple as first argument, i.e. np.dot((a, b, c)) would compute a.dot(b).dot(c), possibly not in that order. As is suggested in the matlab thread linked by Josef, if you do implement an optimal

Re: [Numpy-discussion] New (old) function proposal.

2014-02-18 Thread Jaime Fernández del Río
On Tue, Feb 18, 2014 at 9:03 AM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Feb 18, 2014 at 9:40 AM, Nathaniel Smith n...@pobox.com wrote: On 18 Feb 2014 11:05, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, There is an old ticket, #1499, that suggest

[Numpy-discussion] PR adding an axis argument to np.bincount

2014-02-19 Thread Jaime Fernández del Río
I have just submitted a PR (https://github.com/numpy/numpy/pull/4330) adding an axis argument to bincount. It lets you do things that would have been hard before, but the UI when broadcasting arrays together and having an axis argument can get tricky, and there is no obvious example already in

Re: [Numpy-discussion] How exactly ought 'dot' to work?

2014-02-22 Thread Jaime Fernández del Río
On Feb 22, 2014 2:03 PM, Nathaniel Smith n...@pobox.com wrote: Hi all, Currently numpy's 'dot' acts a bit weird for ndim2 or ndim1. In practice this doesn't usually matter much, because these are very rarely used. But, I would like to nail down the behaviour so we can say something precise

Re: [Numpy-discussion] invert bincounts?

2014-02-27 Thread Jaime Fernández del Río
On Thu, Feb 27, 2014 at 6:11 PM, Alan G Isaac alan.is...@gmail.com wrote: I have a bincount array `cts`. I'd like to produce any one array `a` such that `cts==np.bincounts(a)`. Easy to do in a loop, but does NumPy offer a better (i.e., faster) way? cts = np.bincount([1,1,2,3,4,4,6])

Re: [Numpy-discussion] [RFC] should we argue for a matrix power operator, @@?

2014-03-14 Thread Jaime Fernández del Río
On Fri, Mar 14, 2014 at 9:32 PM, Nathaniel Smith n...@pobox.com wrote: Here are the interesting use cases for @@ that I can think of: - 'vector @@ 2' gives the squared Euclidean length (because it's the same as vector @ vector). Kind of handy. - 'matrix @@ n' of course gives the matrix

Re: [Numpy-discussion] [help needed] associativity and precedence of '@'

2014-03-14 Thread Jaime Fernández del Río
On Fri, Mar 14, 2014 at 9:15 PM, Chris Laumann chris.laum...@gmail.comwrote: Hi all, Let me preface my two cents by saying that I think the best part of @ being accepted is the potential for deprecating the matrix class -- the syntactic beauty of infix for matrix multiply is a nice side

Re: [Numpy-discussion] [help needed] associativity and precedence of '@'

2014-03-17 Thread Jaime Fernández del Río
On Mar 17, 2014 5:54 PM, Nathaniel Smith n...@pobox.com wrote: On Sat, Mar 15, 2014 at 6:28 PM, Nathaniel Smith n...@pobox.com wrote: Mathematica: instead of having an associativity, a @ b @ c gets converted into mdot([a, b, c]) So, I've been thinking about this (thanks to @rfateman for

[Numpy-discussion] PR with changes to triangular array functions

2014-03-18 Thread Jaime Fernández del Río
I submitted a PR that makes some improvements to the numpy functions dealing with triangular arrays. Aside from a general speed-up of about 2x for most functions, there are some minor changes to the public API. In case anyone is concerned about them, here's a list: * 'np.tri' now accepts a

Re: [Numpy-discussion] Is there a pure numpy recipe for this?

2014-03-26 Thread Jaime Fernández del Río
On Wed, Mar 26, 2014 at 1:28 PM, Slaunger slaun...@gmail.com wrote: See if you can make sense of the following. It is a little cryptic, but it works: f_change = np.array([2, 3, 39, 41, 58, 59, 65, 66, 93, 102, 145]) g_change = np.array([2, 94, 101, 146, 149]) N = 150 if len(f_change) % 2 :

Re: [Numpy-discussion] Is there a pure numpy recipe for this?

2014-03-26 Thread Jaime Fernández del Río
On Wed, Mar 26, 2014 at 2:23 PM, Slaunger slaun...@gmail.com wrote: Jaime Fernández del Río wrote You saved my evening! Actually, my head has been spinning about this problem the last three evenings without having been able to nail it down. I had to quit Project Euler about 5 years ago

[Numpy-discussion] Changes to np.vander

2014-03-28 Thread Jaime Fernández del Río
Hi, I have submitted a PR (https://github.com/numpy/numpy/pull/4568) that speeds up `np.vander` by using accumulated multiplication instead of exponentiation to compute the Vandermonde matrix. For largish matrices the speed-ups can be quite dramatic, over an order of magnitude. Julian has raised

Re: [Numpy-discussion] Changes to np.vander

2014-03-29 Thread Jaime Fernández del Río
On Sat, Mar 29, 2014 at 8:55 AM, josef.p...@gmail.com wrote: On Sat, Mar 29, 2014 at 7:31 AM, josef.p...@gmail.com wrote: On Sat, Mar 29, 2014 at 12:12 AM, Jaime Fernández del Río jaime.f...@gmail.com wrote: Hi, I have submitted a PR (https://github.com/numpy/numpy/pull/4568

Re: [Numpy-discussion] repeat an array without allocation

2014-05-05 Thread Jaime Fernández del Río
On Sun, May 4, 2014 at 9:34 PM, srean srean.l...@gmail.com wrote: Hi all, is there an efficient way to do the following without allocating A where A = np.repeat(x, [4, 2, 1, 3], axis=0) c = A.dot(b)# b.shape If x is a 2D array you can call repeat **after** dot, not before, which

Re: [Numpy-discussion] 100 Numpy exercices

2014-05-27 Thread Jaime Fernández del Río
On Tue, May 27, 2014 at 12:27 PM, Nicolas Rougier nicolas.roug...@inria.frwrote: Any other tricky stride_trick tricks ? I promised to put them in the master section. It doesn't use stride_tricks, and seberg doesn't quite like it, but this made the rounds in StackOverflow a couple of years

Re: [Numpy-discussion] Reordering indices

2014-05-30 Thread Jaime Fernández del Río
On Fri, May 30, 2014 at 8:48 AM, Bob Dowling rjd4+nu...@cam.ac.uk wrote: Is there a clean way to create a view on an existing ND-array with its axes in a different order. There's an epidemic of axes reordering, the exact same thing was asked yesterday in StackOverflow:

Re: [Numpy-discussion] ANN: NumPy 1.9.0 beta release

2014-06-09 Thread Jaime Fernández del Río
On Sun, Jun 8, 2014 at 1:43 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Sun, Jun 8, 2014 at 2:34 PM, Julian Taylor jtaylor.deb...@googlemail.com wrote: Hello, I'm happy to announce the fist beta release of Numpy 1.9.0. 1.9.0 will be a new feature release supporting Python

Re: [Numpy-discussion] Bug in np.cross for 2D vectors

2014-07-16 Thread Jaime Fernández del Río
On Tue, Jul 15, 2014 at 2:22 AM, Neil Hodgson hodgson.n...@yahoo.co.uk wrote: Hi, We came across this bug while using np.cross on 3D arrays of 2D vectors. What version of numpy are you using? This should already be solved in numpy master, and be part of the 1.9 release. Here's the relevant

Re: [Numpy-discussion] numpy.mean still broken for large float32 arrays

2014-07-24 Thread Jaime Fernández del Río
On Thu, Jul 24, 2014 at 4:56 AM, Julian Taylor jtaylor.deb...@googlemail.com wrote: In practice one of the better methods is pairwise summation that is pretty much as fast as a naive summation but has an accuracy of O(logN) ulp. This is the method numpy 1.9 will use this method by default (+

Re: [Numpy-discussion] Preliminary thoughts on implementing __matmul__

2014-08-06 Thread Jaime Fernández del Río
On Wed, Aug 6, 2014 at 5:31 AM, Nathaniel Smith n...@pobox.com wrote: I think the other obvious strategy to consider, is defining a 'dot' gufunc, with semantics identical to @. (This would be useful for backcompat as well: adding/dropping compatibility with older python versions would be as

Re: [Numpy-discussion] Proposed new feature for numpy.einsum: repeated output subscripts as diagonal

2014-08-20 Thread Jaime Fernández del Río
On Wed, Aug 20, 2014 at 6:26 AM, Pierre-Andre Noel noel.pierre.an...@gmail.com wrote: Thanks all for the feedback! So there appears to be interest for this feature, and I think that I can implement it. However, it may take a while before I do so: I have other priorities right now. In

Re: [Numpy-discussion] np.unique with structured arrays

2014-08-22 Thread Jaime Fernández del Río
I can confirm, the issue seems to be in sorting: np.sort(V_) array([([0.5, 0.0, 1.0],), ([0.5, 0.0, -1.0],), ([0.5, -0.0, 1.0],), ([0.5, -0.0, -1.0],)], dtype=[('v', 'f4', (3,))]) These I think are handled by the generic sort functions, and it looks like the comparison function

Re: [Numpy-discussion] np.unique with structured arrays

2014-08-22 Thread Jaime Fernández del Río
it over the weekend. Jaime On Fri, Aug 22, 2014 at 7:54 AM, Eelco Hoogendoorn hoogendoorn.ee...@gmail.com wrote: Oh yeah this could be. Floating point equality and bitwise equality are not the same thing. -- From: Jaime Fernández del Río jaime.f...@gmail.com Sent

Re: [Numpy-discussion] Best way to broadcast a function from C

2014-08-22 Thread Jaime Fernández del Río
You can always write your own gufunc with signature '(),(),()-(a, a)', and write a Python wrapper that always call it with an `out=` parameter of shape (..., 3, 3), something along the lines of: def my_wrapper(a, b, c, out=None): if out is None: out =

[Numpy-discussion] Should concatenate broadcast shapes?

2014-08-27 Thread Jaime Fernández del Río
After reading this stackoverflow question: http://stackoverflow.com/questions/25530223/append-a-list-at-the-end-of-each-row-of-2d-array I was reminded that the `np.concatenate` family of functions do not broadcast the shapes of their inputs: import numpy as np a = np.arange(6).reshape(3, 2)

[Numpy-discussion] Does a `mergesorted` function make sense?

2014-08-27 Thread Jaime Fernández del Río
A request was open in github to add a `merge` function to numpy that would merge two sorted 1d arrays into a single sorted 1d array. I have been playing around with that idea for a while, and have a branch in my numpy fork that adds a `mergesorted` function to `numpy.lib`:

Re: [Numpy-discussion] Should concatenate broadcast shapes?

2014-08-27 Thread Jaime Fernández del Río
On Wed, Aug 27, 2014 at 10:01 AM, Robert Kern robert.k...@gmail.com wrote: On Wed, Aug 27, 2014 at 5:44 PM, Jaime Fernández del Río jaime.f...@gmail.com wrote: After reading this stackoverflow question: http://stackoverflow.com/questions/25530223/append-a-list-at-the-end-of-each-row

Re: [Numpy-discussion] Does a `mergesorted` function make sense?

2014-08-27 Thread Jaime Fernández del Río
in this direction, and I feel this draft could really use a bit of back and forth. If we are going to completely rewrite arraysetops, we might as well do it right. On Wed, Aug 27, 2014 at 7:02 PM, Jaime Fernández del Río jaime.f...@gmail.com wrote: A request was open in github to add

Re: [Numpy-discussion] Does a `mergesorted` function make sense?

2014-08-27 Thread Jaime Fernández del Río
. If it isn't, it is more efficient to perform a reduction by means of splitting the array by its groups first, and then map the iterable of groups over some reduction operation (as noted in the docstring of GroupBy.reduce). On Wed, Aug 27, 2014 at 8:29 PM, Jaime Fernández del Río jaime.f

[Numpy-discussion] PR added: frozen dimensions in gufunc signatures

2014-08-28 Thread Jaime Fernández del Río
Hi, I have just sent a PR (https://github.com/numpy/numpy/pull/5015), adding the possibility of having frozen dimensions in gufunc signatures. As a proof of concept, I have added a `cross1d` gufunc to `numpy.core.umath_tests`: In [1]: import numpy as np In [2]: from numpy.core.umath_tests import

Re: [Numpy-discussion] PR added: frozen dimensions in gufunc signatures

2014-08-29 Thread Jaime Fernández del Río
On Thu, Aug 28, 2014 at 5:40 PM, Nathaniel Smith n...@pobox.com wrote: Some thoughts: But, for your computed dimension idea I'm wondering if what we should do instead is just let a gufunc provide a C callback that looks at the input array dimensions and explicitly says somehow which

Re: [Numpy-discussion] Does a `mergesorted` function make sense?

2014-09-02 Thread Jaime Fernández del Río
On Tue, Sep 2, 2014 at 5:40 PM, Charles R Harris charlesr.har...@gmail.com wrote: What do you think about the suggestion of timsort? One would need to concatenate the arrays before sorting, but it should be fairly efficient. Timsort is very cool, and it would definitely be fun to implement

Re: [Numpy-discussion] Does a `mergesorted` function make sense?

2014-09-03 Thread Jaime Fernández del Río
On Wed, Sep 3, 2014 at 6:41 AM, Eelco Hoogendoorn hoogendoorn.ee...@gmail.com wrote: Not sure about the hashing. Indeed one can also build an index of a set by means of a hash table, but its questionable if this leads to improved performance over performing an argsort. Hashing may have

Re: [Numpy-discussion] Does a `mergesorted` function make sense?

2014-09-03 Thread Jaime Fernández del Río
On Wed, Sep 3, 2014 at 9:33 AM, Jaime Fernández del Río jaime.f...@gmail.com wrote: On Wed, Sep 3, 2014 at 6:41 AM, Eelco Hoogendoorn hoogendoorn.ee...@gmail.com wrote: Not sure about the hashing. Indeed one can also build an index of a set by means of a hash table, but its questionable

Re: [Numpy-discussion] Does a `mergesorted` function make sense?

2014-09-03 Thread Jaime Fernández del Río
On Wed, Sep 3, 2014 at 5:26 AM, cjw c...@ncf.ca wrote: These are good issues, that need to be discussed and resolved. Python has the benefit of having a BDFL. Numpy has no similar arrangement. In the post-numarray period, Travis Oliphant took that role and advanced the package in many ways.

Re: [Numpy-discussion] Give Jaime Fernandez commit rights.

2014-09-03 Thread Jaime Fernández del Río
On Wed, Sep 3, 2014 at 5:47 PM, Charles R Harris charlesr.har...@gmail.com wrote: I think the ayes will have it. As I told Chuck (because I now get to call Charles Chuck, right? :-)), I am not sure I am fully qualified for the job: looking at the names on that list is a humbling experience.

Re: [Numpy-discussion] Does a `mergesorted` function make sense?

2014-09-04 Thread Jaime Fernández del Río
On Thu, Sep 4, 2014 at 10:39 AM, Eelco Hoogendoorn hoogendoorn.ee...@gmail.com wrote: On Thu, Sep 4, 2014 at 10:31 AM, Eelco Hoogendoorn hoogendoorn.ee...@gmail.com wrote: On Wed, Sep 3, 2014 at 6:46 PM, Jaime Fernández del Río jaime.f...@gmail.com wrote: On Wed, Sep 3, 2014 at 9:33

Re: [Numpy-discussion] Generalize hstack/vstack -- stack; Block matrices like in matlab

2014-09-08 Thread Jaime Fernández del Río
On Mon, Sep 8, 2014 at 7:41 AM, Sturla Molden sturla.mol...@gmail.com wrote: Stefan Otte stefan.o...@gmail.com wrote: stack([[a, b], [c, d]]) In my case `stack` replaced `hstack` and `vstack` almost completely. If you're interested in including it in numpy I created a pull request

Re: [Numpy-discussion] Is this a bug?

2014-09-16 Thread Jaime Fernández del Río
On Tue, Sep 16, 2014 at 12:27 PM, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, It turns out that gufuncs will broadcast the last dimension if it is one. For instance, inner1d has signature `(n), (n) - ()`, yet In [27]: inner1d([1,1,1], [1]) Out[27]: 3 In [28]:

Re: [Numpy-discussion] Is this a bug?

2014-09-16 Thread Jaime Fernández del Río
On Tue, Sep 16, 2014 at 3:26 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 16, 2014 at 2:51 PM, Nathaniel Smith n...@pobox.com wrote: On Tue, Sep 16, 2014 at 4:31 PM, Jaime Fernández del Río jaime.f...@gmail.com wrote: If it is a bug, it is an extended one, because

Re: [Numpy-discussion] Is this a bug?

2014-09-16 Thread Jaime Fernández del Río
On Tue, Sep 16, 2014 at 4:32 PM, Nathaniel Smith n...@pobox.com wrote: On Tue, Sep 16, 2014 at 6:56 PM, Jaime Fernández del Río jaime.f...@gmail.com wrote: On Tue, Sep 16, 2014 at 3:26 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 16, 2014 at 2:51 PM, Nathaniel Smith

Re: [Numpy-discussion] Is this a bug?

2014-09-16 Thread Jaime Fernández del Río
On Tue, Sep 16, 2014 at 4:32 PM, Nathaniel Smith n...@pobox.com wrote: On Tue, Sep 16, 2014 at 6:56 PM, Jaime Fernández del Río jaime.f...@gmail.com wrote: On Tue, Sep 16, 2014 at 3:26 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 16, 2014 at 2:51 PM, Nathaniel Smith

Re: [Numpy-discussion] Is this a bug?

2014-09-17 Thread Jaime Fernández del Río
On Wed, Sep 17, 2014 at 1:27 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Wed, Sep 17, 2014 at 6:57 AM, Charles R Harris charlesr.har...@gmail.com wrote: On Wed, Sep 17, 2014 at 6:48 AM, Sebastian Berg sebast...@sipsolutions.net wrote: On Mi, 2014-09-17 at 06:33 -0600,

Re: [Numpy-discussion] 0/0 == 0?

2014-10-02 Thread Jaime Fernández del Río
On Thu, Oct 2, 2014 at 4:29 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Thu, Oct 2, 2014 at 5:02 PM, T J tjhn...@gmail.com wrote: Hi, I'm using NumPy 1.8.2: In [1]: np.array(0) / np.array(0) Out[1]: 0 In [2]: np.array(0) / np.array(0.0) Out[2]: nan In [3]: np.array(0.0)

Re: [Numpy-discussion] Request for enhancement to numpy.random.shuffle

2014-10-12 Thread Jaime Fernández del Río
On Sun, Oct 12, 2014 at 9:29 AM, Warren Weckesser warren.weckes...@gmail.com wrote: On Sun, Oct 12, 2014 at 12:14 PM, Warren Weckesser warren.weckes...@gmail.com wrote: On Sat, Oct 11, 2014 at 6:51 PM, Warren Weckesser warren.weckes...@gmail.com wrote: I created an issue on github

Re: [Numpy-discussion] Request for enhancement to numpy.random.shuffle

2014-10-16 Thread Jaime Fernández del Río
On Thu, Oct 16, 2014 at 8:39 AM, Warren Weckesser warren.weckes...@gmail.com wrote: On Sun, Oct 12, 2014 at 9:13 PM, Nathaniel Smith n...@pobox.com wrote: On Sun, Oct 12, 2014 at 5:14 PM, Sebastian se...@sebix.at wrote: On 2014-10-12 16:54, Warren Weckesser wrote: On Sun, Oct 12,

[Numpy-discussion] Passing multiple output arguments to ufunc

2014-10-16 Thread Jaime Fernández del Río
There is an oldish feature request in github (https://github.com/numpy/numpy/issues/4752), complaining about it not being possible to pass multiple output arguments to a ufunc using keyword arguments. You can pass them all as positional arguments: out1 = np.empty(1) out2 = np.empty(1)

Re: [Numpy-discussion] #2522 numpy.diff fails on unsigned integers

2014-11-13 Thread Jaime Fernández del Río
On Wed, Nov 12, 2014 at 11:10 PM, Sebastian se...@sebix.at wrote: On 2014-11-04 19:44, Charles R Harris wrote: On Tue, Nov 4, 2014 at 11:19 AM, Sebastian se...@sebix.at wrote: On 2014-11-04 15:06, Todd wrote: On Tue, Nov 4, 2014 at 2:50 PM, Sebastian Wagner se...@sebix.at

Re: [Numpy-discussion] creation of ndarray with dtype=np.object : bug?

2014-12-03 Thread Jaime Fernández del Río
On Wed, Dec 3, 2014 at 2:21 AM, Emanuele Olivetti emanu...@relativita.com wrote: On 12/03/2014 04:32 AM, Ryan Nelson wrote: Emanuele, This doesn't address your question directly. However, I wonder if you could approach this problem from a different way to get what you want. First of

Re: [Numpy-discussion] Uint64 casting bug for MSVC builds

2014-12-03 Thread Jaime Fernández del Río
On Wed, Dec 3, 2014 at 8:44 AM, Matthew Brett matthew.br...@gmail.com wrote: Hi, I just noticed this using Christophe Gohlke's MKL builds of numpy: import numpy as np val = 2**63 + 2**62 np.float64(val) 1.3835058055282164e+19 np.float64(val).astype(np.uint64) 9223372036854775808 I

Re: [Numpy-discussion] slicing an n-dimensional array

2014-12-03 Thread Jaime Fernández del Río
On Wed, Dec 3, 2014 at 4:02 PM, Stefan van der Walt ste...@sun.ac.za wrote: Hi Catherine On 2014-12-04 01:12:30, Moroney, Catherine M (398E) catherine.m.moro...@jpl.nasa.gov wrote: I have an array A of shape (NX, NY, NZ), and then I have a second array B of shape (NX, NY) that ranges

Re: [Numpy-discussion] Add a function to broadcast arrays to a given shape to numpy's stride_tricks?

2014-12-12 Thread Jaime Fernández del Río
On Thu, Dec 11, 2014 at 10:53 AM, Stephan Hoyer sho...@gmail.com wrote: On Thu, Dec 11, 2014 at 8:17 AM, Sebastian Berg sebast...@sipsolutions.net wrote: One option would also be to have something like: np.common_shape(*arrays) np.broadcast_to(array, shape) # (though I would like many

Re: [Numpy-discussion] Add a function to broadcast arrays to a given shape to numpy's stride_tricks?

2014-12-12 Thread Jaime Fernández del Río
On Fri, Dec 12, 2014 at 5:57 AM, Sebastian Berg sebast...@sipsolutions.net wrote: On Fr, 2014-12-12 at 05:48 -0800, Jaime Fernández del Río wrote: On Thu, Dec 11, 2014 at 10:53 AM, Stephan Hoyer sho...@gmail.com wrote: On Thu, Dec 11, 2014 at 8:17 AM, Sebastian Berg

Re: [Numpy-discussion] Add a function to broadcast arrays to a given shape to numpy's stride_tricks?

2014-12-12 Thread Jaime Fernández del Río
On Fri, Dec 12, 2014 at 11:28 AM, Stephan Hoyer sho...@gmail.com wrote: On Fri, Dec 12, 2014 at 5:48 AM, Jaime Fernández del Río jaime.f...@gmail.com wrote: np.broadcast is the Python object of the old iterator. It may be a better idea to write all of these functions using the new one

Re: [Numpy-discussion] Extracting required indices from the array of tuples

2015-01-02 Thread Jaime Fernández del Río
On Fri, Jan 2, 2015 at 3:06 AM, Simen Langseth simlan...@gmail.com wrote: import numpy as np from scipy import signal y = np.array([[2, 1, 2, 3, 2, 0, 1, 0], [2, 1, 2, 3, 2, 0, 1, 0]]) maximas = signal.argrelmax(y, axis=1) print maximas (array([0, 0, 1, 1], dtype=int64),

Re: [Numpy-discussion] Any interest in a 'heaviside' ufunc?

2015-02-03 Thread Jaime Fernández del Río
On Tue, Feb 3, 2015 at 12:58 PM, Warren Weckesser warren.weckes...@gmail.com wrote: I have an implementation of the Heaviside function as numpy ufunc. Is there any interest in adding this to numpy? The function is simply: 0if x 0 heaviside(x) = 0.5 if x == 0

Re: [Numpy-discussion] Views of a different dtype

2015-02-03 Thread Jaime Fernández del Río
On Tue, Feb 3, 2015 at 1:28 AM, Sebastian Berg sebast...@sipsolutions.net wrote: On Mo, 2015-02-02 at 06:25 -0800, Jaime Fernández del Río wrote: On Sat, Jan 31, 2015 at 1:17 AM, Sebastian Berg sebast...@sipsolutions.net wrote: On Fr, 2015-01-30 at 19:52 -0800, Jaime Fernández del

Re: [Numpy-discussion] Views of a different dtype

2015-02-04 Thread Jaime Fernández del Río
On Tue, Feb 3, 2015 at 1:52 PM, Ian Henriksen insertinterestingnameh...@gmail.com wrote: On Tue Feb 03 2015 at 1:47:34 PM Jaime Fernández del Río jaime.f...@gmail.com wrote: On Tue, Feb 3, 2015 at 8:59 AM, Sebastian Berg sebast...@sipsolutions.net wrote: On Di, 2015-02-03 at 07:18 -0800

Re: [Numpy-discussion] New function: np.stack?

2015-02-05 Thread Jaime Fernández del Río
On Thu, Feb 5, 2015 at 11:10 AM, Benjamin Root ben.r...@ou.edu wrote: +1! I could never keep straight which stack function I needed anyway. Wasn't there a proposal a while back for a more generic stacker, like tetrix or something that allowed one to piece together tiles of different sizes?

Re: [Numpy-discussion] Views of a different dtype

2015-02-03 Thread Jaime Fernández del Río
On Tue, Feb 3, 2015 at 8:59 AM, Sebastian Berg sebast...@sipsolutions.net wrote: On Di, 2015-02-03 at 07:18 -0800, Jaime Fernández del Río wrote: snip Do you have a concrete example of what a non (1, 1) array that fails with relaxed strides would look like? If we used

[Numpy-discussion] Sorting refactor

2015-01-15 Thread Jaime Fernández del Río
Hi all, I have been taking a deep look at the sorting functionality in numpy, and I think it could use a face lift in the form of a big code refactor, to get rid of some of the ugliness in the code and make it easier to maintain. What I have in mind basically amounts to: 1. Refactor

Re: [Numpy-discussion] Sorting refactor

2015-01-16 Thread Jaime Fernández del Río
On Fri, Jan 16, 2015 at 4:19 AM, Matthew Brett matthew.br...@gmail.com wrote: Hi, On Fri, Jan 16, 2015 at 5:24 AM, Jaime Fernández del Río jaime.f...@gmail.com wrote: Hi all, I have been taking a deep look at the sorting functionality in numpy, and I think it could use a face lift

Re: [Numpy-discussion] Sorting refactor

2015-01-16 Thread Jaime Fernández del Río
On Fri, Jan 16, 2015 at 8:15 AM, Charles R Harris charlesr.har...@gmail.com wrote: On Fri, Jan 16, 2015 at 7:11 AM, Jaime Fernández del Río jaime.f...@gmail.com wrote: On Fri, Jan 16, 2015 at 3:33 AM, Lars Buitinck larsm...@gmail.com wrote: 2015-01-16 11:55 GMT+01:00 numpy-discussion

Re: [Numpy-discussion] Float view of complex array

2015-01-27 Thread Jaime Fernández del Río
On Mon, Jan 26, 2015 at 10:28 PM, Jens Jørgen Mortensen je...@fysik.dtu.dk wrote: On 01/26/2015 11:02 AM, Jaime Fernández del Río wrote: On Mon, Jan 26, 2015 at 1:41 AM, Sebastian Berg sebast...@sipsolutions.net mailto:sebast...@sipsolutions.net wrote: On Mo, 2015-01-26 at 09:24

[Numpy-discussion] Views of a different dtype

2015-01-28 Thread Jaime Fernández del Río
HI all, There has been some recent discussion going on on the limitations that numpy imposes to taking views of an array with a different dtype. As of right now, you can basically only take a view of an array if it has no Python objects and neither the old nor the new dtype are structured.

Re: [Numpy-discussion] Views of a different dtype

2015-01-30 Thread Jaime Fernández del Río
On Thu, Jan 29, 2015 at 8:57 AM, Nathaniel Smith n...@pobox.com wrote: On Thu, Jan 29, 2015 at 12:56 AM, Jaime Fernández del Río jaime.f...@gmail.com wrote: [...] With all these in mind, my proposal for the new behavior is that taking a view of an array with a different dtype would require

[Numpy-discussion] linspace handling of extra return

2015-01-13 Thread Jaime Fernández del Río
While working on something else, I realized that linspace is not handling requests for returning the sampling spacing consistently: np.linspace(0, 1, 3, retstep=True) (array([ 0. , 0.5, 1. ]), 0.5) np.linspace(0, 1, 1, retstep=True) array([ 0.]) np.linspace(0, 1, 0, retstep=True) array([],

Re: [Numpy-discussion] Matrix Class

2015-02-14 Thread Jaime Fernández del Río
On Sat, Feb 14, 2015 at 5:21 PM, josef.p...@gmail.com wrote: On Sat, Feb 14, 2015 at 4:27 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Sat, Feb 14, 2015 at 12:36 PM, josef.p...@gmail.com wrote: On Sat, Feb 14, 2015 at 12:05 PM, cjw c...@ncf.ca wrote: On 14-Feb-15

Re: [Numpy-discussion] Rewrite np.histogram in c?

2015-03-16 Thread Jaime Fernández del Río
On Sun, Mar 15, 2015 at 11:06 PM, Robert McGibbon rmcgi...@gmail.com wrote: It might make sense to dispatch to difference c implements if the bins are equally spaced (as created by using an integer for the np.histogram bins argument), vs. non-equally-spaced bins. Dispatching to a different

Re: [Numpy-discussion] Rewrite np.histogram in c?

2015-03-16 Thread Jaime Fernández del Río
On Mon, Mar 16, 2015 at 9:28 AM, Jerome Kieffer jerome.kief...@esrf.fr wrote: On Mon, 16 Mar 2015 06:56:58 -0700 Jaime Fernández del Río jaime.f...@gmail.com wrote: Dispatching to a different method seems like a no brainer indeed. The question is whether we really need to do this in C. I

Re: [Numpy-discussion] Rewrite np.histogram in c?

2015-03-16 Thread Jaime Fernández del Río
On Sun, Mar 15, 2015 at 9:32 PM, Robert McGibbon rmcgi...@gmail.com wrote: Hi, Numpy.histogram is implemented in python, and is a little sluggish. This has been discussed previously on the mailing list, [1, 2]. It came up in a project that I maintain, where a new feature is bottlenecked by

Re: [Numpy-discussion] numpy array casting ruled not safe

2015-03-07 Thread Jaime Fernández del Río
On Sat, Mar 7, 2015 at 1:52 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Sat, Mar 7, 2015 at 2:45 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Sat, Mar 7, 2015 at 2:02 PM, Dinesh Vadhia dineshbvad...@hotmail.com wrote: This was originally posted on SO (

Re: [Numpy-discussion] Numpy 1.10

2015-03-13 Thread Jaime Fernández del Río
On Thu, Mar 12, 2015 at 10:16 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Sun, Mar 8, 2015 at 3:43 PM, Ralf Gommers ralf.gomm...@gmail.com wrote: On Sat, Mar 7, 2015 at 12:40 AM, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, Time to start thinking about

  1   2   >