UnboundLocalError: local variable 'e1' referenced before assignment

Yes, If I set A as a value(A = np.array([[0, 0],[0, 0],[0, 0],[1, 0], [1, 0], [1, 0],[1,0],[1, 0],[1,0],[1, 0],[1,0],[1, 1],[1,1]])), it will pass successfully. but if I use a function to get A ,as following:
def get_changepoint_matrix(t,t_change,T_time,S):
A = np.empty(shape=(T_time,S), dtype=object)
#A = np.zeros((T,S))
a_row = np.zeros(shape=S, dtype=object)

cp_idx = 0
#print ("degaaa",T,S,len(t),len(t_change),t,t_change)
for i in range(0,T_time,1):
    while ((cp_idx < S) and (t[i] >= t_change[cp_idx])):
        a_row[cp_idx] = 1
        cp_idx = cp_idx + 1
    A[i] = a_row
    #print ("a_row",a_row)
#print ("A",A)
return A

there will be an error " theano.tensor.var.AsTensorError: (‘Variable type field must be a TensorType.’, A, <theano.gof.type.Generic object at 0x000000000EE061D0>)"