本文整理汇总了Java中org.python.core.PyFunction类的典型用法代码示例。如果您正苦于以下问题:Java PyFunction类的具体用法?Java PyFunction怎么用?Java PyFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PyFunction类属于org.python.core包,在下文中一共展示了PyFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GBMLRCoreData
import org.python.core.PyFunction; //导入依赖的package包/类
public GBMLRCoreData(ThreadCommSlave comm,
CoreParams coreParams,
IFeatureMap featureMap,
PyFunction pyTransformFunc,
boolean needPyTransform,
FeatureHash featureHash,
float uniformBaseScore,
boolean sampleDepdtBaseScore) {
super(comm, coreParams, featureMap, pyTransformFunc, needPyTransform, featureHash);
this.z = new float[MAX_2D_LEN][];
this.randMask = new BitSet[MAX_2D_LEN];
this.uniformBaseScore = uniformBaseScore;
this.sampleDepdtBaseScore = sampleDepdtBaseScore;
}
示例2: GBDTCoreData
import org.python.core.PyFunction; //导入依赖的package包/类
public GBDTCoreData(ThreadCommSlave comm,
DataFlow.CoreParams coreParams,
IFeatureMap featureMap,
PyFunction pyTransformFunc,
boolean needPyTransfor,
int maxFeatureDim,
int numTreeInGroup,
ILossFunction obj,
float baseScore,
boolean sampleDepdtBasePrediction) {
super(comm, coreParams, featureMap, pyTransformFunc, needPyTransfor);
this.initScore = new float[MAX_2D_LEN][];
this.score = new float[MAX_2D_LEN][];
this.DENSE_MAX_1D_SAMPLE_CNT = MAX_1D_LEN / maxFeatureDim;
this.DENSE_MAX_1D_LEN = DENSE_MAX_1D_SAMPLE_CNT * maxFeatureDim;
this.lastPredRound = 0;
this.maxFeatureDim = maxFeatureDim;
this.numTreeInGroup = numTreeInGroup;
this.obj = obj;
this.baseScore = baseScore;
this.sampleDepdtBasePrediction = sampleDepdtBasePrediction;
}
示例3: onHandleIntent
import org.python.core.PyFunction; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent workIntent) {
try {
String callback = workIntent.getExtras().getString("com.runassudo.pyandroid.CALLBACK");
PyFunction callbackR = ((PyAndroidApplication) getApplicationContext()).callbacks.get(callback);
if (callbackR != null) {
callbackR.__call__();
} else {
throw new NullPointerException("Tried to call undefined callback " + callback);
}
} catch (Exception e) {
mHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(PyService.this, "An error occurred!", Toast.LENGTH_LONG).show();
}
});
Log.e("PyAndroid", "An error occurred!", e);
}
}
示例4: callFunc
import org.python.core.PyFunction; //导入依赖的package包/类
public static Object callFunc(Class<?> c, String funcName, Object... binds) {
try {
PyObject obj = ScriptManager.python.get(funcName);
if (obj != null && obj instanceof PyFunction) {
PyFunction func = (PyFunction) obj;
PyObject[] objects = new PyObject[binds.length];
for (int i = 0; i < binds.length; i++) {
Object bind = binds[i];
objects[i] = Py.java2py(bind);
}
return func.__call__(objects).__tojava__(c);
} else
return null;
} catch (PyException ex) {
ex.printStackTrace();
return null;
}
}
示例5: prepare
import org.python.core.PyFunction; //导入依赖的package包/类
@Setup(Level.Trial)
public void prepare() {
PythonInterpreter interpreter = new CodeLoader().jython("dispatch");
dispatcher = (PyFunction) interpreter.get("dispatch");
MonomorphicState monomorphicState = new MonomorphicState();
monomorphicState.prepare();
monomorphicArray = new PyArray(Object.class, monomorphicState.data);
TriMorphicState triMorphicState = new TriMorphicState();
triMorphicState.prepare();
trimorphicArray = new PyArray(Object.class, triMorphicState.data);
PolyMorphicState polyMorphicState = new PolyMorphicState();
polyMorphicState.prepare();
polymorphicArray = new PyArray(Object.class, polyMorphicState.data);
}
示例6: outputSchema
import org.python.core.PyFunction; //导入依赖的package包/类
@Override
public Schema outputSchema(Schema input) {
if(schema != null) {
return schema;
} else {
if(outputSchemaFunc != null) {
PyFunction pf;
try {
pf = JythonScriptEngine.getFunction(scriptFilePath, outputSchemaFunc);
// this should be a schema function
PyObject schemaFunctionDef = pf.__findattr__("schemaFunction".intern());
if(schemaFunctionDef == null) {
throw new IllegalStateException("Function: "
+ outputSchemaFunc + " is not a schema function");
}
return (Schema)((pf.__call__(Py.java2py(input))).__tojava__(Object.class));
} catch (IOException ioe) {
throw new IllegalStateException("Could not find function: "
+ outputSchemaFunc + "()", ioe);
}
} else {
return new Schema(new Schema.FieldSchema(null, DataType.BYTEARRAY));
}
}
}
示例7: nextSamples
import org.python.core.PyFunction; //导入依赖的package包/类
private static Iterator nextSamples(String line, boolean needPyTransform, PyFunction pyTransformFunc, List<String>lineList) throws UnsupportedEncodingException {
Iterator iter;
if (needPyTransform) {
iter = transform(line, pyTransformFunc).iterator();
} else {
lineList.set(0, line);
iter = lineList.iterator();
}
return iter;
}
示例8: nextSamples
import org.python.core.PyFunction; //导入依赖的package包/类
private static Iterator nextSamples(String line, boolean needPyTransform, PyFunction pyTransformFunc, List<String> lineList) throws UnsupportedEncodingException {
Iterator iter;
if (needPyTransform) {
iter = transform(line, pyTransformFunc).iterator();
} else {
lineList.set(0, line);
iter = lineList.iterator();
}
return iter;
}
示例9: MulticlassLinearCoreData
import org.python.core.PyFunction; //导入依赖的package包/类
public MulticlassLinearCoreData(ThreadCommSlave comm,
CoreParams coreParams,
IFeatureMap featureMap,
PyFunction pyTransformFunc,
boolean needPyTransform,
FeatureHash featureHash,
int K) {
super(comm, coreParams, featureMap, pyTransformFunc, needPyTransform, featureHash);
this.K = K;
}
示例10: CoreData
import org.python.core.PyFunction; //导入依赖的package包/类
public CoreData(ThreadCommSlave comm,
DataFlow.CoreParams coreParams,
IFeatureMap featureMap,
PyFunction pyTransformFunc,
boolean needPyTransform) {
this.comm = comm;
this.coreParams = coreParams;
this.featureMap = featureMap;
this.pyTransformFunc = pyTransformFunc;
this.needPyTransform = needPyTransform;
this.LOG_UTILS = new LogUtils(comm, coreParams.verbose);
this.biasDelta = coreParams.need_bias ? 1 : 0;
this.x = new int[MAX_2D_LEN][];
this.xidx = new int[MAX_2D_LEN][];
this.y = new float[MAX_2D_LEN][];
this.weight = new float[MAX_2D_LEN][];
this.realNum = new int[MAX_2D_LEN];
this.weightNum = new double[MAX_2D_LEN];
this.predict = new float[MAX_2D_LEN][];
this.needFeatureTransform = coreParams.featureParams != null &&
coreParams.featureParams.transform != null &&
coreParams.featureParams.transform.switch_on;
}
示例11: FFMCoreData
import org.python.core.PyFunction; //导入依赖的package包/类
public FFMCoreData(ThreadCommSlave comm,
DataFlow.CoreParams coreParams,
IFeatureMap featureMap,
PyFunction pyTransformFunc,
boolean needPyTransform,
FeatureHash featureHash,
int maxFeatureNum,
String fieldDelim,
Map<String, Integer> field2IndexMap) {
super(comm, coreParams, featureMap, pyTransformFunc, needPyTransform, featureHash);
this.maxFeatureNum = maxFeatureNum;
this.fieldDelim = fieldDelim;
this.field2IndexMap = field2IndexMap;
}
示例12: ContinuousCoreData
import org.python.core.PyFunction; //导入依赖的package包/类
public ContinuousCoreData(ThreadCommSlave comm,
DataFlow.CoreParams coreParams,
IFeatureMap featureMap,
PyFunction pyTransformFunc,
boolean needPyTransform,
FeatureHash featureHash
) {
super(comm, coreParams, featureMap, pyTransformFunc, needPyTransform);
this.featureHash = featureHash;
}
示例13: __engine_init_pyfuncs
import org.python.core.PyFunction; //导入依赖的package包/类
public static void __engine_init_pyfuncs() {
isFull = pi.get("__engine_inventory_is_full", PyFunction.class);
contains = pi.get("__engine_inventory_contains", PyFunction.class);
baseOnLeftClick = pi.get("__engine_onLeftClick", PyFunction.class);
addItem = pi.get("__engine_add_item", PyFunction.class);
removeItem = pi.get("__engine_remove_item", PyFunction.class);
removeItemWithSlotNumber = pi.get("__engine_remove_item_with_slot_number", PyFunction.class);
}
示例14: onDestroy
import org.python.core.PyFunction; //导入依赖的package包/类
@Override
public void onDestroy() {
super.onDestroy();
try {
PyFunction callbackR = ((PyAndroidApplication) getApplicationContext()).callbacks.get("_stop");
if (callbackR != null) {
callbackR.__call__();
}
} catch (Exception e) {
Log.w("PyAndroid", "An error occurred while stopping.", e);
appendLog("An error occurred while stopping.");
appendLog(Log.getStackTraceString(e));
}
}
示例15: invoke
import org.python.core.PyFunction; //导入依赖的package包/类
public void invoke(String method) {
PyObject obj = (PyObject) this.bindings.get(method);
if (obj == null) {
failz0r(world, pos, "Unknown function '%s'", method);
return;
}
PyFunction func = (PyFunction)obj;
try {
func.__call__();
} catch (RuntimeException e) {
failz0r(world, pos, "Error running code: %s", e.toString());
}
}