I have a module lib
that needs numpy
. So, for instance, let\'s say I have a hypothetical function that looks like
import numpy
def doS
Since everything in python is an object, including modules, you can do something like:
def doSomething(x, numpy=None):
if numpy is None:
import numpy
return numpy.sqrt(x)
Then you can call the function without setting numpy
, then it will use the default numpy. If you want to use another numpy, just call it as such:
from autograd import numpy as autograd_numpy
doSomething(x, numpy=autograd_numpy)