本文整理汇总了Java中org.python.core.PyList.get方法的典型用法代码示例。如果您正苦于以下问题:Java PyList.get方法的具体用法?Java PyList.get怎么用?Java PyList.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.python.core.PyList
的用法示例。
在下文中一共展示了PyList.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimpleToDict
import org.python.core.PyList; //导入方法依赖的package包/类
@Test
public void testSimpleToDict() throws Exception {
IPointGenerator<StepModel> temp = service.createGenerator(new StepModel("Temperature", 290, 295, 1));
IPointGenerator<?> scan = service.createCompoundGenerator(temp);
Map<?,?> dict = ((PySerializable)scan).toDict();
PyList gens = (PyList) dict.get("generators");
PyDictionary line1 = (PyDictionary) gens.get(0);
assertEquals("Temperature", ((PyList) line1.get("axes")).get(0));
assertEquals("mm", ((PyList) line1.get("units")).get(0));
assertEquals(290.0, (double) ((PyList) line1.get("start")).get(0), 1E-10);
assertEquals(295.0, (double) ((PyList) line1.get("stop")).get(0), 1E-10);
assertEquals(6, (int) line1.get("size"));
PyList excluders = (PyList) dict.get("excluders");
PyList mutators = (PyList) dict.get("mutators");
assertEquals(new PyList(), excluders);
assertEquals(new PyList(), mutators);
}
示例2: testNestedToDict
import org.python.core.PyList; //导入方法依赖的package包/类
@Test
public void testNestedToDict() throws Exception {
IPointGenerator<StepModel> temp = service.createGenerator(new StepModel("Temperature", 290, 295, 1));
IPointGenerator<StepModel> pos = service.createGenerator(new StepModel("Position", 1, 4, 0.6));
IPointGenerator<?> scan = service.createCompoundGenerator(temp, pos);
Map<?,?> dict = ((PySerializable)scan).toDict();
PyList gens = (PyList) dict.get("generators");
PyDictionary line1 = (PyDictionary) gens.get(0);
PyDictionary line2 = (PyDictionary) gens.get(1);
assertEquals("Temperature", ((PyList) line1.get("axes")).get(0));
assertEquals("mm", ((PyList) line1.get("units")).get(0));
assertEquals(290.0, (double) ((PyList) line1.get("start")).get(0), 1E-10);
assertEquals(295.0, (double) ((PyList) line1.get("stop")).get(0), 1E-10);
assertEquals(6, (int) line1.get("size"));
assertEquals("Position", ((PyList) line2.get("axes")).get(0));
assertEquals("mm", ((PyList) line2.get("units")).get(0));
assertEquals(1.0, (double) ((PyList) line2.get("start")).get(0), 1E-10);
assertEquals(4.0, (double) ((PyList) line2.get("stop")).get(0), 1E-10);
assertEquals(6, (int) line2.get("size"));
PyList excluders = (PyList) dict.get("excluders");
PyList mutators = (PyList) dict.get("mutators");
assertEquals(new PyList(), excluders);
assertEquals(new PyList(), mutators);
}
示例3: setDoubles
import org.python.core.PyList; //导入方法依赖的package包/类
/**
* Lets the name of the variable containing list of numbers.
* Specifically desinged to used from Python.
*/
public void setDoubles(final String name, final PyList list) {
final double[] values = new double[list.size()];
for(int i = 0; i < values.length; i++) {
values[i] = (Double) list.get(i);
}
this.engine.assign(name, values);
}
示例4: setDoubles
import org.python.core.PyList; //导入方法依赖的package包/类
public void setDoubles(final String name, final PyList list) {
final double[] values = new double[list.size()];
for(int i = 0; i < values.length; i++) {
values[i] = (Double) list.get(i);
}
this.engine.assign(name, values);
}