fumfunction question
Can additional function arguments (aside from the dimensions of an array) be used in conjunction with fromfunction? Thanks, -Mark
Mark.Miller wrote:
Can additional function arguments (aside from the dimensions of an array) be used in conjunction with fromfunction?
Yes --- as long as they are keyword arguments. Keyword arguments can be passed in and they will be handed over to the function as keyword arguments. -Travis
OK...I think I understand. But just to clarify: Suppose I have a function that can take 3 parameters def f(x,y,constant): operations Is it appropriate to use something like a=numpy.fromfunction(f,(x,y),const) where x and y give the array dimensions and const is another variable that is used to perform operations within f. I know that it doesn't work, but I just wanted to check to see if there is possibly a syntax that can work. Thanks, -Mark Travis Oliphant wrote:
Mark.Miller wrote:
Can additional function arguments (aside from the dimensions of an array) be used in conjunction with fromfunction?
Yes --- as long as they are keyword arguments.
Keyword arguments can be passed in and they will be handed over to the function as keyword arguments.
-Travis
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Mark.Miller wrote:
OK...I think I understand. But just to clarify:
Suppose I have a function that can take 3 parameters
def f(x,y,constant): operations
Is it appropriate to use something like
a=numpy.fromfunction(f,(x,y),const)
where x and y give the array dimensions and const is another variable that is used to perform operations within f.
I know that it doesn't work, but I just wanted to check to see if there is possibly a syntax that can work.
No, you can only pass extra keyword arguments on to the function. Thus, def f(x,y,myval=3): operations could be called as a = numpy.fromfunction(f, (10,20), myval=4) -Travis
Got it...thanks! Travis Oliphant wrote:
Mark.Miller wrote:
OK...I think I understand. But just to clarify:
Suppose I have a function that can take 3 parameters
def f(x,y,constant): operations
Is it appropriate to use something like
a=numpy.fromfunction(f,(x,y),const)
where x and y give the array dimensions and const is another variable that is used to perform operations within f.
I know that it doesn't work, but I just wanted to check to see if there is possibly a syntax that can work.
No, you can only pass extra keyword arguments on to the function. Thus,
def f(x,y,myval=3): operations
could be called as
a = numpy.fromfunction(f, (10,20), myval=4)
-Travis
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
-- Dr. Mark P. Miller Department of Biology 5305 Old Main Hill Utah State University Logan, UT 84322-5305 USA
<><><><><><><><><><><><><><><>< http://www.biology.usu.edu/people/facultyinfo.asp?username=mpmbio http://www.marksgeneticsoftware.net
participants (3)
-
Mark.Miller
-
Travis Oliphant
-
Travis Oliphant