On Tuesday 16 October 2007 11:47:35 Sebastian Haase wrote:
Hi,
there is a way of doing this. As far as I know, you have to create
your own version of numpy arrays. E. g. try this:
...
Be carefull that some (many / most ?) operations on that array will
return you a normal numpy array again.
On Thursday 04 October 2007 13:08:08 David M. Cooke wrote:
Alan G Isaac [EMAIL PROTECTED] writes:
To help me understand, might someone offer some examples of
NumPy names that really should be changed?
Internal classes, like:
- masked_unary_operation, etc. in numpy/core/ma.py
FYI, the new
All,
I'm starting to update the documentation of maskedarray to the latest
standard.
How should I represent the default value of an optional parameter ?
I was thinking something like
def function(a, value=None)
Does something
*Parameters*:
a : {ndarray}
Input array.
value :
All,
The latest version of maskedarray has just been released on the scipy SVN
sandbox. This version fixes the inconsistencies in filling (see below) and
introduces some minor modifications for optimization purposes (see below as
well). Many thanks to Eric Firing and Matt Knox for the fruitful
On Monday 27 August 2007 14:09:33 Christopher Barker wrote:
This is the best bet, or we could call the new one ma, and the old one
ma_old. In any case, the old one needs to stick around until the new one
has been fully tested for compatibility (and otherwise).
That shouldn't be a pb, the
On Saturday 25 August 2007 15:48:00 Eric Firing wrote:
I've made a couple of small emergency edits, but a separate page would
make things much more visible and less confusing.
So here it is:
http://projects.scipy.org/scipy/numpy/wiki/MaskedArrayAlternative
Please note the section : Optimizing
On Saturday 25 August 2007 12:50:38 Eric Firing wrote:
Alexander Michael wrote:
Is there any documentation available for your maskedarray?
Pierre wrote some notes about maskedarray here:
http://projects.scipy.org/scipy/numpy/wiki/MaskedArray
starting half-way down the page.
Please note
On Saturday 25 August 2007 15:48:00 Eric Firing wrote:
I've made a couple of small emergency edits, but a separate page would
make things much more visible and less confusing.
So here it is:
http://projects.scipy.org/scipy/numpy/wiki/MaskedArrayAlternative
Please note the section : Optimizing
All,
Using the maskedarray package:
import maskedarray as ma
x = numpy.array([1,numpy.nan,3])
y = numpy.array([1,numpy.nan,3])
ma.allclose(ma.array(x,mask=numpy.isnan(x)),ma.array(y,mask=numpy.isnan(y)) )
True
or even simpler:
maskedarray.testutils.assert_equal(x,y)
All,
As you might be aware, there are currently two concurrent implementations of
masked arrays in numpy:
* numpy.ma is the official implementation, but it is unclear whether it is
still actively maintained.
* maskedarray is the alternative I've been developing initially for my own
purpose
On Monday 25 June 2007 05:12:01 Jesper Larsen wrote:
Hi numpy users,
I have a masked array. I am looping over the elements of this array and
sometimes want to set a value to missing. Normally this can be done by:
myarray.mask[i] = True
Mmh. Experience shows that directly accessing the mask
On Monday 25 June 2007 10:14:21 Jesper Larsen wrote:
Hi Pierre and others,
I was not aware that the way to use masked arrays was as you describe. I
thought you had to somehow modify the mask (but the method you describe is
of course much more elegant). Thanks for answering my very basic
On Thursday 14 June 2007 09:19:06 John Hunter wrote:
On 6/13/07, Pierre GM [EMAIL PROTECTED] wrote:
Have you tried mrecords, in the alternative maskedarray package available
on the scipy SVN ?
I would be happy to try this out -- do you happen to have an example
that shows how to set
Lorenzo,
you can indeed use f2py to write extensions around some C code:
http://cens.ioc.ee/projects/f2py2e/usersguide/index.html
http://www.scipy.org/Cookbook/f2py_and_NumPy
I think you should also be able to find some actual examples in the scipy
sources...
n Thursday 17 May 2007 04:54:22 Travis Oliphant wrote:
I'm inclined to move his masked array over to ma wholesale. The fact
that Pierre sees it as his baby is very important to me.
Well, all the credits should go to Paul Dubois, the original author of
numpy.core.ma, and the scores of people
In addition to Matt's answer:
Yes, we have a tmulti where you can store dates and other variables in a
record-like TimeSeries.
However, there must be simpler:
Why are you using getattr to access the fields ? Your object tr is a record
array, so you could use
for n in tr.dtype.names:
print
On Tuesday 15 May 2007 17:34:15 Charles R Harris wrote:
I see no one answered ;) I think it is traditional behaviour from Numeric,
so can't be changed without a bit of thought.
Why not file a ticket for the
1.1 release and see how folks respond?
I'll try to.
Is there any reason why you
On Wednesday 09 May 2007 08:54:37 Bernhard Voigt wrote:
I'm trying to subclass ndarray or recarray to build a record array that has
a dictionary with a mapping of keys to array indexes and vice versa.
Bernhard,
Could you send me the rest of your code ? I'd like to test a couple of things
Mark,
In your example:
b = asarray(3,'d')
b is really a numpy scalar, so it doesn't have a length. But it does have a
size (1) and a ndim (0).
If you need to have arrays with a length, you can force the array to have a
dimension 1 with atleast_1d(b) or array(b,copy=False,ndmin=1)
On Wednesday 02 May 2007 10:00:58 Charles R Harris wrote:
On 5/2/07, Pierre GM [EMAIL PROTECTED] wrote:
Mark,
Or just array([1],'d')
Except that in that case you need to know in advance the input is a scalar to
put it in a list. The atleast_1d should work better on any input
On Wednesday 02 May 2007 11:39:29 Francesc Altet wrote:
El dc 02 de 05 del 2007 a les 09:52 -0400, en/na Pierre GM va escriure:
In your example:
b = asarray(3,'d')
b is really a numpy scalar, so it doesn't have a length. But it does have
a size (1) and a ndim (0).
Just one
On Wednesday 02 May 2007 14:15:06 Fernando Perez wrote:
On 5/2/07, Darren Dale [EMAIL PROTECTED] wrote:
I know Numeric is no longer supported, but I just upgraded to python-2.5
and now I'm having problems indexing Numeric arrays:
Fine on 32-bit ubuntu, using Python 2.5:
But I think that
On Wednesday 02 May 2007 14:45:40 Christopher Barker wrote:
Pierre GM wrote:
If you need your inputs to be array or scalar and stay that way
It didn't sound like the OP wanted that. I suspect that what is wanted
if for to always be a 1-d array (i.e. vector). To do that, I'd do:
I beg
On Monday 23 April 2007 10:37:57 Mark.Miller wrote:
Greetings:
In some of my code, I need to use large matrix of random numbers that
meet specific criteria (i.e., some random numbers need to be removed and
replaces with new ones).
I have been working with .any() and .where() to facilitate
Have you tried nonzero() ?
Nonzero isn't quite what I'm after, as the tests are more complicated
than what I illustrated in my example.
Tests such as (a0)(b1) will give you arrays of booleans. The nonzero give
you where the two conditions are met (viz, where the results is True, or 1)
When you say no python temps I guess you mean, no temporary
*variables*? If I understand correctly, this allocates a temporary
boolean array to hold the result of a0.
Indeed, hence my precising no *python* temps. There still be a tmp created
at one point or another (if I'm not mistaken)
On Monday 23 April 2007 13:36:26 Christopher Barker wrote:
Gael Varoquaux wrote:
Unless I miss something obvious a.reshape() doesn't modify a, which is
somewhat missleading, IMHO.
quite correct. .reshape() creates a new array that shared data with the
original:
Mmh. My understanding is
On Wednesday 11 April 2007 18:12:16 Matthew Koichi Grimes wrote:
Is there any way to detect whether one array is a view into another
array? I'd like something like:
arr = N.arange(5)
subarr = arr[1:3]
sharesdata(arr, subarr)
Mmh, would arr.flags['OWNDATA'] would do the trick ?
p.
On Monday 09 April 2007 06:28:33 Miquel Poch wrote:
T is a matrix and the rest of the variables are floats. I don't know why
are this '.' in the expresion, and that's why I can't translate it.
http://www.scipy.org/NumPy_for_Matlab_Users
The .* means: element-wise multiplitcation.
I tried to
On Friday 06 April 2007 12:14:20 Giorgio F. Gilestro wrote:
Is there any way I could get a 1D array (no tuples please!) directly
from the file?
(BTW numpy.core.records.fromstring gives the same output)
numpy.core.records.fromfile (filename, formats='i2', byteorder='big')['f0']
With
On Friday 30 March 2007 16:26:26 Robert Kern wrote:
True, not every
two-liner should be in the core, but very-frequently-used two-liners that
state the authors intent clearer can have a good case made for them.
Fair enough, I'll keep that in mind.
Thanks again!
On Friday 30 March 2007 17:43:42 Bill Baxter wrote:
Actually I
didn't realize that it had a loop in it, so thanks for pointing that
out. I thought it was just and alias for array with some args.
I just realized that myself, going directly in the sources: that's how I found
that the ndmin
On Thursday 29 March 2007 12:04:51 Bryce Hendrix wrote:
I spoke too soon, this code fails with the example you gave:
mmh, I tried to use the class you linked to last time: the only modifications
I gave are listed below
class UnitArray(numpy.ndarray):
__array_priority__ = 10.0
On Thursday 29 March 2007 13:47:48 Bryce Hendrix wrote:
doh! I followed the example on the Wiki which does not define the class
attribute in the class scope, but in __new__. Adding the declaration to
the class scope seems to work.
Yeah, sorry about that, I really should update this wiki page.
On Thursday 29 March 2007 14:09:38 Bryce Hendrix wrote:
I really should widen my tests before proclaiming success... If you
change the default units to feet, the result of concatenating two
UnitArrays instances with meters units is a UnitArray with feet.
Not a surprise at all, and I should
On Thursday 29 March 2007 14:40:35 Bryce Hendrix wrote:
Yup, we've decided to write custom concatenate where methods. Thanks
for all the help.
Don't mention it, my pleasure.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
All,
I could swear that I ran once into a numpy (or scipy) function that output the
unique values of a 1d ndarray along with the number of occurences of each
element. If I'm not completely mistaken, it 's a private function initially
in Fortran.
Does this ring a bell to anyone ? Where could I
Zach,
There's unique and unique1d, but these don't output the number of
occurences.
There's also bincount, which outputs the number of each element, but
includes zeros for non-present elements and so could be problematic
for certain data.
Well, I found it anyway. As I was pretty sure it was
On Tuesday 27 March 2007 20:08:04 Bryce Hendrix wrote:
We have a class which is a subclass of ndarray which defines
__array_finalize__ to add an attribute. The class looks something like
this:
Ahah, we ran into this problem a few months ago:
You should not initialize your units attribute in
On Tuesday 20 March 2007 18:57:18 Robert Kern wrote:
Is there an init_loess function in cloess.c? If cloess.c was created by
Pyrex from cloess.pyx, then Pyrex will make an initcloess function. The
module name needs to be consistent throughout.
Ahah, that was the problem. Thanks a lot Robert,
All,
I'm trying to write a numpy.distutils setup.py for a pyrex module that
involves both external C and fortran sources, and where the fortran sources
need to be linked w/ blas and lapack. Here's what I have so far:
##
def
On Tuesday 20 March 2007 17:46:28 Robert Kern wrote:
The first file in the sources list should be the one that actually
implements the module, i.e. the C file generated by Pyrex. FORTRAN files
specified after the first one won't be processed by f2py.
Mmh. I had to get rid of the '*.pyx' and
On Friday 09 March 2007 14:41:23 lechtlr wrote:
I would very much appreciate, if someone can give suggestions to
implement a loop to generate a string in the following format. Variables
with assigned values are given in A:
A = {a1:2.0, a2:4.0,
,an:5.0}
I want to transform what
On Friday 23 February 2007 14:53:05 Zachary Pincus wrote:
Scipy's ndimage module has a function that takes a generic callback
and calls it with the values of each neighborhood (of a given size,
and optionally with a particular mask footprint) centered on each
array element. That function
Stefan,
Travis checked numpy/doc/HOWTO_DOCUMENT.txt a couple of days ago.
Excellent, just what I needed. Thanks for the info
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
On Wednesday 07 February 2007 23:09:16 Travis Oliphant wrote:
So, there's no real point in using the Python 'id' function ? Do we need
a shortcut to __array_interface__['data'] as id number ?
You have it (sort of a short-cut).
.ctypes.data
OK, great, thanks a lot
On Wednesday 07 February
On Thursday 08 February 2007 16:21:09 [EMAIL PROTECTED] wrote:
I'm very surprised by the line noted. I always thinking that the input
variable didn't change the variable itself outside the function.
Except that in this particular case, you explicitly change the input array
itself by using
On Thursday 01 February 2007 18:48:56 Travis Oliphant wrote:
What is the attitude of this group about the ndarray growing some class
methods?
ndarray.frombuffer
ndarray.fromfile
Sounds great. But what would really make my semester is to have
ndarray.__new__ accept optional keywords (as
On Monday 22 January 2007 11:18, Francesc Altet wrote:
You should first inform to Pyrex about the definition of ndarray. For
this, it's only necessary to declare this in a file (say
definitions.pxd):
from now on, Pyrex knows about the ndarray object and you should be able
to derive a class
However, even record
arrays don't have a keys() method.
You can access the attributes of a recarray by
N.ndarray.__getattribute__(obj,'dtype').fields
which is yet another dictproxy.
Some context: the type of introspection I'm often wishing I could do
in a single, easy command usually has
On Wednesday 03 January 2007 23:57, Matthew Koichi Grimes wrote:
Pierre GM wrote:
On Wednesday 03 January 2007 15:39, Matthew Koichi Grimes wrote:
As per Stefan's help, I've made a subclass of recarray called nnvalue.
It just fixes the dtype to [('x', 'f8'), ('dx', 'f8'), ('delta', 'f8
On Thursday 21 December 2006 16:10, Travis Oliphant wrote:
I much prefer to make SciPy an easy install for as many people as
possible and/or work on breaking up SciPy into modular components that
can be installed separately if needed.
Talking about that, what happened to these projects of
On Wednesday 20 December 2006 18:02, Tom Denniston wrote:
If you want the n largest item i would recommend quicksort
...
I don't know of a way to do this in numpy. I think it would require
adding a cfunction to numpy. Perhaps an argnth function?
Does anyone else know of an existing
On Saturday 16 December 2006 19:55, Colin J. Williams wrote:
Colin,
First of all, a disclaimer: I'm a (bad) hydrologist, not a computer scientist.
I learned python/numpy by playing around, and really got into subclassing
since 3-4 months ago. My explanations might not be completely accurate,
On Wednesday 13 December 2006 15:29, A. M. Archibald wrote:
Generate an axis-permutation tuple and use transpose:
Ah OK. It took me a little while to get it running: instead of
s=list(A.shape)
in your example, one should read
s=range(A.ndim)
But it does the trick, thanks a lot!
And now,
+1 for a change. I'm not using the current implementation. Since it was
undocumented, I prefered coding my own.
Same case as David. I found it easier to code something with FFTs than trying
to understand what was going on.
___
Numpy-discussion
On Tuesday 12 December 2006 19:02, Charles R Harris wrote:
Hi all,
I'm curious about the error thrown when I use a.T as the left side of a
multiply assign. I
Chuck, if you keep in mind that .T is a shortcut for .transpose(), you'll
understand why you can't assign to a function call.
On Friday 01 December 2006 17:56, Keith Goodman wrote:
...
Would it break anything to change the first line of the nan functions from
a = array(a)
to
a = asanyarray(a)
?
Seeing what the nan functions do, I don't think that would be a problem. An
expception would be raised if the operation
Folks,
Is there any reason why `apply_along_axis`, `apply_over_axes` (and I expect
`vectorize` as well, but I haven't tried) won't accept subclasses of
ndarrays ?
Would it be possible to use `asanyarray` instead of `asarray` in those
functions ?
Oh, and I ran into some problems with
601 - 659 of 659 matches
Mail list logo