# 'numpy.ndarray' object is not callable error [closed]

I want to find optimize minimum value but it shows 'numpy.ndarray' object is not callable error.

This is my code in python

from scipy.optimize import fmin
import numpy as np
import pylab

wavelenght = np.array([0.2,0.3,0.4,0.5,0.6,0.7,1.0,2.0,4.0,10.0 ])
ns = np.array([1.07,1.51,0.17,0.13,0.12,0.14,0.21,0.65,2.30,19.3])
nc = np.array([1.01,1.39,1.18,1.13,0.40,0.21,0.33,0.85,2.41,11.6])
ng = np.array([1.43,1.80,1.66,0.85,0.22,0.16,0.26,0.85,2.60,12.4])
ks = np.array([1.24,0.96,1.95,2.92,3.73,4.52,6.76,12.2,24.3,54.0])
kc = np.array([1.50,1.67,2.21,2.56,2.95,4.16,6.60,10.6,21.5,49.1])
kg = np.array([1.22,1.92,1.96,1.90,2.97,3.95,6.82,12.6,24.6,55.0])

Rs=((((ns-1)**2)+ks**2)/(((ns+1)**2)+ks**2))*100

Rc=((((nc-1)**2)+kc**2)/(((nc+1)**2)+kc**2))*100
Rg=((((ng-1)**2)+kg**2)/(((ng+1)**2)+kg**2))*100

x0 = -5 # start from x = -5
xmin0 = fmin(Rs,x0)

pylab.plot(wavelenght,Rs)
pylab.plot(wavelenght,Rc)
pylab.plot(wavelenght,Rg)


## closed as off-topic by nbro, DuttaA, hisairnessag3, Djib2011, malioboroSep 8 at 8:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question does not appear to be about artificial intelligence, within the scope defined in the help center." – nbro, DuttaA, hisairnessag3, Djib2011, malioboro
If this question can be reworded to fit the rules in the help center, please edit the question.

The definition of fmin according to scipy is:

fmin(func, x0, args=(), **kwargs)


The reason fmin doesn't take Rs is because it isn't a callable, but an array. A callable is simply an object that implements __call__, such objects are methods, anonymous functions(lambdas), classes and instantiated classes.

def callable_function(*vargs):
pass

class Callable:
def __init__(self, *vargs):
pass
def __call__(self, *vargs):
pass
@staticmethod
def staticcallable(*vargs):
pass

callable_lambda = lambda *vargs: None


All of the above are callables. However, not all callables can be used with fmin as it expects the callable to return an int or a float.