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.
>
>
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
Hi all,
I've updated the numpy exercices collection and made it available on github at:
https://github.com/rougier/numpy-100
These exercices mainly comes from this mailing list and also from stack
overflow. If you have other examples in mind, do not hesitate to make a pull
request. The maste
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, at 16:5
>
> Ben Root
>
>
> On Mon, Mar 3, 2014 at 4:06 PM, Nicolas Rougier
> wrote:
>
> Hi all,
>
> I'm using numpy 1.8.0 (osx 10.9, python 2.7.6) and I can't understand dtype
> promotion in the following case:
>
> >>> Z = np.zeros((2,2)
Hi all,
I'm using numpy 1.8.0 (osx 10.9, python 2.7.6) and I can't understand dtype
promotion in the following case:
>>> Z = np.zeros((2,2),dtype=np.float32) + 1
>>> print Z.dtype
float32
>>> Z = np.zeros((2,2),dtype=np.float32) + (1,1)
>>> print Z.dtype
float64
Is this the expected behavior
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
Hi all,
I've coding an ArrayList object based on a regular numpy array. This objects
allows to dynamically append/insert/delete/access items. I found it quite
convenient since it allows to manipulate an array as if it was a list with
elements of different sizes but with same underlying type (=
((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
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(('>> Z['a'].view(Z.dtype['a'])
ValueError: new type not compatible with array.
Nicolas
_
Hi,
I have a (n,2) shaped array representing points and I would like to double each
point as in:
A = np.arange(10*2).reshape(10,2)
B = np.repeat( A, 2, axis=0 )
Is it possible to do the same using 'as_strided' to avoid copy (and still get
the same output shape for B) ?
I found this referenc
Works for me (numpy 1.7.1, osx 10.8.3):
>>> import numpy as np
>>> print np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), size=1)
[[-0.55854737 -1.82631485]]
>>> print np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2),
>>> size=np.int64(1))
[[ 0.40274243 -0.33922682]]
> 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
>
> Sure, that's clearly what's going on, but numpy shouldn't let you
> silently shoot yourself in the foot like that. Re-using input as
> output is a very common operation, and usually supported fine.
> Probably we should silently make a copy of any input(s) that overlap
> with the output? For h
Hi,
>From the dot documentation, I tried something simple:
a = np.array([[1, 2], [3, 4]])
b = np.array([[1, 2], [3, 4]])
np.dot(a, b)
-> array([[ 7, 10],
[15, 22]])
And I got expected result but if I use either a or b as output, results are
wrong (and nothing in the dot documentatio
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
Hi all,
I got a weird output from the following script:
import numpy as np
U = np.zeros(1, dtype=[('x', np.float32, (4,4))])
U[0] = np.eye(4)
print U[0]
# output: ([[0.0, 1.875, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0,
1.875], [0.0, 0.0, 0.0, 0.0]],)
U[0] = np.eye(4, dtype=np.float
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 tutorial).
>
> Ralf
___
Hello everybody,
I've written a numpy beginner tutorial that is available from:
http://www.loria.fr/~rougier/teaching/numpy/numpy.html
It has been designed around cellular automata to try to make it fun.
While writing it, I tried to compile a set of exercises and make them
progressively ha
> This made me think of a serious performance limitation of structured dtypes: a
> structured dtype is always "packed", which may lead to terrible byte alignment
> for common types. For instance, `dtype([('a', 'u1'), ('b',
> 'u8')]).itemsize == 9`,
> meaning that the 8-byte integer is not aligned
>
> 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
Hi,
I'm trying to increment an array using indexing and a second array for
increment values (since it might be a little tedious to explain, see below for
a short example).
Using "direct" indexing, the values in the example are incremented by 1 only
while I want to achieve the alternative beh
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(
Hi,
I'm trying to get a view on a sliced array without copy but I'm not able to do
it as illustrated below:
dtype = np.dtype( [('color', 'f4', 4)] )
Z = np.zeros(100, dtype=dtype)
print Z.view('f4').base is Z# True
print Z[:50].base is Z # True
print (Z.view('f4'))[:50]
e,level=1)
print
# Not fully reductible
dtype = [ ('vertex', [('x', 'i4'), ('y', 'i4'), ('z', 'i4')]),
('normal', [('x', 'f4'), ('y', 'f4'),
You might want to have a look at :
http://code.google.com/p/glumpy/source/browse/demos/gray-scott.py
which implements a Gray-Scott reaction-diffusion system.
The 'convolution_matrix(src, dst, kernel, toric)' build a sparse matrix such
that multiplying an array with this matrix will result in
wer.
Nicolas
On Dec 27, 2012, at 1:32 , Nathaniel Smith wrote:
> On Wed, Dec 26, 2012 at 8:09 PM, Nicolas Rougier
> wrote:
>>
>>
>> Hi all,
>>
>>
>> I'm looking for a way to "reduce" dtype1 into dtype2 (when it is possible of
Hi all,
I'm looking for a way to "reduce" dtype1 into dtype2 (when it is possible of
course).
Is there some easy way to do that by any chance ?
dtype1 = np.dtype( [ ('vertex', [('x', 'f4'),
('y', 'f4'),
('z', 'f4')]),
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
I missed the original post but I personally find this addition especially
useful for my work in computational neuroscience.
I did something vaguely similar in a small framework (http://dana.loria.fr/,
you can look more specifically at http://dana.loria.fr/doc/connection.html for
details). Exa
You should use a (M,N,2) array to store your vectors:
import math
import numpy
import numpy.random
# Rotation angle
theta = math.pi/6.0
# Grid shape
M = 10
N = 10
# Establish the rotation matrix
c = math.cos(theta)
s = math.sin(theta)
rotation = numpy.array([[c, s],
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-Discussi
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
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 frames/seconds (5-
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 based on pyqt
> you can store
Hello,
I'm trying to find a way to compute the normals of a mesh (vertices + indices)
using only vectorized computations and I wonder if anyone already did that.
Here my code so far:
# Mesh generation + indices for triangles
n = 24
vertices = numpy.zeros(((n*n),3), dtype=numpy.float32)
normals
Thanks and in fact, I already wasted quite some time on and your last version
will help me a lot. Unfortunately, I'm not a specialist at lattice Boltzmann
methods at all so I'm not able to answer your questions (my initial idea was to
convert the matlab script to be have a running example to g
+uy**2)
#u[bbRegion] = numpy.nan
print u.min(), u.max()
#plt.imshow(u)
#plt.show()
On Mar 13, 2010, at 16:59 , Friedrich Romstedt wrote:
> 2010/3/13 Nicolas Rougier :
>> I'm trying to translate a small matlab program for the simulation in a 2D
>>
Thanks.
I agree that the use of ':' is a bit weird.
Nicolas
On Mar 13, 2010, at 11:45 , Fabrice Silva wrote:
> Le samedi 13 mars 2010 à 10:20 +0100, Nicolas Rougier a écrit :
>> Hello,
>> I'm trying to translate a small matlab program for the simulation in a
Hello,
I'm trying to translate a small matlab program for the simulation in a 2D flow
in a channel past a cylinder and since I do not have matlab access, I would
like to know if someone can help me, especially on array indexing. The matlab
source code is available at: http://www.lbmethod.org/o
Hello,
This is an update about glumpy, a fast-OpenGL based numpy visualization.
I modified the code such that the only dependencies are PyOpenGL and
IPython (for interactive sessions). You will also need matplotlib and
scipy for some demos.
Sources: hg clone http://glumpy.googlecode.com/hg/ glu
I've created a ticket (#1327).
Nicolas
On Dec 11, 2009, at 17:21 , Keith Goodman wrote:
> On Fri, Dec 11, 2009 at 12:50 AM, Nicolas Rougier
> wrote:
>>
>> Hello,
>>
>> Using both numpy 1.3.0 and 1.4.0rc1 I got the following exception using
>> nan_to_
Hello,
Using both numpy 1.3.0 and 1.4.0rc1 I got the following exception using
nan_to_num on a bool array, is that the expected behavior ?
>>> import numpy
>>> Z = numpy.zeros((3,3),dtype=bool)
>>> numpy.nan_to_num(Z)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/py
28, 2009 at 9:06 AM, Nicolas Rougier > wrote:
Hi all,
glumpy is a fast OpenGL visualization tool for numpy arrays coded on
top of pyglet (http://www.pyglet.org/). The package contains many
demos showing basic usage as well as integration with matplotlib. As a
reference, the animation script ava
Hi all,
glumpy is a fast OpenGL visualization tool for numpy arrays coded on
top of pyglet (http://www.pyglet.org/). The package contains many
demos showing basic usage as well as integration with matplotlib. As a
reference, the animation script available from matplotlib distribution
runs
Hi,
I've coded a function that allows to extract a contiguous array from
another one using a given shape and centered on a given position. I
did not find an equivalent within numpy so I hope I did not miss it.
The only interest of the function is to guarantee that the resulting
sub-array
*len(t))
s += t+a+'\n'
s += ')'
return s
if __name__ == '__main__':
G = group((3,3), dtype =
[('r',np.float32),('g',np.int32),('b',np.bool)])
G['r'] = G.g = G.b = 0
prin
Thanks for the quick answer. It makes sense.
I will have to find some other way to do it then.
Nicolas
On 30 Jul, 2009, at 18:52 , David Cournapeau wrote:
> On Fri, Jul 31, 2009 at 12:53 AM, Nicolas
> Rougier wrote:
>>
>>
>> Hello,
>>
>> I've been
Hello,
I've been using record arrays to create arrays with different types
and since I'm doing a lot of computation on each of the different
fields, the default memory layout does not serve my computations.
Ideally, I would like to have record arrays where each field is a
contiguous bloc
Thank for the clear answer, it definitely helps.
Nicolas
On Thu, 2009-05-28 at 19:25 +0200, Francesc Alted wrote:
> A Wednesday 27 May 2009 17:31:20 Nicolas Rougier escrigué:
> > Hi,
> >
> > I've written a very simple benchmark on recarrays:
> >
> > impo
Hi,
I tried to post results but the file is too big, anyway, here is the
benchmark program if you want to run it:
Nicolas
-
import time
import numpy
from scipy import sparse
def benchmark(xtype = 'numpy.array', xdensity = 0.1,
ytype = 'numpy.array', ydensity = 1.0, n = 100
I just created the account.
Nicolas
On Thu, 2009-05-28 at 11:21 +0200, Stéfan van der Walt wrote:
> Hi Nicolas
>
> 2009/5/27 Nicolas Rougier :
> > No, I don't have permission to edit.
>
> Thanks for helping out with the docs! Please create an account on
> docs.
Hi,
I'm now testing dot product and using the following:
import numpy as np, scipy.sparse as sp
A = np.matrix(np.zeros((5,10)))
B = np.zeros((10,1))
print (A*B).shape
print np.dot(A,B).shape
A = sp.csr_matrix(np.zeros((5,10)))
B = sp.csr_matrix((10,1))
print (A*B).shape
print np.dot(A,B).shape
Hi again,
I have a problem with the nonzero() function for matrix.
The following test program:
import numpy, scipy.sparse
Z = numpy.zeros((10,10))
Z[0,0] = Z[1,1] = 1
i = Z.nonzero()
print i
Zc = scipy.sparse.coo_matrix((Z[i],i))
Z = numpy.matrix(Z)
i = Z.nonzero()
print i
Zc = scipy.sparse
No, I don't have permission to edit.
Nicolas
On 27 May, 2009, at 18:01 , Charles R Harris wrote:
On Wed, May 27, 2009 at 9:31 AM, Nicolas Rougier > wrote:
Hi,
I've written a very simple benchmark on recarrays:
import numpy, time
Z = numpy.zeros((100,100), dtype=numpy.fl
Hi,
I've written a very simple benchmark on recarrays:
import numpy, time
Z = numpy.zeros((100,100), dtype=numpy.float64)
Z_fast = numpy.zeros((100,100), dtype=[('x',numpy.float64),
('y',numpy.int32)])
Z_slow = numpy.zeros((100,100), dtype=[('x',numpy.float64),
('y',numpy.bool)])
t = time.cloc
Hello,
I've come across what is probably a bug in size check for large arrays:
>>> import numpy
>>> z1 = numpy.zeros((255*256,256*256))
Traceback (most recent call last):
File "", line 1, in
ValueError: dimensions too large.
>>> z2 = numpy.zeros((256*256,256*256))
>>> z2.shape
(65536, 65536)
Hello,
I'm using tensordot in some computation and while I've been amazed by
the speed, I'm now trying to reduce memory consumption in some very
particular cases:
Let S be a 2 dims array of size (s1,s2)
Let D be a 2 dims array of size (d1,d2)
Let W be a 4 dims array of size (d1,d2,s1,s2)
Cu
m able to write something like:
>>> group = Unit()*[2,2]
>>> group.potentials = numpy.zeros([2,2])
>>> print group.potentials
[[ 0. 0.]
[ 0. 0.]]
>>> group[0,0].potential = 1
[[ 1. 0.]
[ 0. 0.]]
Nicolas
On Thu, 2008-07-10 at 16:30 -0700
Nicolas
On Thu, 2008-07-10 at 13:43 -0700, Christopher Barker wrote:
> Nicolas Rougier wrote:
> > I would like to create numpy array with my own (python) datatype, so I
> > tried the obvious solution:
> >
> > from numpy import *
> > class Unit(object):
&g
Hi all,
I'm rather new to the list so maybe the question is well known but from
my researches on the web and list archive, I did not find a clear
explanation.
I would like to create numpy array with my own (python) datatype, so I
tried the obvious solution:
from numpy import *
class Unit(objec
61 matches
Mail list logo