Re: [Numpy-discussion] From Python to Numpy

2016-12-31 Thread Nicolas P. Rougier
roduction about readability vs speed with an example showing a clever optimization (by Jaime Fernández del Río) that is hardly readable for the non-experts (including myself). Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.

Re: [Numpy-discussion] From Python to Numpy

2016-12-30 Thread Nicolas P. Rougier
> On 30 Dec 2016, at 20:36, Alex Rogozhnikov wrote: > > Hi Nicolas, > that's a very nice work! > >> Comments/questions/fixes/ideas are of course welcome. > > Boids example brought my attention too, some comments on it: > - I find using complex numbers here

Re: [Numpy-discussion] Casting to np.byte before clearing values

2016-12-27 Thread Nicolas P. Rougier
Yes, clearing is not the proper word but the "trick" works only work for 0 (I'll get the same result in both cases). Nicolas > On 27 Dec 2016, at 20:52, Chris Barker wrote: > > On Mon, Dec 26, 2016 at 1:34 AM, Nicolas P. Rougier > wrote: > > I'm try

Re: [Numpy-discussion] Casting to np.byte before clearing values

2016-12-26 Thread Nicolas P. Rougier
Thanks for the explanation Sebastian, makes sense. Nicolas > On 26 Dec 2016, at 11:48, Sebastian Berg wrote: > > On Mo, 2016-12-26 at 10:34 +0100, Nicolas P. Rougier wrote: >> Hi all, >> >> >> I'm trying to understand why viewing an array as by

[Numpy-discussion] Casting to np.byte before clearing values

2016-12-26 Thread Nicolas P. Rougier
) %timeit Z_float[...] = 0 1000 loops, best of 3: 361 µs per loop %timeit Z_int[...] = 0 1000 loops, best of 3: 366 µs per loop %timeit Z_float.view(np.byte)[...] = 0 1000 loops, best of 3: 267 µs per loop %timeit Z_int.view(np.byte)[...] = 0 1000 loops, best of 3: 266 µs per loop

[Numpy-discussion] From Python to Numpy

2016-12-22 Thread Nicolas P. Rougier
happy with the boids example that show a nice combination of numpy and matplotlib strengths. Book is online at: http://www.labri.fr/perso/nrougier/from-python-to-numpy/ Sources are available at: https://github.com/rougier/from-python-to-numpy Comments/questions/fixes/ideas are of cours

[Numpy-discussion] Useless but tricky exercise

2016-11-03 Thread Nicolas P. Rougier
;B[%s]" % index))) True ``` I wrote a solution at https://gist.github.com/rougier/b8c2256434b3a4a4271260cd4cc6cbc7 (not very thoroughly tested) but maybe there are better ways to do that (like a magic numpy call ?) (no use-case at all, only for

[Numpy-discussion] 100 Numpy exercises complete !

2016-07-15 Thread Nicolas P. Rougier
(I'm still fighting to fix exercise #54 that does not work as expected). Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] 100 numpy exercises (80/100)

2016-03-08 Thread Nicolas P. Rougier
Hi all, I've just added some exercises to the collection at https://github.com/rougier/numpy-100 (and in the process, I've discovered np.argpartition... nice!) If you have some ideas/comments/corrections... Still 20 to go... Nicolas ___

Re: [Numpy-discussion] How to find indices of values in an array (indirect in1d) ?

2015-12-30 Thread Nicolas P. Rougier
In the end, I’ve only the list comprehension to work as expected A = [0,0,1,3] B = np.arange(8) np.random.shuffle(B) I = [list(B).index(item) for item in A if item in B] But Mark's and Sebastian's methods do not seem to work... > On 30 Dec 2015, at 19:51, Nicolas P. R

Re: [Numpy-discussion] How to find indices of values in an array (indirect in1d) ?

2015-12-30 Thread Nicolas P. Rougier
gt;> numpy.where(numpy.in1d(b, a)) > (array([1, 2, 5, 7], dtype=int64),) > It would be interesting to see the benchmarks. > > > On Wed, Dec 30, 2015 at 10:17 AM, Nicolas P. Rougier > wrote: > > Yes, it is the expected result. Thanks. > Maybe the set(a) & set(b) can

Re: [Numpy-discussion] How to find indices of values in an array (indirect in1d) ?

2015-12-30 Thread Nicolas P. Rougier
ices #indices of b where the elements of a in b occur > array([1, 2, 5, 7], dtype=int64) > > -Mark > > > On Wed, Dec 30, 2015 at 6:45 AM, Nicolas P. Rougier > wrote: > > I’m scratching my head around a small problem but I can’t find a vectorized > solution. >

Re: [Numpy-discussion] How to find indices of values in an array (indirect in1d) ?

2015-12-30 Thread Nicolas P. Rougier
Thanks, I will make some benchmark and post results. > On 30 Dec 2015, at 17:47, Sebastian Berg wrote: > > On Mi, 2015-12-30 at 17:12 +0100, Nicolas P. Rougier wrote: >> Thanks for the quick answers. I think I will go with the .index and >> list comprehension. >>

Re: [Numpy-discussion] How to find indices of values in an array (indirect in1d) ?

2015-12-30 Thread Nicolas P. Rougier
Thanks for the quick answers. I think I will go with the .index and list comprehension. But if someone finds with a vectorised solution for the numpy 100 exercises... Nicolas > On 30 Dec 2015, at 16:31, Benjamin Root wrote: > > Maybe use searchsorted()? I will note that I have nee

[Numpy-discussion] How to find indices of values in an array (indirect in1d) ?

2015-12-30 Thread Nicolas P. Rougier
nction(A,B)) [1,2,0] # A[0] == 2 is in B and 2 == B[1] -> 1 # A[1] == 0 is in B and 0 == B[2] -> 2 # A[2] == 1 is in B and 1 == B[0] -> 0 Any idea ? I tried numpy.in1d with no luck. Nicolas ___ NumPy-Discussion mailing list NumPy-Discuss

Re: [Numpy-discussion] Dynamic array list implementation

2015-12-30 Thread Nicolas P. Rougier
> On 28 Dec 2015, at 19:58, Chris Barker wrote: > > On Wed, Dec 23, 2015 at 4:01 AM, Nicolas P. Rougier > wrote: > But my implementation is quite slow, especially when you add one item at a > time: > > >>> python benchmark.py > Python list, append 10

Re: [Numpy-discussion] Dynamic array list implementation

2015-12-23 Thread Nicolas P. Rougier
= ArrayList( np.arange(10), [3,3,4]) > >>> print(L) > [[0 1 2], [3 4 5], [6 7 8 9]] > >>> print(L.data) > [0 1 2 3 4 5 6 7 8 9] > > > does an ArrayList act like a numpy array in other ways: > > L * 5 > > L* some_array > > in which case, how does it

Re: [Numpy-discussion] Dynamic array list implementation

2015-12-22 Thread Nicolas P. Rougier
Yes, you can append/insert/remove items. It works pretty much like a python list in fact (but with a single data type for all elements). Nicolas > On 22 Dec 2015, at 20:19, Chris Barker wrote: > > sorry for being so lazy as to not go look at the project pages, but > > T

[Numpy-discussion] Dynamic array list implementation

2015-12-22 Thread Nicolas P. Rougier
I've coded a typed dynamic list based on numpy array (needed for the glumpy project). Code is available from https://github.com/rougier/numpy-list A Numpy array list is a strongly typed list whose type can be anything that can be interpreted as a numpy data type. >>> L = ArrayList( [[0], [1,2

[Numpy-discussion] Numpy 100 exercices

2015-08-16 Thread Nicolas P. Rougier
t;only" 60 exercices... So, if you remember a nice question that has been answered on this list (or elsewhere)... Or you can also make a PR on github. Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman

[Numpy-discussion] EuroScipy 2015: Extended deadline (15/05/2015)

2015-05-01 Thread Nicolas P. Rougier
Extended deadline: 15th May 2015 EuroScipy 2015, the annual conference on Python in science will take place in Cambridge, UK on 26-30 August 2015. The conference features two days of tutorials followed by two days of scientific talk

[Numpy-discussion] EuroScipy 2015: Submission deadline in 3 days !!!

2015-04-27 Thread Nicolas P. Rougier
- Submission deadline in 3 days !!! - EuroScipy 2015, the annual conference on Python in science will take place in Cambridge, UK on 26-30 August 2015. The conference features two days of tutorials followed by two days of scientific t

[Numpy-discussion] EuroScipy 2015 : Call for talks, posters and tutorials [Reminder]

2015-04-17 Thread Nicolas P. Rougier
[Apology for cross-posting] Dear all, EuroScipy 2015, the annual conference on Python in science will take place in Cambridge, UK on 26-30 August 2015. The conference features two days of tutorials followed by two days of scientific talks & posters and an extra day dedicated to developer spri

[Numpy-discussion] EuroScipy 2015: Call for talks, posters & tutorials

2015-03-24 Thread Nicolas P. Rougier
Dear all, EuroScipy 2015, the annual conference on Python in science will take place in Cambridge, UK on 26-30 August 2015. The conference features two days of tutorials followed by two days of scientific talks & posters and an extra day dedicated to developer sprints. It is the major event in

Re: [Numpy-discussion] Bilinear interpolation (numpy only)

2014-12-14 Thread Nicolas P. Rougier
Thanks Jérôme, I will look into your code. Having other filter might be useful for my case. While looking for code, I've also found this (pure python) implementation: http://stackoverflow.com/questions/12729228/simple-efficient-bilinear-interpolation-of-images-in-numpy-and-python Ni

[Numpy-discussion] Bilinear interpolation (numpy only)

2014-12-13 Thread Nicolas P. Rougier
ke to avoid the scipy dependency) Thanks. Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] np.unique with structured arrays

2014-08-22 Thread Nicolas P. Rougier
Hello, I've found a strange behavior or I'm missing something obvious (or np.unique is not supposed to work with structured arrays). I'm trying to extract unique values from a simple structured array but it does not seem to work as expected. Here is a minimal script showing the problem: impor

Re: [Numpy-discussion] Inverted indices

2014-08-07 Thread Nicolas P. Rougier
Nicolas On 07 Aug 2014, at 14:04, Gregor Thalhammer wrote: > > Am 07.08.2014 um 13:59 schrieb Gregor Thalhammer > : > >> >> Am 07.08.2014 um 13:16 schrieb Nicolas P. Rougier : >> >>> >>> Hi, >>> >>> I've a small prob

Re: [Numpy-discussion] Inverted indices

2014-08-07 Thread Nicolas P. Rougier
Nice ! Thanks Stéfan. I will add it to the numpy 100 problems. Nicolas On 07 Aug 2014, at 13:31, Stéfan van der Walt wrote: > Hi Nicolas > > On Thu, Aug 7, 2014 at 1:16 PM, Nicolas P. Rougier > wrote: >> Here is a small example: >> >> Z = [(0,0), (1,1), (

[Numpy-discussion] Inverted indices

2014-08-07 Thread Nicolas P. Rougier
t; Wrong (15 not in I) but ideally, I would like this to be converted to [(0,0), (0,0)] Any idea ? Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Find n closest values

2014-06-22 Thread Nicolas P. Rougier
vector graphics module in there would make it even better. Would > be nice if those projects could be merged. > I'm part of vispy actually, those are side experiments for this project. Nicolas > > On Sun, Jun 22, 2014 at 9:51 PM, Nicolas P. Rougier > wrote: > >

Re: [Numpy-discussion] Find n closest values

2014-06-22 Thread Nicolas P. Rougier
is able to draw any amiunt of grids/ticks (as in matplotlib). Some old example are available from here: https://github.com/rougier/gl-agg I tested your solution and it is faster by only a tiny amount but the way you wrote it might open the door for other improvements. Thanks. Nicolas On 22 Ju

Re: [Numpy-discussion] Find n closest values

2014-06-22 Thread Nicolas P. Rougier
Thanks, I'll try your solution. Data (L) is not so big actually, it represents pixels on screen and (I) represents line position (for grids). I need to compute this quantity everytime the user zoom in or out. Nicolas On 22 Jun 2014, at 19:05, Eelco Hoogendoorn wrote: > Well

[Numpy-discussion] 100 numpy exercises, now in Julia

2014-06-22 Thread Nicolas P. Rougier
Hi all, Michiaki Ariga has started conversion of 100 numpy exercises in Julia. I know this might be a bit off-topic but I thought it was interesting enough. Github repository is at https://github.com/chezou/julia-100-exercises Nicolas ___ NumPy

Re: [Numpy-discussion] Find n closest values

2014-06-22 Thread Nicolas P. Rougier
Thanks for the answer. I was secretly hoping for some kind of hardly-known numpy function that would make things faster auto-magically... Nicolas On 22 Jun 2014, at 10:30, Eelco Hoogendoorn wrote: > Perhaps you could simplify some statements, but at least the algorithmic > complex

[Numpy-discussion] Find n closest values

2014-06-22 Thread Nicolas P. Rougier
[0,width] I = np.sort(np.random.randint(0,width,10)) # n regular spaced values in [0,width] L = np.linspace(0, width, n) print I[find_closest(I,L)] Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/

Re: [Numpy-discussion] 100 Numpy exercices

2014-05-29 Thread Nicolas P. Rougier
: > > http://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array/16973510#16973510 > > It may not work properly on floats, but I think it is a very cool use of > dtypes. Then again I'm obviously biased... > > I remained astonished when I discovere

Re: [Numpy-discussion] 100 Numpy exercices

2014-05-29 Thread Nicolas P. Rougier
Hi Valentin, Thanks for reminded me about this great tool. I intended to use it after I get all 100 exercises but it really helps track errors quickly. I will now use it to keep a notebook up to date with each commit . Nicolas On 28 May 2014, at 23:46, Valentin Haenel wrote: > Hi Nico

Re: [Numpy-discussion] 100 Numpy exercices

2014-05-27 Thread Nicolas Rougier
Thanks, you just inaugurated the master section. Nicolas On 27 May 2014, at 21:48, Jaime Fernández del Río wrote: > On Tue, May 27, 2014 at 12:27 PM, Nicolas Rougier > wrote: > Any other tricky stride_trick tricks ? I promised to put them in the master > section. > >

Re: [Numpy-discussion] 100 Numpy exercices

2014-05-27 Thread Nicolas Rougier
On 27 May 2014, at 21:09, Chris Barker wrote: > On Mon, May 26, 2014 at 9:57 PM, Nicolas Rougier > wrote: > > I've updated the numpy exercices collection and made it available on github > at: > > https://github.com/rougier/numpy-100 > > > very usefu

[Numpy-discussion] 100 Numpy exercices

2014-05-26 Thread Nicolas Rougier
. The master and archmaster sections still need to be populated... Once finished, I'll make an ipython notebook as well. Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] python array

2014-03-13 Thread Nicolas Rougier
Seems to be related to the masked values: print r2010[:3,:3] [[-- -- --] [-- -- --] [-- -- --]] print abs(r2010)[:3,:3] [[-- -- --] [-- -- --] [-- -- --]] print r2010[ r2010[:3,:3] <0 ] [-- -- -- -- -- -- -- -- --] print r2010[ abs(r2010)[:3,:3] < 0] [] Nicolas On 13 Mar 2014,

Re: [Numpy-discussion] dtype promotion

2014-03-03 Thread Nicolas Rougier
I never noticed this kind of cast before (1.8.0), it's just a bit surprising. It was convenient to write translations (for a bunch of points) such as: Z = np.ones((n,2),dtype=np.float32) + (300,300) but I can live with Z += 300,300 Nicolas On 03 Mar 2014, at 23:02, Benjamin Root

[Numpy-discussion] dtype promotion

2014-03-03 Thread Nicolas Rougier
; print Z.dtype float64 Is this the expected behavior ? What it the difference between the two lines ? Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] Bug in resize of structured array (with initial size = 0)

2014-01-10 Thread Nicolas Rougier
Hi, I've tried to resize a record array that was first empty (on purpose, I need it) and I got the following error (while it's working for regular array). Traceback (most recent call last): File "test_resize.py", line 10, in print np.resize(V,2) File "/usr/locaL/Cellar/python/2.7.6/Fr

[Numpy-discussion] ArrayList object

2014-01-04 Thread Nicolas Rougier
core numpy (np.list ?) ? Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Structured array dtype

2013-08-31 Thread Nicolas Rougier
((10,4), np.float32) Z.strides (16,4) Z = np.zeros(10, (np.float32,4)) Z.strides (16,4) Nicolas On Aug 31, 2013, at 7:51 AM, Stéfan van der Walt wrote: > Hi Nicolas > > On Fri, 30 Aug 2013 17:26:51 +0200, Nicolas Rougier wrote: >>>>> Z = np.zeros(10, [('a

[Numpy-discussion] Structured array dtype

2013-08-30 Thread Nicolas Rougier
Hi, I'm a bit lost with the following example (numpy 1.7.1, osx 10.8): >>> Z = np.zeros(10, [('a', np.float32, 3), ('b', np.float32, 4)]) >>> Z['a'].dtype dtype('float32') >>> Z.dtype['a'] dtype(('

[Numpy-discussion] Using as_strided to avoid copy on repeat (with 2-dimensional array)

2013-08-12 Thread Nicolas Rougier
(10,2) B = np.repeat( A[::2], 2, axis=0 ) Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] multivariate_normal issue with 'size' argument

2013-05-24 Thread Nicolas Rougier
.int64(1)) [[ 0.40274243 -0.33922682]] Nicolas On May 24, 2013, at 2:02 PM, Emanuele Olivetti wrote: > import numpy as np > print np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), size=1) > print np.random.multivariate_normal(mean=n

Re: [Numpy-discussion] np.dot and 'out' bug

2013-05-23 Thread Nicolas Rougier
> Can you file a bug in the bug tracker so this won't get lost? Done. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] np.dot and 'out' bug

2013-05-23 Thread Nicolas Rougier
;out=a' or out=b' since nothing in the 'dot' documentation warned me about such problem. Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] np.dot and 'out' bug

2013-05-23 Thread Nicolas Rougier
yone confirm this behavior ? (tested using numpy 1.7.1) Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Possible conversion bug with record array

2013-05-22 Thread Nicolas Rougier
Thanks, I filed a new issue on the bug tracker. Nicolas On May 22, 2013, at 8:15 PM, eat wrote: > Hi, > > FWIW, apparently bug related to dtype of np.eye(.) > > > On Wed, May 22, 2013 at 8:07 PM, Nicolas Rougier > wrote: > > > Hi all, > > I g

[Numpy-discussion] Possible conversion bug with record array

2013-05-22 Thread Nicolas Rougier
e(4, dtype=np.float32) print U[0] # output: ([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]],) The first output is obviously wrong. Can anyone confirm ? (using numpy 1.7.1 on osx 10.8.3) Nicolas ___ NumPy-Discussi

Re: [Numpy-discussion] Numpy beginner tutorial

2013-05-07 Thread Nicolas Rougier
Shame on me ! How did I forget this one... Thanks, just added it. Nicolas > > Hi Nicolas, that looks good. You're linking to some other tutorials at the > bottom, maybe you can add http://scipy-lectures.github.io/ (has both an intro > and an advanced numpy tuto

[Numpy-discussion] Numpy beginner tutorial

2013-05-07 Thread Nicolas Rougier
ectly the formated entry. Here is an example: #. Find indices of non-zero elements from [1,2,0,0,4,0] .. code:: python # Author: Somebody print np.nonzero([1,2,0,0,4,0]) If you can provide the (assumed) level of the answer, that would be even better.

Re: [Numpy-discussion] GSOC 2013

2013-03-04 Thread Nicolas Rougier
very problem and ended up coding a "group class" which is a "split" structured array (each field is stored as a single array) offering the same interface as a regular structured array. http://www.loria.fr/~rougier/coding/software/numpy_group.py Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Array indexing and repeated indices

2013-03-01 Thread Nicolas Rougier
> > bincount takes a weights argument which should do exactly what you are > looking for. Fantastic ! Thanks ! Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] Array indexing and repeated indices

2013-02-28 Thread Nicolas Rougier
y-with-repeated-indices but it is only for a fixed increment from what I've understood. Nicolas # import numpy as np n,p = 5,100 nodes = np.zeros( n, [('value', 'f4', 1)] ) links = np.zeros( p, [('source', 'i4', 1

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

2013-02-12 Thread Nicolas Rougier
I did not know that. Thanks for the clear explanation. Nicolas On Feb 12, 2013, at 19:25 , Jaime Fernández del Río wrote: > On Tue, Feb 12, 2013 at 9:53 AM, Nicolas Rougier > wrote: > Did I do something wrong or is it expected behavior ? > > Try: > > print (Z.view(&#x

[Numpy-discussion] View on sliced array without copy

2013-02-12 Thread Nicolas Rougier
# True print (Z.view('f4'))[:50].base is Z # False print Z[:50].view('f4').base is Z # False Did I do something wrong or is it expected behavior ? Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] dtype "reduction" [SOLVED]

2013-01-15 Thread Nicolas Rougier
I ended coding the dtype reduction, it's not foolproof but it might be useful for others as well. Nicolas import numpy as np def dtype_reduce(dtype, level=0, depth=0): """ Try to reduce dtype up to a given level when it is possible dtype = [ ('ve

Re: [Numpy-discussion] Manipulate neighboring points in 2D array

2012-12-30 Thread Nicolas Rougier
7; parameter won't be useful in your case so you have to set it to 'src'. Nicolas On Dec 30, 2012, at 12:21 , deb wrote: > Thanks Zach for your interest > > I was thinking about ndimage.generic_filter when I wrote about generic filter. > For generic_filter I used trivial fun

Re: [Numpy-discussion] dtype "reduction"

2012-12-27 Thread Nicolas Rougier
Yep, I'm trying to construct dtype2 programmaticaly and was hoping for some function giving me a "canonical" expression of the dtype. I've started playing with fields but it's just a bit harder than I though (lot of different cases and recursion). Thanks for the ans

[Numpy-discussion] dtype "reduction"

2012-12-26 Thread Nicolas Rougier
, 'f4')]), ('color', [('r', 'f4'), ('g', 'f4'), ('b', 'f4'), ('a', 'f4')]) ] ) dtype2 = np.dtype( [ (

Re: [Numpy-discussion] Scipy dot

2012-11-12 Thread Nicolas SCHEFFER
Yep exactly. I just want to make sure that we talked enough on the principle first (ie. goals and technical approach), and that indeed the code is good enough to look at. I get it from your answer that it is, so I went ahead https://github.com/numpy/numpy/pull/2730 Thanks -nicolas On Mon, Nov

Re: [Numpy-discussion] Scipy dot

2012-11-12 Thread Nicolas SCHEFFER
I've pushed my code to a branch here https://github.com/leschef/numpy/tree/faster_dot with the commit https://github.com/leschef/numpy/commit/ea037770e03f23aca1a06274a1a8e8bf0e0e2ee4 Let me know if that's enough to create a pull request. Thanks, -nicolas On Sat, Nov 10, 2012 at 4:39

Re: [Numpy-discussion] Scipy dot

2012-11-09 Thread Nicolas SCHEFFER
n a.dot(a.T), which is awesome. -nicolas Nath: same trend if arrays are different. On Fri, Nov 9, 2012 at 3:05 PM, Nathaniel Smith wrote: > In this case it's even possible the blas is being smart enough to notice > that you've passed it the same pointer twice with the transpose switch o

Re: [Numpy-discussion] Scipy dot

2012-11-09 Thread Nicolas SCHEFFER
ht'] - right)**2).sum()) Out[28]: 0.015331409 # # CCl # While the MSE are small, I'm wondering whether: - It's a bug: it should be exactly the same - It's a feature: BLAS is taking shortcuts when you have A.A'. The difference is not significant. Quick: PR that asap! I don&#

Re: [Numpy-discussion] Scipy dot

2012-11-09 Thread Nicolas SCHEFFER
It's a pain to test because I cannot do the test in a single python session. I'm going to try to integrate most of your suggestions, I cannot guarantee I'll have time to do them all though. -nicolas On Fri, Nov 9, 2012 at 8:56 AM, Nathaniel Smith wrote: > On Fri, Nov 9, 2012 at

Re: [Numpy-discussion] Scipy dot

2012-11-08 Thread Nicolas SCHEFFER
gt; blas version accept the same stuff, so if this isn't in the current version, > there will be probably some adjustment later on that side. What blas do you > use? I think ATLAS was one that was causing problem. > > > When we did this in Theano, it was more complicated then this di

Re: [Numpy-discussion] Scipy dot

2012-11-08 Thread Nicolas SCHEFFER
wrote: > On Fri, 2012-11-09 at 00:24 +0100, Sebastian Berg wrote: >> Hey, >> >> On Thu, 2012-11-08 at 14:44 -0800, Nicolas SCHEFFER wrote: >> > Well, hinted by what Fabien said, I looked at the C level dot function. >> > Quite verbose! >> > >> &

Re: [Numpy-discussion] Scipy dot

2012-11-08 Thread Nicolas SCHEFFER
ht be too easy to be true. On Thu, Nov 8, 2012 at 12:06 PM, Nicolas SCHEFFER wrote: > I've made the necessary changes to get the proper order for the output array. > Also, a pass of pep8 and some tests (fixmes are in failing tests) > http://pastebin.com/M8TfbURi > > -n >

Re: [Numpy-discussion] Scipy dot

2012-11-08 Thread Nicolas SCHEFFER
I've made the necessary changes to get the proper order for the output array. Also, a pass of pep8 and some tests (fixmes are in failing tests) http://pastebin.com/M8TfbURi -n On Thu, Nov 8, 2012 at 11:38 AM, Nicolas SCHEFFER wrote: > Thanks for all the responses folks. This is indee

Re: [Numpy-discussion] Scipy dot

2012-11-08 Thread Nicolas SCHEFFER
hand scipy is always compiled with >>> >> lapack. Thus this makes more sens in scipy. >>> > >>> > Well, numpy.dot already contains multiple fallback cases for when it is >>> > compiled with BLAS and not. So I'm +1 on just making this a

Re: [Numpy-discussion] [numpy] ENH: Initial implementation of a 'neighbor' calculation (#303)

2012-10-12 Thread Nicolas Rougier
Sorry, I'm away from the lab and did not have a chance to test is yet. I will do next week. Nicolas On Oct 11, 2012, at 15:48 , Nathaniel Smith wrote: > On Thu, Oct 11, 2012 at 10:50 AM, Nicolas Rougier > wrote: >> I missed the original post but I personally find this ad

Re: [Numpy-discussion] [numpy] ENH: Initial implementation of a 'neighbor' calculation (#303)

2012-10-11 Thread Nicolas Rougier
ed result. This also work with sparse array for example when the kernel is very small. I suspect the PR will be quite efficient compared to what I did. Nicolas On Oct 10, 2012, at 18:55 , Cera, Tim wrote: > On Wed, Oct 10, 2012 at 1:58 AM, Travis E. Oliphant > wrote: > I'm not

[Numpy-discussion] nested loops too slow

2012-08-08 Thread nicolas aunai
Hi, I'm trying to write a code for doing a 2D integral. It works well when I'm doing it with normal "for" loops, but requires two nested loops, and is much too slow for my application. I would like to know if it is possible to do it faster, for example with fancy indexing and the use of numpy.cums

Re: [Numpy-discussion] Matrices and arrays of vectors

2012-02-24 Thread Nicolas Rougier
], [-1.0*s, c]]) # Fudge some data to work with data = numpy.random.uniform(-1.0, 1.0, (M,N,2)) numpy.dot(data,rotation) Nicolas On Feb 24, 2012, at 13:11 , Bob Dowling wrote: > import math > import numpy > import numpy.random > > # Rotation angle > theta = math.pi/6.0 >

Re: [Numpy-discussion] matrix product in parallel?

2011-11-18 Thread Nicolas Bock
Hello list, please ignore my previous email. I just found http://www.scipy.org/ParallelProgramming Thanks, nick On Fri, Nov 18, 2011 at 15:27, Nicolas Bock wrote: > Hello list, > > is it possible to get numpy to do a matrix product in parallel? I presume > that the multiply in

[Numpy-discussion] matrix product in parallel?

2011-11-18 Thread Nicolas Bock
Hello list, is it possible to get numpy to do a matrix product in parallel? I presume that the multiply in the back-end is really done by dgemm() or equivalent, so is it possible to use a parallel dgemm() there? Thanks, nick ___ NumPy-Discussion mailin

Re: [Numpy-discussion] [ANN] glumpy 0.2.0

2011-09-17 Thread Nicolas Rougier
Thanks. I just uploaded it to pypi. Nicolas On Sep 16, 2011, at 22:21 , Samuel John wrote: > Hi Nicolas, > > that looks great. > Could you make this available such that `pip install glumpy` would work? > > cheers, > Samuel > >

[Numpy-discussion] [ANN] glumpy 0.2.0

2011-09-16 Thread Nicolas Rougier
Hi folks, I am pleased to announce a new release of glumpy, a small python library for the (very) fast vizualization of numpy arrays, (mainly two dimensional) that has been designed with efficiency in mind. If you want to draw nice figures for inclusion in a scientific article, you’d better us

[Numpy-discussion] Get a 1D slice of a 3D data set?

2011-07-25 Thread Nicolas Bigaouette
Hi all, I have a 3D orthogonal and non-uniform grid representing a scalar field. I'm using matplotlib.image.NonUniformImage() to plot it similarly to imshow(). What I'd like to do is plot the values of the scalar field across a specific line (say, from point A to B). Any suggestion? Thanks! ___

Re: [Numpy-discussion] Recommndations for an easy GUI

2011-06-27 Thread Nicolas Rougier
Have a look at glumpy: http://code.google.com/p/glumpy/ It's quite simple and very fast for images (it's based on OpenGL/shaders). Nicolas On Jun 28, 2011, at 6:38 AM, Nadav Horesh wrote: > I have an application which generates and displays RGB images as rate of > several f

Re: [Numpy-discussion] How to sum weighted matrices

2011-03-08 Thread Nicolas SCHEFFER
Or just with a dot: === In [17]: np.tensordot(weights, matrices, (0,0)) Out[17]: array([[ 5., 5., 5.], [ 5., 5., 5.]]) In [18]: np.dot(matrices.T,weights).T Out[18]: array([[ 5., 5., 5.], [ 5., 5., 5.]]) == make matrices.T C_CONTIGUOUS for maximum speed. -n On Mon, Mar

Re: [Numpy-discussion] MKL libraries can't be found

2011-02-13 Thread Nicolas Pinto
ng to avoid creating a directory > of symbolic links to every necessary library. > > > > > Jonathan Tu > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > -- Nicolas Pinto http://web.mit.edu/pinto ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Help in speeding up accumulation in a matrix

2011-01-30 Thread Nicolas SCHEFFER
Thalhammer wrote: > > Am 29.1.2011 um 22:01 schrieb Nicolas SCHEFFER: > >> Hi all, >> >> First email to the list for me, I just want to say how grateful I am >> to have python+numpy+ipython etc... for my day to day needs. Great >> combination of software.

Re: [Numpy-discussion] Help in speeding up accumulation in a matrix

2011-01-29 Thread Nicolas SCHEFFER
Thanks for the prompt reply! I quickly tried that and it actually helps compared to the full vectorized version. Depending on the dimensions, the chunk size has to be tuned (typically 100 or so) But I don't get any improvement w/r to the simple for loop (i can almost match the time though). My gue

[Numpy-discussion] Help in speeding up accumulation in a matrix

2011-01-29 Thread Nicolas SCHEFFER
Hi all, First email to the list for me, I just want to say how grateful I am to have python+numpy+ipython etc... for my day to day needs. Great combination of software. Anyway, I've been having this bottleneck in one my algorithms that has been bugging me for quite a while. The objective is to sp

Re: [Numpy-discussion] Regrading Numpy Documentation ...

2010-11-17 Thread Nicolas Bigaouette
Chrome might have some feature where local javascript can't be executed... just an idea ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] index of a value in an array

2010-10-06 Thread Nicolas Bigaouette
On Wed, Oct 6, 2010 at 5:26 AM, Chris Withers wrote: > Hi All, > > Given an array such as: > > array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) > > How can I find the index of a particular number in the array? > > (ie: if it was a list, I'd do [1,2,3,4].index(3)) > > cheers, > > Chris > _

Re: [Numpy-discussion] Viewer for 2D Numpy arrays (GUI)

2010-09-17 Thread Nicolas Rougier
Maybe glumpy may be of some help: http://code.google.com/p/glumpy/ Nicolas On Fri, 2010-09-17 at 09:03 +0200, Massimo Di Stefano wrote: > Hi, > > > have yo already tryied Spyderlib : > > > http://code.google.com/p/spyderlib/ > > > a matlab-like environment

Re: [Numpy-discussion] [Matplotlib-users] Vectorization

2010-07-30 Thread Nicolas Bigaouette
2010/7/2 Charles R Harris > > > On Fri, Jul 2, 2010 at 12:15 PM, Nicolas Bigaouette > wrote: > >> Hi all, >> >> I don't really know where to ask, so here it is. >> >> I was able to vectorize the normalization calculation in quantum >> m

[Numpy-discussion] Help on vectorization of mesh normals computation

2010-06-17 Thread Nicolas Rougier
rmals[indices[i]] += N[i] I would like to get rid of the last 'for' loop but did not find the proper way to do it. Anyone got an idea ? Nicolas ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] numpy documentation

2010-06-03 Thread Nicolas Gruel
Hi Stefan, It's seems that can be very useful indeed. I will give a try. Thank you. Nicolas 2010/6/3 Stéfan van der Walt > Hi Nicolas > > On 3 June 2010 02:03, Nicolas Gruel wrote: > > Another question, it's seems that the rst file for each function in numpy >

[Numpy-discussion] numpy documentation

2010-06-03 Thread Nicolas Gruel
he rst file for each function in numpy are autogenerated. Can you give me any information how to do it, please? I didn't find it on numpy website but I probably miss the good link... Thank you for any help. Nicolas here the two files: foo.rst

Re: [Numpy-discussion] Some help on matlab to numpy translation

2010-03-15 Thread Nicolas Rougier
y. Thanks again. Nicolas On Mar 15, 2010, at 22:32 , Friedrich Romstedt wrote: > Ok, so I send yet another version. Maybe Bruce is right, but I didn't > care, because we have fret enough. Now it not only computes > something, but also displays something :-( > > Ni

Re: [Numpy-discussion] Some help on matlab to numpy translation

2010-03-14 Thread Nicolas Rougier
think) but unfortunately, it does not seem to do anything at the moment, I need to investigate further where is the problem. Nicolas New version: ''' Channel flow past a cylindrical obstacle, using a LB method Copyright (C) 2006 Jonas Latt Address: Rue General Dufour 24, 1211 Gen

  1   2   >