Bonjour a tous
je cherche a comprendre comment utiliser les fonctions python dans python caller
je joins un petit code test qui ne fonctionne pas avec python caller alors que c'est bon avec mon interpreteur en ligne de commande
import fme
import fmeobjects
import numpy as np
# Template Function interface:
# When using this function, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter
def processFeature(feature):
pass
# Template Class Interface:
# When using this class, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter
class FeatureProcessor(object):
def __init__(self):
pass
def fonction_sinus(x):
y=np.sin(x)
return y
def input(self,feature):
new_feature = feature.clone()
x_new = [0,1,2,3,4,5,6]
y_new = [0,1,0,-1,0,1,0]
x_interpol = np.linspace(float(x_new[0]), float(max(x_new)), 200)
y_interpol = fonction_sinus(x_interpol)
for i in range(len(x_interpol)):
chart_value_a = x_interpol[i]
chart_value_b = y_interpol[i]
new_feature.setAttribute('sinus{%d}.x' %i,chart_value_a)
new_feature.setAttribute('sinus{%d}.y' %i,chart_value_b)
self.pyoutput(new_feature)
def close(self):
pass
(numpy est pourtant bien installé - si je fais directement y_interpol =np.sin(x_new) c'est ok)
Merci de votre aide