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

2016-01-09 Thread Stefan Otte
it's tested Cons: - the implementation is not super efficient. Temporary copies are created. However, bmat also does that. Feedback is very welcome! Best, Stefan On Sun, May 10, 2015 at 12:33 PM, Stefan Otte wrote: > Hey, > > Just a quick update. I updated the pull request and rena

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-14 Thread Stefan Otte
Hey, I just created a pull request: https://github.com/numpy/numpy/pull/5874 Best, Stefan On Tue, May 12, 2015 at 3:29 PM Stefan Otte wrote: > Hey, > > here is an ipython notebook with benchmarks of all implementations (scroll > to the bottom for plots): > > https:

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-12 Thread Stefan Otte
ández del Río < jaime.f...@gmail.com> wrote: > On Tue, May 12, 2015 at 1:17 AM, Stefan Otte > wrote: > >> Hello, >> >> indeed I was looking for the cartesian product. >> >> I timed the two stackoverflow answers and the winner is not quite as >

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-12 Thread Stefan Otte
Hello, indeed I was looking for the cartesian product. I timed the two stackoverflow answers and the winner is not quite as clear: n_elements:10 cartesian 0.00427 cartesian2 0.00172 n_elements: 100 cartesian 0.02758 cartesian2 0.01044 n_elements: 1000 cartesian 0.97628 cartesian2

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-10 Thread Stefan Otte
I just drafted different versions of the `gridspace` function: https://tmp23.tmpnb.org/user/1waoqQ8PJBJ7/notebooks/2015-05%20gridspace.ipynb Beste Grüße, Stefan On Sun, May 10, 2015 at 1:40 PM, Stefan Otte wrote: > Hey, > > quite often I want to evaluate a function on a grid in a

[Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-10 Thread Stefan Otte
Hey, quite often I want to evaluate a function on a grid in a n-D space. What I end up doing (and what I really dislike) looks something like this: x = np.linspace(0, 5, 20) M1, M2 = np.meshgrid(x, x) X = np.column_stack([M1.flatten(), M2.flatten()]) X.shape # (400, 2) fancy_function(

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

2015-05-10 Thread Stefan Otte
at 2:13 PM Stefan Otte wrote: > To make the last point more concrete the implementation could look > something like this (note that I didn't test it and that it still > takes some work): > > > def bmat(obj, ldict=None, gdict=None): > return matrix(stack(obj, ldict, gdi

Re: [Numpy-discussion] numpy.stack -- which function, if any, deserves the name?

2015-03-16 Thread Stefan Otte
Hey, > 1. np.stack for stacking like np.asarray(np.bmat(...)) > http://thread.gmane.org/gmane.comp.python.numeric.general/58748/ > https://github.com/numpy/numpy/pull/5057 I'm the author of this proposal. I'll just give some context real quickly. "My stack" started really simple, basically allow

[Numpy-discussion] Subscribing to mailinglist not possible / sites down

2014-11-12 Thread Stefan Otte
Hey *, The websites to subscribe to the numpy/scipy mailinglists seem to be down: - http://mail.scipy.org/mailman/listinfo/scipy-user - http://mail.scipy.org/mailman/listinfo/scipy-user - http://projects.scipy.org/pipermail/scipy-dev/ And it's not just me: http://www.downforeveryoneorjustme.com

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

2014-10-31 Thread Stefan Otte
else: arr_rows.append(concatenate(row, axis=-1)) return concatenate(arr_rows, axis=0) if isinstance(obj, N.ndarray): return obj I basically turned the old `bmat` into `stack` and removed the matrix calls. Best, Stefan On Wed, Oct 29, 2014 at 3:59 PM, Stefan

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

2014-10-29 Thread Stefan Otte
and the feature to specify a string representation of the block matrix is nice. Best, Stefan On Tue, Oct 28, 2014 at 7:46 PM, Nathaniel Smith wrote: > On 28 Oct 2014 18:34, "Stefan Otte" wrote: >> >> Hey, >> >> In the last weeks I tested `np.asarray(np.bmat

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

2014-10-28 Thread Stefan Otte
ested calls to a stacking function. >>> >>> However, some form of nd-stack function would be neat in my opinion. >>> >>> On Mon, Sep 8, 2014 at 6:10 PM, Jaime Fernández del Río >>> wrote: >>>> >>>> On Mon, Sep 8, 2014 at 7:41 AM, Sturla

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

2014-09-09 Thread Stefan Otte
r implementing `stack`? More code leads to more bugs and maintenance work. Best, Stefan On Tue, Sep 9, 2014 at 12:14 AM, cjw wrote: > > On 08-Sep-14 4:40 PM, Joseph Martinot-Lagarde wrote: >> Le 08/09/2014 15:29, Stefan Otte a écrit : >>> Hey, >>> >>&

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

2014-09-08 Thread Stefan Otte
Hey, quite often I work with block matrices. Matlab offers the convenient notation [ a b; c d ] to stack matrices. The numpy equivalent is kinda clumsy: vstack([hstack([a,b]), hstack([c,d])]) I wrote the little function `stack` that does exactly that: stack([[a, b], [c, d]]) In my ca

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

2014-02-24 Thread Stefan Otte
nd print out a numpy expression. It's kinda handy but do we actually need it? Beste Grüße, Stefan On Thu, Feb 20, 2014 at 8:39 PM, Nathaniel Smith wrote: > On Thu, Feb 20, 2014 at 1:35 PM, Stefan Otte wrote: >> Hey guys, >> >> I quickly hacked together a prototype o

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

2014-02-20 Thread Stefan Otte
lco Hoogendoorn >> wrote: >>> >>> If the standard semantics are not affected, and the most common >>> two-argument scenario does not take more than a single if-statement >>> overhead, I don't see why it couldn't be a replacement for the existing >&

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

2014-02-20 Thread Stefan Otte
Hey, so I propose the following. I'll implement a new function `mdot`. Incorporating the changes in `dot` are unlikely. Later, one can still include the features in `dot` if desired. `mdot` will have a default parameter `optimize`. If `optimize==True` the reordering of the multiplication is don

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

2014-02-18 Thread Stefan Otte
Mon, Feb 17, 2014 at 4:57 PM, wrote: >> On Mon, Feb 17, 2014 at 4:39 PM, Stefan Otte wrote: >>> Hey guys, >>> >>> I wrote myself a little helper function `mdot` which chains np.dot for >>> multiple arrays. So I can write >>> >>> m

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

2014-02-17 Thread Stefan Otte
Hey guys, I wrote myself a little helper function `mdot` which chains np.dot for multiple arrays. So I can write mdot(A, B, C, D, E) instead of these A.dot(B).dot(C).dot(D).dot(E) np.dot(np.dot(np.dot(np.dot(A, B), C), D), E) I know you can use `numpy.matrix` to get nicer formulas.