
Quoting from numdoc.pdf, dated March 31, 2001, in section "Creating an array from a function: fromfunction()"
This is wholly incorrect. apply() does not call a function for each element in the sequence, apply calls a function exactly *once*, using the elements of the sequence for arguments. Also, that same section of the documentation refers to "the first example below [...] works" and "the second array [...] fails", but there is only one example, which apparently is the failing one (as it's named "buggy"). Having a *working* example would be nice. =) Perhaps this is a formatting glitch in the documentation processor, but I couldn't find the documentation's source format. and then... there's always the possibility that I'm barking up the wrong tree. What I'm trying to achieve is this: I've got a function which, given a vector describing a point in n-dimensional space, returns a value for that point. I want a matrix of the shape I specify, filled these values, with the array indicies as coordinates for the points. Is that too much to ask? ;) Thanks, - Kevin Turner [using Python version 2.0, PyNum 19.0.0] -- Kevin Turner <acapnotic@users.sf.net> | OpenPGP encryption welcome here http://www.purl.org/wiki/python/KevinTurner

A previous report of this doc error had caused me to fix it in my copy but it hadn't made it up to the web yet. The section has been redone to make it clearer, I hope. I am in the process of doing the update now. The documentation source is not available to you. Conventional use of fromfunction is like this:
For your use, you need a "helper" function. Suppose g is your function.
def g(x): return x[0] + x[1]**2
def helper (x, y): return g([x,y])
Of course, you can use a lambda to avoid explicity creating the helper.
Quoting from numdoc.pdf, dated March 31, 2001, in section "Creating an array from a function: fromfunction()"
This is wholly incorrect. apply() does not call a function for each element in the sequence, apply calls a function exactly *once*, using the elements of the sequence for arguments. Also, that same section of the documentation refers to "the first example below [...] works" and "the second array [...] fails", but there is only one example, which apparently is the failing one (as it's named "buggy"). Having a *working* example would be nice. =) Perhaps this is a formatting glitch in the documentation processor, but I couldn't find the documentation's source format. and then... there's always the possibility that I'm barking up the wrong tree. What I'm trying to achieve is this: I've got a function which, given a vector describing a point in n-dimensional space, returns a value for that point. I want a matrix of the shape I specify, filled these values, with the array indicies as coordinates for the points. Is that too much to ask? ;) Thanks, - Kevin Turner [using Python version 2.0, PyNum 19.0.0] -- Kevin Turner <acapnotic@users.sf.net> | OpenPGP encryption welcome here http://www.purl.org/wiki/python/KevinTurner _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion

A previous report of this doc error had caused me to fix it in my copy but it hadn't made it up to the web yet. The section has been redone to make it clearer, I hope. I am in the process of doing the update now. The documentation source is not available to you. Conventional use of fromfunction is like this:
For your use, you need a "helper" function. Suppose g is your function.
def g(x): return x[0] + x[1]**2
def helper (x, y): return g([x,y])
Of course, you can use a lambda to avoid explicity creating the helper.
Quoting from numdoc.pdf, dated March 31, 2001, in section "Creating an array from a function: fromfunction()"
This is wholly incorrect. apply() does not call a function for each element in the sequence, apply calls a function exactly *once*, using the elements of the sequence for arguments. Also, that same section of the documentation refers to "the first example below [...] works" and "the second array [...] fails", but there is only one example, which apparently is the failing one (as it's named "buggy"). Having a *working* example would be nice. =) Perhaps this is a formatting glitch in the documentation processor, but I couldn't find the documentation's source format. and then... there's always the possibility that I'm barking up the wrong tree. What I'm trying to achieve is this: I've got a function which, given a vector describing a point in n-dimensional space, returns a value for that point. I want a matrix of the shape I specify, filled these values, with the array indicies as coordinates for the points. Is that too much to ask? ;) Thanks, - Kevin Turner [using Python version 2.0, PyNum 19.0.0] -- Kevin Turner <acapnotic@users.sf.net> | OpenPGP encryption welcome here http://www.purl.org/wiki/python/KevinTurner _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion
participants (2)
-
Kevin Turner
-
Paul F. Dubois