numarray - silent truncation of complex values
![](https://secure.gravatar.com/avatar/b24e93182e89a519546baa7bafe054ed.jpg?s=120&d=mm&r=g)
Todd, This is to suggest that further consideration be given to this bug. As a minimum, I would suggest that the truncation be clearly documented but it would be better handled in the Python manner. Please see: http://sourceforge.net/tracker/index.php?func=detail&aid=1216688&group_id=1369&atid=450446 Regards, Colin W.
![](https://secure.gravatar.com/avatar/652de683df845c20ee1bf88a299e80c9.jpg?s=120&d=mm&r=g)
All, I apologize if this is a dupe. I haven't seen it where I looked. There is numarray.numeric.histogram and numarray.mlab.histogram. What they do is this (more or less): for idx in arr: histogram[idx] += 1 What I want to do is: for idx in arr: result[idx] ^= value Doing: result[arr] ^= value doesn't work. Which is not surprising because: histogram[arr] += 1 doesn't work either. My question is whether there is a way to do it (the XOR example) without using a for loop. Thanks, Piotr
![](https://secure.gravatar.com/avatar/c7976f03fcae7e1199d28d1c20e34647.jpg?s=120&d=mm&r=g)
On Jun 20, 2005, at 3:09 PM, Piotr Luszczek wrote:
All,
I apologize if this is a dupe. I haven't seen it where I looked.
There is numarray.numeric.histogram and numarray.mlab.histogram. What they do is this (more or less):
for idx in arr: histogram[idx] += 1
What I want to do is:
for idx in arr: result[idx] ^= value
Doing:
result[arr] ^= value
doesn't work. Which is not surprising because:
histogram[arr] += 1
doesn't work either.
My question is whether there is a way to do it (the XOR example) without using a for loop.
Thanks,
Piotr
Not that I'm aware of. It suggests that there may be a need to expand on the histogram-like functionality to handle this sort of thing, though I wonder how often it would be used. Perry Greenfield
![](https://secure.gravatar.com/avatar/652de683df845c20ee1bf88a299e80c9.jpg?s=120&d=mm&r=g)
Perry Greenfield wrote:
On Jun 20, 2005, at 3:09 PM, Piotr Luszczek wrote:
All,
I apologize if this is a dupe. I haven't seen it where I looked.
There is numarray.numeric.histogram and numarray.mlab.histogram. What they do is this (more or less):
for idx in arr: histogram[idx] += 1
What I want to do is:
for idx in arr: result[idx] ^= value
Doing:
result[arr] ^= value
doesn't work. Which is not surprising because:
histogram[arr] += 1
doesn't work either.
My question is whether there is a way to do it (the XOR example) without using a for loop.
Thanks,
Piotr
Not that I'm aware of. It suggests that there may be a need to expand on the histogram-like functionality to handle this sort of thing, though I wonder how often it would be used.
Sparse matrix computations use indirection all the time. And being able to the calculations in C and in-place would be a good thing. But then again I don't know if many numarray users use sparse matrices rather than just make the matrix dense and use LAPACK.
![](https://secure.gravatar.com/avatar/faf9400121dca9940496a7473b1d8179.jpg?s=120&d=mm&r=g)
On Mon, 2005-06-20 at 15:36, Piotr Luszczek wrote:
Perry Greenfield wrote:
On Jun 20, 2005, at 3:09 PM, Piotr Luszczek wrote:
All,
I apologize if this is a dupe. I haven't seen it where I looked.
There is numarray.numeric.histogram and numarray.mlab.histogram. What they do is this (more or less):
for idx in arr: histogram[idx] += 1
What I want to do is:
for idx in arr: result[idx] ^= value
Doing:
result[arr] ^= value
doesn't work. Which is not surprising because:
histogram[arr] += 1
doesn't work either.
My question is whether there is a way to do it (the XOR example) without using a for loop.
I may be misreading your intent, but here's what I get:
a = na.zeros((10,)) a[[1,3,5]] ^= 100 a array([ 0, 100, 0, 100, 0, 100, 0, 0, 0, 0])
It seems to work to me. What is it that you meant? Regards, Todd
Thanks,
Piotr
Not that I'm aware of. It suggests that there may be a need to expand on the histogram-like functionality to handle this sort of thing, though I wonder how often it would be used.
Sparse matrix computations use indirection all the time. And being able to the calculations in C and in-place would be a good thing. But then again I don't know if many numarray users use sparse matrices rather than just make the matrix dense and use LAPACK.
------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion --
![](https://secure.gravatar.com/avatar/652de683df845c20ee1bf88a299e80c9.jpg?s=120&d=mm&r=g)
Todd Miller wrote:
On Mon, 2005-06-20 at 15:36, Piotr Luszczek wrote:
Perry Greenfield wrote:
On Jun 20, 2005, at 3:09 PM, Piotr Luszczek wrote:
All,
I apologize if this is a dupe. I haven't seen it where I looked.
There is numarray.numeric.histogram and numarray.mlab.histogram. What they do is this (more or less):
for idx in arr: histogram[idx] += 1
What I want to do is:
for idx in arr: result[idx] ^= value
Doing:
result[arr] ^= value
doesn't work. Which is not surprising because:
histogram[arr] += 1
doesn't work either.
My question is whether there is a way to do it (the XOR example) without using a for loop.
I may be misreading your intent, but here's what I get:
a = na.zeros((10,)) a[[1,3,5]] ^= 100 a
array([ 0, 100, 0, 100, 0, 100, 0, 0, 0, 0])
It seems to work to me. What is it that you meant?
I meant exactly what you said. But:
a=na.zeros((10,)) a[[1,3,5,3]] ^= 100 a array([ 0, 100, 0, 100, 0, 100, 0, 0, 0, 0])
So provided that indices are unique - it works. If indices are not unique, then the last operation on the index prevails (I think). Functionality like this is the most useful only for commutative and associative operators so that numarray has freedom to reorder the computation at will for duplicates.
Regards, Todd
Thanks,
Piotr
Not that I'm aware of. It suggests that there may be a need to expand on the histogram-like functionality to handle this sort of thing, though I wonder how often it would be used.
Sparse matrix computations use indirection all the time. And being able to the calculations in C and in-place would be a good thing. But then again I don't know if many numarray users use sparse matrices rather than just make the matrix dense and use LAPACK.
![](https://secure.gravatar.com/avatar/c3fbc70c6e7101b4905799649b5572e7.jpg?s=120&d=mm&r=g)
On Mon, 20 Jun 2005, Piotr Luszczek wrote:
There is numarray.numeric.histogram and numarray.mlab.histogram. What they do is this (more or less):
for idx in arr: histogram[idx] += 1
What I want to do is:
for idx in arr: result[idx] ^= value
My question is whether there is a way to do it (the XOR example) without using a for loop.
Is value the same for every idx? That's the way you've written it. If so, you could simply do this: result = (mlab.histogram(idx) & 1)*value I'm guessing that you want value to be an array of the same size as idx though, in which case this would not work. Rick
![](https://secure.gravatar.com/avatar/652de683df845c20ee1bf88a299e80c9.jpg?s=120&d=mm&r=g)
Rick White wrote:
On Mon, 20 Jun 2005, Piotr Luszczek wrote:
There is numarray.numeric.histogram and numarray.mlab.histogram. What they do is this (more or less):
for idx in arr: histogram[idx] += 1
What I want to do is:
for idx in arr: result[idx] ^= value
My question is whether there is a way to do it (the XOR example) without using a for loop.
Is value the same for every idx? That's the way you've written it. If so, you could simply do this:
result = (mlab.histogram(idx) & 1)*value
I'm guessing that you want value to be an array of the same size as idx though, in which case this would not work.
Yes it makes a difference whether value is a single value or an array. In my case `value' is an array but I think your solution would work as well if there are no duplicates in `idx'. In my case there are duplicates in `idx' so `& 1' part would yield a funny result. Piotr
![](https://secure.gravatar.com/avatar/cd1e42e08e72711ad93d1e376ff26df4.jpg?s=120&d=mm&r=g)
Hello, does anyone know why it is not possible to create a memmap beyond a certain length. For example: m = MM.open('/tmp/test','write',len=500000000) works, while the same command using a length of 600000000 gives the following error message: /shannon/joost/lib/python/numarray/memmap.py in __init__(self, filename, mode, len) 299 else: 300 acc = mmap.ACCESS_WRITE --> 301 self._mmap = mmap.mmap(file.fileno(), len, access=acc) 302 else: 303 self._mmap = None EnvironmentError: [Errno 22] Invalid argument I am using: - numarray version 1.3.1 - python 2.4.1 - linux Greetings, Joost
![](https://secure.gravatar.com/avatar/faf9400121dca9940496a7473b1d8179.jpg?s=120&d=mm&r=g)
On Fri, 2005-07-01 at 07:39, Joost van Evert wrote:
Hello,
does anyone know why it is not possible to create a memmap beyond a certain length. For example: m = MM.open('/tmp/test','write',len=500000000) works, while the same command using a length of 600000000 gives the following error message:
/shannon/joost/lib/python/numarray/memmap.py in __init__(self, filename, mode, len) 299 else: 300 acc = mmap.ACCESS_WRITE --> 301 self._mmap = mmap.mmap(file.fileno(), len, access=acc) 302 else: 303 self._mmap = None
EnvironmentError: [Errno 22] Invalid argument
I am using: - numarray version 1.3.1 - python 2.4.1 - linux
I'm not sure it matters, but how much RAM and swap do you have? How much free space do you have on /tmp? Regards, Todd
participants (6)
-
Colin J. Williams
-
Joost van Evert
-
Perry Greenfield
-
Piotr Luszczek
-
Rick White
-
Todd Miller