On 27 May 2014, at 21:09, Chris Barker chris.bar...@noaa.gov wrote:
On Mon, May 26, 2014 at 9:57 PM, Nicolas Rougier nicolas.roug...@inria.fr
wrote:
I've updated the numpy exercices collection and made it available on github
at:
https://github.com/rougier/numpy-100
very useful
Thanks, you just inaugurated the master section.
Nicolas
On 27 May 2014, at 21:48, Jaime Fernández del Río jaime.f...@gmail.com wrote:
On Tue, May 27, 2014 at 12:27 PM, Nicolas Rougier nicolas.roug...@inria.fr
wrote:
Any other tricky stride_trick tricks ? I promised to put them
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
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
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 ?
What it
On Mon, Mar 3, 2014 at 4:06 PM, Nicolas Rougier nicolas.roug...@inria.fr
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),dtype=np.float32) + 1
print Z.dtype
float32
Z = np.zeros((2,2
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 module
print np.resize(V,2)
File
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
= np.zeros(10, (np.float32,4))
Z.strides
(16,4)
Nicolas
On Aug 31, 2013, at 7:51 AM, Stéfan van der Walt ste...@sun.ac.za wrote:
Hi Nicolas
On Fri, 30 Aug 2013 17:26:51 +0200, Nicolas Rougier wrote:
Z = np.zeros(10, [('a', np.float32, 3), ('b', np.float32, 4)])
Z['a'].dtype
dtype
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(('f4', (3,)))
Does that mean that dtype['a'] is the dtype of field 'a' when in Z, while
Z['a'].dtype is
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
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
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
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,
Thanks, I filed a new issue on the bug tracker.
Nicolas
On May 22, 2013, at 8:15 PM, eat e.antero.ta...@gmail.com wrote:
Hi,
FWIW, apparently bug related to dtype of np.eye(.)
On Wed, May 22, 2013 at 8:07 PM, Nicolas Rougier nicolas.roug...@inria.fr
wrote:
Hi all,
I got
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
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 as an
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
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
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 nicolas.roug...@inria.fr
wrote:
Did I do something wrong or is it expected behavior ?
Try:
print (Z.view('f4
)
On Dec 27, 2012, at 9:11 , Nicolas Rougier wrote:
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
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
, 2012, at 1:32 , Nathaniel Smith wrote:
On Wed, Dec 26, 2012 at 8:09 PM, Nicolas Rougier
nicolas.roug...@inria.fr wrote:
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
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
nicolas.roug...@inria.fr wrote:
I missed the original post but I personally find
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).
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-Discussion
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
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
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 object
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)
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
(), u.max()
#plt.imshow(u)
#plt.show()
On Mar 13, 2010, at 16:59 , Friedrich Romstedt wrote:
2010/3/13 Nicolas Rougier nicolas.roug...@loria.fr:
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
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:
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
2D flow in a channel past a cylinder
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/
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 stdin, line 1, in module
File
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
nicolas.roug...@loria.fr wrote:
Hello,
Using both numpy 1.3.0 and 1.4.0rc1 I got the following exception using
nan_to_num on a bool array
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
is whether people are interested in glumpy
to have a quick dirty debug tool on top of matplotlib or whether
they prefer a full fledged and fast pyglet/OpenGL backend (which is
really harder).
Nicolas
On 28 Sep, 2009, at 18:05 , Gökhan Sever wrote:
On Mon, Sep 28, 2009 at 9:06 AM, Nicolas
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
at 20:01 +0200, Nicolas Rougier wrote:
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
Rougiernicolas.roug...@loria.fr wrote
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
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
Rougiernicolas.roug...@loria.fr wrote:
Hello,
I've been using record arrays to create
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 =
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:
import numpy, time
Z = numpy.zeros((100,100
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
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 =
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 nicolas.roug...@loria.fr
wrote:
Hi,
I've written a very simple benchmark on recarrays:
import numpy, time
Z = numpy.zeros((100,100
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 =
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 stdin, line 1, in module
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)
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, Christopher Barker wrote:
Nicolas Rougier wrote:
Concerning the dtype
, 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):
def __init__(self,value=0.0):
self.value = value
def __float__(self
56 matches
Mail list logo