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:
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:
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/652de683df845c20ee1bf88a299e80c9.jpg?s=120&d=mm&r=g)
Todd Miller wrote:
I meant exactly what you said. But:
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.
![](https://secure.gravatar.com/avatar/c3fbc70c6e7101b4905799649b5572e7.jpg?s=120&d=mm&r=g)
On Mon, 20 Jun 2005, Piotr Luszczek wrote:
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:
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/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:
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:
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/652de683df845c20ee1bf88a299e80c9.jpg?s=120&d=mm&r=g)
Todd Miller wrote:
I meant exactly what you said. But:
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.
![](https://secure.gravatar.com/avatar/c3fbc70c6e7101b4905799649b5572e7.jpg?s=120&d=mm&r=g)
On Mon, 20 Jun 2005, Piotr Luszczek wrote:
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:
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
participants (6)
-
Colin J. Williams
-
Joost van Evert
-
Perry Greenfield
-
Piotr Luszczek
-
Rick White
-
Todd Miller