Re: [Numpy-discussion] 1.6: branching and release notes

2011-03-13 Thread Robert Kern
27;newiter' > to 'nditer', is that a reasonable name or does anyone have a better > suggestion? +1. As a general rule, never name anything "new". -- Robert Kern "I have come to believe that the whole world is an e

Re: [Numpy-discussion] how to compile Fortran using setup.py

2011-03-10 Thread Robert Kern
;s it. In other words, this is what I want > distutils to do: > > $ cython cmesh.pyx > $ gcc -fPIC -o cmesh.o -c cmesh.c -I$SPKG_LOCAL/include/python2.6 > -I$SPKG_LOCAL/lib/python2.6/site-packages/numpy/core/include > $ gfortran -fPIC -o fmesh.o -c fmesh.f90 > $ gcc -shared -o cmesh.s

Re: [Numpy-discussion] Any easy way to do this?

2011-03-09 Thread Robert Kern
mbda x, axis: np.sqrt(np.sum(x**2, axis=axis)) >> d = norm(w[:,:,None] - y[None,None], -1) >> >> Angus. > > Thanks!  Now if I could understand why > w[:,:,None] - y[None,None] is what I needed... np.newaxis is None. Idiomatically, that should be written d = norm(w[:,:,

Re: [Numpy-discussion] Boolean indexing

2011-03-08 Thread Robert Kern
([0,1,0,0,0], dtype=bool) > print b[m] > print b[m][0,0] > b[m][0,0] = -1 > print b[m][0,0] > > I think the boolean slicing is making a copy instead of a view. is there > a way around this? bm = b[m] bm[0,0] = -1 b[m] = bm -- Robert Kern "I have come to believe that the whole

Re: [Numpy-discussion] Numpy 1.6 schedule

2011-03-07 Thread Robert Kern
r to me what operations are different under Mark's changes. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth."   -- Umberto Eco __

Re: [Numpy-discussion] (no subject)

2011-03-02 Thread Robert Kern
j] 0.0065380564732848701 [~] |19> A.min() 0.0065380564732848701 -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth."   -- Umberto Eco ___

Re: [Numpy-discussion] Adding `offset` argument to np.lib.format.open_memmap and np.load

2011-03-01 Thread Robert Kern
On Tue, Mar 1, 2011 at 18:40, Jon Olav Vik wrote: > Robert Kern gmail.com> writes: >> > Within a single machine, that sounds fine. What about processes running on >> > different nodes, with different main memories? >> >> You mean mmaping a file on a shared f

Re: [Numpy-discussion] Adding `offset` argument to np.lib.format.open_memmap and np.load

2011-03-01 Thread Robert Kern
On Tue, Mar 1, 2011 at 17:06, Jon Olav Vik wrote: > Robert Kern gmail.com> writes: >> >> It's up to the virtual memory manager, but usually, it will just load >> >> those pages (chunks the size of mmap.PAGESIZE) that are touched by >> >> your req

Re: [Numpy-discussion] Adding `offset` argument to np.lib.format.open_memmap and np.load

2011-03-01 Thread Robert Kern
On Tue, Mar 1, 2011 at 15:36, Jon Olav Vik wrote: > Robert Kern gmail.com> writes: >> >> >> You can have each of those processes memory-map the whole file and >> >> >> just operate on their own slices. Your operating system's virtual >> >

Re: [Numpy-discussion] Adding `offset` argument to np.lib.format.open_memmap and np.load

2011-03-01 Thread Robert Kern
On Tue, Mar 1, 2011 at 07:20, Jon Olav Vik wrote: > Robert Kern gmail.com> writes: > >> On Mon, Feb 28, 2011 at 18:50, Sturla Molden molden.no> wrote: >> > Den 01.03.2011 01:15, skrev Robert Kern: >> >> You can have each of those processes memory-map t

Re: [Numpy-discussion] Adding `offset` argument to np.lib.format.open_memmap and np.load

2011-02-28 Thread Robert Kern
On Mon, Feb 28, 2011 at 18:50, Sturla Molden wrote: > Den 01.03.2011 01:15, skrev Robert Kern: >> You can have each of those processes memory-map the whole file and >> just operate on their own slices. Your operating system's virtual >> memory manager should handle

Re: [Numpy-discussion] Adding `offset` argument to np.lib.format.open_memmap and np.load

2011-02-28 Thread Robert Kern
ap and read/write to non-overlapping > portions without interfering with each other allows for fast, simple parallel > I/ > O. You can have each of those processes memory-map the whole file and just operate on their own slices. Your operating system's virtual memory manager should handle all

Re: [Numpy-discussion] conditional array indexing

2011-02-14 Thread Robert Kern
2D arrays. z0_legend in a 1D > look-up table. I assume the error here comes from trying to index a 1D array > with a 2D array. Make sure that z0_legend is a numpy array, not a list. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is

Re: [Numpy-discussion] conditional array indexing

2011-02-14 Thread Robert Kern
1D array with a > roughness value for each class. I am trying to create a new 2D array > containing a map of the roughness values. roughness = z0_legend[landcover] -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible

Re: [Numpy-discussion] numpy docs dependency problem in Ubuntu

2011-02-11 Thread Robert Kern
ckage. A python-matplotlib-nogui in main? ;-) If you are going to do an Ubuntu-only fix, would that allow using our prebuilt doc packages? IIRC, the only objection to that was that it was Debian policy to build docs from sources. But then again, that might have just been the first objection. --

Re: [Numpy-discussion] numpy docs dependency problem in Ubuntu

2011-02-11 Thread Robert Kern
On Fri, Feb 11, 2011 at 11:34, Bruce Southey wrote: > The apparent problem occurs when the user has to build the documentation > from source as sphinx and matlibplot are dependencies. No, please reread the original post. -- Robert Kern "I have come to believe that the whole

Re: [Numpy-discussion] numpy docs dependency problem in Ubuntu

2011-02-10 Thread Robert Kern
Ubuntu users of numpy? We might be able to commit to building and releasing complete doc packages with each source release. Could you just download and use those? We currently make such doc packages, but I don't think we keep old micro revisions around, and I suspect you would want those. htt

Re: [Numpy-discussion] odd performance of sum?

2011-02-10 Thread Robert Kern
On Thu, Feb 10, 2011 at 15:32, eat wrote: > Hi Robert, > > On Thu, Feb 10, 2011 at 10:58 PM, Robert Kern wrote: >> >> On Thu, Feb 10, 2011 at 14:29, eat wrote: >> > Hi Robert, >> > >> > On Thu, Feb 10, 2011 at 8:16 PM, Robert Kern >> &

Re: [Numpy-discussion] odd performance of sum?

2011-02-10 Thread Robert Kern
On Thu, Feb 10, 2011 at 14:51, Joshua Holbrook wrote: > Maybe I'm missing something, but why not just implement sum() using > dot() and ones() ? You can't do everything that sum() does with just dot() and ones(). -- Robert Kern "I have come to believe that the whole

Re: [Numpy-discussion] odd performance of sum?

2011-02-10 Thread Robert Kern
On Thu, Feb 10, 2011 at 14:29, eat wrote: > Hi Robert, > > On Thu, Feb 10, 2011 at 8:16 PM, Robert Kern wrote: >> >> On Thu, Feb 10, 2011 at 11:53, eat wrote: >> > Thanks Chuck, >> > >> > for replying. But don't you still feel very odd that d

Re: [Numpy-discussion] odd performance of sum?

2011-02-10 Thread Robert Kern
and do their iterations more quickly, at least for some common combinations of dtype and contiguity. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Robert Kern
On Wed, Feb 9, 2011 at 10:48, Neal Becker wrote: > Still, I wonder if numpy would benefit from a 'find_first' function. I certainly could have used one many times. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terri

Re: [Numpy-discussion] Computing the norm of an array of vectors

2011-02-08 Thread Robert Kern
On Tue, Feb 8, 2011 at 11:55, Ben Gamari wrote: > On Tue, 8 Feb 2011 10:46:34 -0600, Robert Kern wrote: >> (v*v).sum(axis=1)[:,np.newaxis] >> >> You can leave off the newaxis bit if you don't really need a column vector. >> > Fair enough, I unfortunately neg

Re: [Numpy-discussion] Computing the norm of an array of vectors

2011-02-08 Thread Robert Kern
t; > but surely there must be a better way. Any ideas? (v*v).sum(axis=1)[:,np.newaxis] You can leave off the newaxis bit if you don't really need a column vector. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by

Re: [Numpy-discussion] Need a good idea: calculate the mean of many vectors

2011-02-08 Thread Robert Kern
[~] |17> mean_xyz = sum_xyz / counts[:,np.newaxis] [~] |18> mean_xyz array([[ 0.78316224, 0.4409687 , 0.10126793], [ 0.68330832, 0.4934926 , 0.39946005], [ 0.26787528, 0.12850502, 0.76042557], [ 0.54244609, 0.35049674, 0.78332874], [ 0.28331422, 0.67514095, 0.07765996

Re: [Numpy-discussion] relational join

2011-02-02 Thread Robert Kern
s sorted along the key. * A temporary array is formed by dropping the fields not in the key for the two arrays and concatenating the result. This array is then sorted, and the common entries selected. The output is constructed by filling the fields with the selected entries

Re: [Numpy-discussion] Developer NumPy list versus User NumPy list

2011-01-27 Thread Robert Kern
ood. But that may just be my perspective because I'm subscribed to both and filter them both to the same folder. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an

Re: [Numpy-discussion] einsum

2011-01-26 Thread Robert Kern
complete, this would be part of > libndarray, and could be used directly from C without depending on Python. It think his real question is whether einsum() and the iterator stuff can live in a separate module that *uses* a released version of numpy rather than a development branch. -- Robert K

Re: [Numpy-discussion] find machine maximum numpy array size

2011-01-17 Thread Robert Kern
vely, there is 1 Gb of free address space, but broken up into two 0.5 Gb blocks. You could not allocate a third 1 Gb block because there is nowhere to put it. You can detect this problem early by doing an np.empty() of the right size early in the program. -- Robert Kern "I have come to believe

Re: [Numpy-discussion] indexing of rank-0 structured arrays: why not?

2011-01-10 Thread Robert Kern
ord scalar. It can be indexed because it is often convient to treat such records like tuples. This replaces the default indexing behavior of scalars (which is to simply disallow indexing). a_rank_0 is an array, so the array indexing semantics are the default, and we do not change them. -- Robe

Re: [Numpy-discussion] indexing of rank-0 structured arrays: why not?

2011-01-10 Thread Robert Kern
to index into a rank-0 array. Use an empty tuple instead. [~] |1> dt = np.dtype([('x', ' a_rank_0 = np.zeros((), dtype=dt) [~] |3> a_rank_0[()] (0.0, 0.0) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible

Re: [Numpy-discussion] aa.astype(int) truncates and doesn't round

2011-01-06 Thread Robert Kern
22044605e-16, >        -3.33066907e-16,  -3.33066907e-16]) >>>> np.round(aa).astype(int) > array([1, 1, 1, 1, 1]) This is behavior inherited from C and matches Python's behavior. int(aa[0]) == 0. Similarly, inside the C code, (int)(1.0 - 2.22e-16) == 0. -- Robert Kern "

Re: [Numpy-discussion] aa.astype(int) truncates and doesn't round

2011-01-06 Thread Robert Kern
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, >       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, >       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, >       1, 1, 1, 1, 1, 1, 1, 1]) He's not pointing out a bug. His array does not hav

Re: [Numpy-discussion] Arrays with aliased elements?

2011-01-01 Thread Robert Kern
erstand broadcasting rules, e.g. for > calculating outer products (I mentioned this in a previous thread). See numpy.lib.stride_tricks for tools to do this, specifically the as_strided() function. See numpy.broadcast_arrays() for the latter functionality. http://docs.scipy.org/doc/numpy/reference/ge

Re: [Numpy-discussion] How to call import_array() properly?

2010-12-27 Thread Robert Kern
} > #else > void > init_numpy() > { >        import_array(); > } > #endif Just put "import_array();" into initcvisual(). You should not put it in any other function. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that

Re: [Numpy-discussion] How to call import_array() properly?

2010-12-27 Thread Robert Kern
zation function for your module, e.g. initcvisual(). Do not put it into a separate function for the user of your module to call. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it h

Re: [Numpy-discussion] How to control column for pretty print line wrap of ndarrays

2010-12-22 Thread Robert Kern
On Wed, Dec 22, 2010 at 16:32, Ian Stokes-Rees wrote: > Like most people these days, I have multiple 24" monitors.  I don't need > "print" of ndarrays to wrap after 72 columns.  Is there some way to > change this? np.set_printoptions(linewidth=100) -- Robert Kern

Re: [Numpy-discussion] sample without replacement

2010-12-21 Thread Robert Kern
r j from 0 <= j < nselected: out[i,j] = j for j from nselected <= j < ntotal: u = rk_interval(j+1, self.internal_state) if u < nselected: out[i,u] = j return out.reshape(shape) -- Robert Kern &qu

Re: [Numpy-discussion] Most efficient trim of arrays

2010-12-14 Thread Robert Kern
py. Use boolean indexing. http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#boolean -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth."   -

Re: [Numpy-discussion] truth value of dtypes

2010-12-10 Thread Robert Kern
dtype' The default truth value probably should be True, but not for this reason. The correct idiom to use is this: def f(dtype=None): if dtype is None: print 'using default dtype' -- Robert Kern "I have come to believe that the whole world is an enigma, a har

Re: [Numpy-discussion] The power of strides - Combinations

2010-12-06 Thread Robert Kern
On Mon, Dec 6, 2010 at 21:51, Benjamin Root wrote: > On Monday, December 6, 2010, Robert Kern wrote: >> On Mon, Dec 6, 2010 at 20:18, Mario Moura wrote: >>> Hi Folks >>> >>> Is it possible some example how deal with strides with combinations, let >>>

Re: [Numpy-discussion] The power of strides - Combinations

2010-12-06 Thread Robert Kern
On Mon, Dec 6, 2010 at 20:18, Mario Moura wrote: > Hi Folks > > Is it possible some example how deal with strides with combinations, let see: No, sorry. It is not possible to generate combinations just using strides. -- Robert Kern "I have come to believe that the whole world i

Re: [Numpy-discussion] printoption to allow hexified floats?

2010-12-01 Thread Robert Kern
bout the string conversion rather than about numerical differences. Unfortunately, there are still cross-platform numerical differences that are real (but are irrelevant to the validity of the code under test). Hex-printing for floats only helps a little to make doctests useful for numerical code.

Re: [Numpy-discussion] Warning: invalid value encountered in subtract

2010-11-30 Thread Robert Kern
in divide >> Out[7]: inf >> >> I have been using the orig_settings so that I can take over the >> control of this from the user and then set it back to how it was. > > Thank, Skipper. That works. Do you wrap it in a try...except? And then > raise whatever brought you

Re: [Numpy-discussion] How to export a CObject from NumPy to my own module?

2010-11-24 Thread Robert Kern
Can anyone point me in the direction of a good step-step guide og using this > api to export function pointers from NumPy to your own modules? http://docs.scipy.org/doc/numpy/user/c-info.how-to-extend.html?highlight=import_array -- Robert Kern "I have come to believe that the whole wo

Re: [Numpy-discussion] indexing question

2010-11-22 Thread Robert Kern
(1,1) which is what > I wanted. The question is: is it possible to omit the [0,1] > in the index? No, but you can write generic code for it: t[np.arange(t.shape[0]), x, y] -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is mad

Re: [Numpy-discussion] Does np.std() make two passes through the data?

2010-11-21 Thread Robert Kern
ement for > scipy.stats.nanstd. Maybe I'll have to add an asterisk to the drop-in > part. Either that, or suck it up and store the damn mean. The difference is less than eps. Quite possibly, the one-pass version is even closer to the true value than the two-pass version. -- Robert Kern

Re: [Numpy-discussion] Does np.std() make two passes through the data?

2010-11-21 Thread Robert Kern
On Sun, Nov 21, 2010 at 17:43, Keith Goodman wrote: > Does np.std() make two passes through the data? Yes. See PyArray_Std() in numpy/core/src/calculation.c -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad

Re: [Numpy-discussion] Python scalar float indices into array work - but not for array indices - why ?

2010-11-17 Thread Robert Kern
e indices makes a copy of the data. Those copies are incremented independently, then they are shoved back into the original foo array. At no point does the array know that these methods are being called because of this special combination of operators and that you want it to behave like a hist

Re: [Numpy-discussion] Python scalar float indices into array work - but not for array indices - why ?

2010-11-17 Thread Robert Kern
On Wed, Nov 17, 2010 at 13:11, Sebastian Haase wrote: > On Wed, Nov 17, 2010 at 7:48 PM, Nathaniel Smith wrote: >> On Wed, Nov 17, 2010 at 10:32 AM, Sebastian Haase >> wrote: >>> On Wed, Nov 17, 2010 at 7:26 PM, Robert Kern wrote: >>>> On Wed, Nov 17, 2

Re: [Numpy-discussion] Python scalar float indices into array work - but not for array indices - why ?

2010-11-17 Thread Robert Kern
to also allow float ndarrays then ? It only works for float scalars by accident. Do not rely on it. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth."  

Re: [Numpy-discussion] getitem and slice

2010-11-15 Thread Robert Kern
ntext: > > Say I have a 2d array-like object with axis 0 named 'space' and axis 1 > named 'time', I'd like to be able to make the following distinctions: > > a['time':2] --> a[:,2] > a['time':2:] --> a[:,2:] > > a['space&#

Re: [Numpy-discussion] Printing formatted numerical values

2010-11-15 Thread Robert Kern
able is > an object of type 'str'. How should I understand this? Does python not > understand that numpy.int32 is an integer? Correct. On a 64-bit system, numpy.int32 does not subtype from int. The format codes do strict type-checking. -- Robert Kern "I have come to believe

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

2010-11-15 Thread Robert Kern
t has some thing to do with > the operating system or JAVA!. Check your JavaScript settings. The search functionality is implemented in JavaScript. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt t

Re: [Numpy-discussion] Simple broadcasting? Or not so simple?? [SEC=UNCLASSIFIED]

2010-11-14 Thread Robert Kern
n the failing machine numpy.__version__ > returns '1.2.0'.  Machines on which the broadcasting works as I expect I see > '1.3.0' (or later) in numpy.__version__. > > Have broadcast rules changed since 1.2.0?  Or maybe I just don't understand > broadcasting?

Re: [Numpy-discussion] Change in Python/Numpy numerics with Py version 2.6 ?

2010-11-12 Thread Robert Kern
e don't touch the math module at all. That would be evil. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlyi

Re: [Numpy-discussion] Change in Python/Numpy numerics with Py version 2.6 ?

2010-11-12 Thread Robert Kern
cos to throw a Domain Exception. This does not happen > when > I use Python 2.4 with Numpy 1.0.3. acos() is not a numpy function. It comes from the stdlib math module. Python 2.6 tightened up many of the border cases for the math functions. That is probably where the behavior difference comes fr

Re: [Numpy-discussion] specifying array sizes in random vs. ones, zeros, etc

2010-11-11 Thread Robert Kern
omeone please explain? rand() and randn() were added as conveniences for people who were used to the MATLAB functions. numpy.random.random_sample((2,3)) and numpy.random.standard_normal((2,3)) are the preferred, more consistent functions to use. Ignore rand() and randn() if you like. -- Robert

Re: [Numpy-discussion] C-compiler options

2010-11-10 Thread Robert Kern
t; compiler (I don't know about the fortran compiler. Are you sure that the python executable that you are using is the 64-bit python executable that you think it is? -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by ou

Re: [Numpy-discussion] create an object array with named dtype

2010-11-04 Thread Robert Kern
7;] didn't get copied correctly when it got assigned. If you assign D[0]['n1'] and D[1]['n1'] separately, it works. [~] |12> D[0]['n1'] = A [~] |16> D[1]['n1'] = A [~] |17> D array([ ((array([[ 0.], [ 1.], [ 2.], [ 3.],

Re: [Numpy-discussion] strange behavior of ravel() and flatnonzero() on matrix

2010-11-03 Thread Robert Kern
hat they return the same subclass of ndarray that the original object is. So type(some_matrix.ravel()) is also matrix. Since matrix objects are always 2D, you get the above behavior. One could probably overwrite those methods to return ndarrays of the proper shape instead. If you are doing such shape-

Re: [Numpy-discussion] Path to numpy installation

2010-11-02 Thread Robert Kern
which python /Library/Frameworks/Python.framework/Versions/Current/bin/python > Do you think it is safe just to delete the folder > /System/Library/Frameworks/Python.framework to «uninstall» the wrong > version? No! Do not touch that! It is used by OS X. -- Robert Kern "I have com

Re: [Numpy-discussion] Precision difference between dot and sum

2010-11-01 Thread Robert Kern
on 32 bits or 64 bits? I ask because there are different > floating point precisions on the 32 bit platform and the results can depend > on how the compiler does things. Eh, what? Are you talking about the sometimes-differing intermediate precisions? I wasn't aware that was constrained t

Re: [Numpy-discussion] Path to numpy installation

2010-11-01 Thread Robert Kern
brary/Frameworks/Python.framework/Versions/Current/bin before /usr/bin. Then when you type "python", you will get this installation of Python and all of its libraries. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made te

Re: [Numpy-discussion] C extension compiling question

2010-10-29 Thread Robert Kern
> It would be really useful to have a complete example somewhere. As in, a > set of files for a minimum example that builds and runs. http://github.com/numpy/numpy/tree/master/doc/newdtype_example/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless en

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-28 Thread Robert Kern
On Thu, Oct 28, 2010 at 16:37, Ian Stokes-Rees wrote: > > > On 10/28/10 5:29 PM, Robert Kern wrote: >> On Thu, Oct 28, 2010 at 15:17, Ian Stokes-Rees >> wrote: >>> I have an ndarray with named dimensions.  I find myself writing some >>> fairly laboriou

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-28 Thread Robert Kern
__getattr__ to __getitem__? Using __getattribute__ tends to slow down almost all operations on the array substantially. Perhaps __getattr__ would work better, but all of the methods and attributes would mask the fields. If you can find a better solution that doesn't have such an impact on norm

Re: [Numpy-discussion] quadratic function

2010-10-28 Thread Robert Kern
On Thu, Oct 28, 2010 at 12:47, Brennan Williams wrote: >  On 29/10/2010 6:35 a.m., Robert Kern wrote: >> On Thu, Oct 28, 2010 at 12:33, Brennan Williams >>  wrote: >>>   On 29/10/2010 2:34 a.m., Robert Kern wrote: >>>> On Thu, Oct 28, 2010 at 06:38, Brennan

Re: [Numpy-discussion] quadratic function

2010-10-28 Thread Robert Kern
On Thu, Oct 28, 2010 at 12:33, Brennan Williams wrote: >  On 29/10/2010 2:34 a.m., Robert Kern wrote: >> On Thu, Oct 28, 2010 at 06:38, Brennan Williams >>  wrote: >>>   I have used both linear least squares and radial basis functions as a >>> proxy equatio

Re: [Numpy-discussion] quadratic function

2010-10-28 Thread Robert Kern
the different second order terms. A = np.column_stack([ np.ones_like(x), x, y, z, x*x, y*y, z*z, x*y, y*z, x*z, ]) x, res, rank, s = np.linalg.lstsq(A, f) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our ow

Re: [Numpy-discussion] The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

2010-10-27 Thread Robert Kern
> to a normal python float. But I still get this error message. > > At this point, I suspect that I'm doing something dumb, rather than > discovering some unique bug in numpy. Can anyone help me out? Can you provide a complete, self-contained example that does not work? What kind of

Re: [Numpy-discussion] function name as parameter

2010-10-20 Thread Robert Kern
gt; rather than > my_analysis.perform(optimizer='Amoeba') +11ty-billion > This lets users do introspection on the pyOpt namespace to see what > functions they can choose from, which is rather friendlier in an > interactive environment. Or implement their own without having to modify

Re: [Numpy-discussion] function name as parameter

2010-10-20 Thread Robert Kern
nstantiate, typically > passed as an argument by the client code/user..... Example? -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underl

Re: [Numpy-discussion] Using issubdtype to check integer types

2010-10-14 Thread Robert Kern
type is np.unsignedinteger: |3> np.issubdtype(np.uint16, np.unsignedinteger) True -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an u

Re: [Numpy-discussion] AttributeError: 'module' object has no attribute 'parse'

2010-10-14 Thread Robert Kern
> AttributeError: 'module' object has no attribute 'parse' You have a local module named parser.py . This is interfering with the local "import parser" in compiler/transformer.py . Rename your module or execute numpy.test() from somewhere else. This is not a bug in n

Re: [Numpy-discussion] equality of empty arrays

2010-10-12 Thread Robert Kern
" As a wiki, it will automatically be "official". -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth."   -- Umberto Eco ___

Re: [Numpy-discussion] ndarray of object dtype

2010-10-07 Thread Robert Kern
oat wl; >        int cssid; >        int br; > }hm1dval1; > > to an element of this array > I get the array object, i can see the fields. The type of the array > elements is Pyarray_VOID > > however following code gives me a segfault > > hm1dval1 **s = PyArray_DATA(ao); Sin

Re: [Numpy-discussion] Assigning complex value to real array

2010-10-07 Thread Robert Kern
mpatibly. There is not only too much code in numpy to rewrite, but a ton of other code that we do not maintain that relies on our current memory model. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt

Re: [Numpy-discussion] ndarray of object dtype

2010-10-04 Thread Robert Kern
      c.set_values(q=3.0, wl=2.5, cssid=6, br=7) > > > So following code should be valid in C: > > hm1dval s* = PyArray_DATA(array); > > but the members are 0 after casting in spite they were set previously. The elements of a dtype=object array are PyObject* pointers. In C, an array of poi

Re: [Numpy-discussion] NPZ format

2010-10-02 Thread Robert Kern
On Sat, Oct 2, 2010 at 22:10, David Warde-Farley wrote: > On 2010-10-01, at 7:22 PM, Robert Kern wrote: > >> Also some design, documentation, format version bump, and (not least) >> code away. ;-) > > Would it require a format version number bump? I thought that was a .NPY

Re: [Numpy-discussion] NPZ format

2010-10-01 Thread Robert Kern
On Fri, Oct 1, 2010 at 02:13, Francesc Alted wrote: > A Thursday 30 September 2010 18:20:16 Robert Kern escrigué: >> On Wed, Sep 29, 2010 at 03:17, Francesc Alted > wrote: >> > Hi, >> > >> > I'm going to give a seminar about serialization, and I

Re: [Numpy-discussion] constant shaded triangle mesh in mayavi2

2010-10-01 Thread Robert Kern
On Thu, Sep 30, 2010 at 23:04, Geoffrey Irving wrote: > On Fri, Oct 1, 2010 at 11:39 AM, Robert Kern wrote: >>  s = mlab.pipeline.triangular_mesh_source(x,y,z,triangles) >>  s.data.cell_data.scalars = # Your data here. >>  surf = mlab.pipeline.surface(s) >>  su

Re: [Numpy-discussion] constant shaded triangle mesh in mayavi2

2010-09-30 Thread Robert Kern
On Thu, Sep 30, 2010 at 16:26, Geoffrey Irving wrote: > On Fri, Oct 1, 2010 at 10:18 AM, Robert Kern wrote: >> On Thu, Sep 30, 2010 at 16:00, Geoffrey Irving wrote: >>> On Fri, Oct 1, 2010 at 9:38 AM, Robert Kern wrote: >>>> On Thu, Sep 30, 2010 at 15:30, Geoff

Re: [Numpy-discussion] constant shaded triangle mesh in mayavi2

2010-09-30 Thread Robert Kern
On Thu, Sep 30, 2010 at 16:00, Geoffrey Irving wrote: > On Fri, Oct 1, 2010 at 9:38 AM, Robert Kern wrote: >> On Thu, Sep 30, 2010 at 15:30, Geoffrey Irving wrote: >>> Hello, >>> >>> I'm not sure where the correct place to ask questions about Mayavi,

Re: [Numpy-discussion] constant shaded triangle mesh in mayavi2

2010-09-30 Thread Robert Kern
t, unfortunately. The only way I have found is to assign UV texture coordinates to the vertices and slap on a texture. Assigning the UV coordinates is usually not easy. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by o

Re: [Numpy-discussion] NPZ format

2010-09-30 Thread Robert Kern
have any code that actually does it. Most likely the author assumed that it would be faster (or tested it to be faster with their CPU/hard disk configuration) to not compress. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrib

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Robert Kern
On Wed, Sep 29, 2010 at 20:11, wrote: > On Wed, Sep 29, 2010 at 9:03 PM, Damien Morton wrote: >> On Thu, Sep 30, 2010 at 3:28 AM, Robert Kern wrote: >>> On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: >>>> Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Robert Kern
On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: > Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: > [clip: inplace addition with duplicates] >> Use numpy.bincount() instead. > > It might be worthwhile to add a separate helper function for this > purpose. Bincount ma

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Robert Kern
+= y" idiom in order to do something different to achieve the semantics you want. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth."   -- Umber

Re: [Numpy-discussion] mean of empty sequence gives nan

2010-09-27 Thread Robert Kern
/ len([]) -> 0.0 / 0 -> nan, so yes. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth."   -- Umberto Eco ___

Re: [Numpy-discussion] constructing an array from memory

2010-09-24 Thread Robert Kern
interface self.base = base Constructor information: Definition: np.lib.stride_tricks.DummyArray(self, interface, base=None) Then np.asarray() will consume that object to make an ndarray that references the given memory. -- Robert Kern "I have come to believe that the whole wor

Re: [Numpy-discussion] printable random seed ?

2010-09-22 Thread Robert Kern
On Wed, Sep 22, 2010 at 10:48, wrote: > On Wed, Sep 22, 2010 at 10:34 AM, Robert Kern wrote: >> On Wed, Sep 22, 2010 at 09:27,   wrote: >>> I would like to generate random numbers based on a random seed, for >>> example what numpy.random does if the seed is not spec

Re: [Numpy-discussion] searching binary data

2010-09-22 Thread Robert Kern
y (using buffer=). > > But, how to then efficiently find a sequence? mmap objects have most of the usual string methods: [~] |2> f = open('./scratch/foo.py', 'r+b') [~] |4> m = mmap.mmap(f.fileno(), 0) [~] |6> m.find('import') 11 [~] |7> m[11:1

Re: [Numpy-discussion] printable random seed ?

2010-09-22 Thread Robert Kern
33437794758841e-288) > Alternatively, what's a good way to  randomly generate an initial > state? np.random.RandomState() will do the best thing on each platform. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible b

Re: [Numpy-discussion] real and imag functions should produce errors for object arrays

2010-09-21 Thread Robert Kern
On Tue, Sep 21, 2010 at 17:40, Pauli Virtanen wrote: > Tue, 21 Sep 2010 17:28:08 -0500, Robert Kern wrote: > [clip] >>> *that* == return a complex number from .real >> >> What is the alternative? I'm personally happy with saying that many of >> the operations

Re: [Numpy-discussion] real and imag functions should produce errors for object arrays

2010-09-21 Thread Robert Kern
> It probably shouldn't do *that* at the least. > > *that* == return a complex number from .real What is the alternative? I'm personally happy with saying that many of the operations we define on numpy arrays can be done because we know the types and that object arrays subvert th

Re: [Numpy-discussion] Question about masked arrays

2010-09-20 Thread Robert Kern
reason that np.mean() gives the same result as np.ma.mean() is that it simply defers to the .mean() method on the object, so it works as expected on a masked array. Many other functions will not. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigm

Re: [Numpy-discussion] buffer arg to ndarray

2010-09-17 Thread Robert Kern
m = mmap.mmap(f.fileno(), 0) In [23]: buffer(m) Out[23]: -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth."   -- Umberto Eco _

Re: [Numpy-discussion] Can we freeze the subversion repository and move to github this week?

2010-09-15 Thread Robert Kern
ollowing contents: > > *.o > *.a > *.pyc > *.swp > *~ > build *.pyo *.so *.pyd .gdb_history dist -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret

Re: [Numpy-discussion] [OT: MATLAB] Any way to globally make Matlab struct attributes Python-property-like

2010-09-13 Thread Robert Kern
On Mon, Sep 13, 2010 at 21:24, David Goldsmith wrote: > (Sorry for the OT post; I thought I'd get a more sympathetic response > here than on the MATLAB lists.) ;) I'm sorry, but that's *really* off-topic. -- Robert Kern "I have come to believe that the whole worl

<    2   3   4   5   6   7   8   9   10   11   >