当前位置: 首页>>代码示例>>Java>>正文


Java PyDictionary.put方法代码示例

本文整理汇总了Java中org.python.core.PyDictionary.put方法的典型用法代码示例。如果您正苦于以下问题:Java PyDictionary.put方法的具体用法?Java PyDictionary.put怎么用?Java PyDictionary.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.python.core.PyDictionary的用法示例。


在下文中一共展示了PyDictionary.put方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configFromProperties

import org.python.core.PyDictionary; //导入方法依赖的package包/类
/**
 * Copy all properties into jython envirenment
 * @param appId
 * @param whExecId
 * @param properties
 * @return PySystemState A PySystemState that contain all the arguments.
 */
private PySystemState configFromProperties(Integer appId, Integer dbId, Long whExecId, Properties properties) {
  this.prop = properties;
  if (appId != null)
    prop.setProperty(Constant.APP_ID_KEY, String.valueOf(appId));
  if (dbId != null)
    prop.setProperty(Constant.DB_ID_KEY, String.valueOf(dbId));
  prop.setProperty(Constant.WH_EXEC_ID_KEY, String.valueOf(whExecId));
  PyDictionary config = new PyDictionary();
  for (String key : prop.stringPropertyNames()) {
    String value = prop.getProperty(key);
    config.put(new PyString(key), new PyString(value));
  }
  PySystemState sys = new PySystemState();
  sys.argv.append(config);
  return sys;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:24,代码来源:EtlJob.java

示例2: iteratorFromValidModel

import org.python.core.PyDictionary; //导入方法依赖的package包/类
@Override
public ScanPointIterator iteratorFromValidModel() {
	final String xName = model.getFastAxisName();
	final String yName = model.getSlowAxisName();
	final double width = model.getBoundingBox().getFastAxisLength();
	final double height = model.getBoundingBox().getSlowAxisLength();

       final JythonObjectFactory<ScanPointIterator> lissajousGeneratorFactory = ScanPointGeneratorFactory.JLissajousGeneratorFactory();

       final PyDictionary box = new PyDictionary();
       box.put("width", width);
       box.put("height", height);
       box.put("centre", new double[] {model.getBoundingBox().getFastAxisStart() + width / 2,
								model.getBoundingBox().getSlowAxisStart() + height / 2});

       final PyList names =  new PyList(Arrays.asList(xName, yName));
       final PyList units = new PyList(Arrays.asList("mm", "mm"));
       final int numLobes = (int) (model.getA() / model.getB());
       final int numPoints = model.getPoints();

       final ScanPointIterator lissajous = lissajousGeneratorFactory.createObject(
			names, units, box, numLobes, numPoints);
	final ScanPointIterator pyIterator = CompoundSpgIteratorFactory.createSpgCompoundGenerator(new Iterator[] {lissajous}, getRegions().toArray(),
			new String[] {xName, yName}, EMPTY_PY_ARRAY, -1, model.isContinuous());
	return new SpgIterator(pyIterator);
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:27,代码来源:LissajousGenerator.java

示例3: createStudentInfoDict

import org.python.core.PyDictionary; //导入方法依赖的package包/类
/**
 * Creates a PyDictionary about infos about the student. The infos and their
 * stored keys
 * first_name: FirstName of the student
 * last_name: LastName of the student
 * email: email of the student
 * matriculation: Matriculation number of the student.
 * part_type: participation type of the student.
 * @param student The student which infos should be put in the py Dict.
 * @return The PyDict with student infos.
 */
private PyDictionary createStudentInfoDict(Student student) {
    log.debug("createStudentInfoDict called with student " + student.getUser());
    PyDictionary studentDict = new PyDictionary();

    studentDict.put(new PyString(KEY_STUDENT_INFO_MATR),
            student.getUser().getMatriculationNumber() == null
                    ? new PyString("")
                    : new PyString(student.getUser().getMatriculationNumber()));

    studentDict.put(new PyString(KEY_STUDENT_INFO_FIRST_NAME),
            new PyString(student.getUser().getFirstName()));
    studentDict.put(new PyString(KEY_STUDENT_INFO_LAST_NAME),
            new PyString(student.getUser().getLastName()));
    studentDict.put(new PyString(KEY_STUDENT_INFO_EMAIL),
            new PyString(student.getUser().getEmail()));
    studentDict.put(new PyString(KEY_STUDENT_INFO_PART_TYPE),
            new PyString(student.getParticipationType().getName()));


    return studentDict;
}
 
开发者ID:stefanoberdoerfer,项目名称:exmatrikulator,代码行数:33,代码来源:GradeScriptController.java

示例4: createOtherStudentGradesDict

import org.python.core.PyDictionary; //导入方法依赖的package包/类
/**
 * Creates a python dictionary of the other student relations of a student
 * in which the currently logged in user is lecturer.
 * The dictionary has as the first index the semester in which the courses were
 * located, which points to a dictionary of courses during this semester.
 * This dictionary uses the shortcut of a course to get a grade dictionary
 * of the student in that course.
 * @param otherStudentRelations The other student relations which should create
 *                            the Python Dictionary
 * @return The python dictionary with other grades indexed by semester
 *         and course shortcut.
 */
private PyDictionary createOtherStudentGradesDict(List<Student> otherStudentRelations) {
    List<Semester> semesters = new ArrayList<>();
    PyDictionary semesterDict = new PyDictionary();

    for (Student otherStudent: otherStudentRelations) {
        Semester semester = otherStudent.getCourse().getSemester();

        if (!semesters.contains(semester)) {
            semesters.add(otherStudent.getCourse().getSemester());
            semesterDict.put(new PyString(semester.toString()), new PyDictionary());
        }

        if (!otherStudent.getCourse().equals(course)) {
            PyDictionary courseDict = (PyDictionary)
                    semesterDict.get(new PyString(semester.toString()));

            courseDict.put(new PyString(otherStudent.getCourse().getIdentifier()),
                    createPyGradeDict(otherStudent.getCourse().getExams(), otherStudent));
        }
    }

    return semesterDict;
}
 
开发者ID:stefanoberdoerfer,项目名称:exmatrikulator,代码行数:36,代码来源:GradeScriptController.java

示例5: pigToPython

import org.python.core.PyDictionary; //导入方法依赖的package包/类
public static PyObject pigToPython(Object object) {
    if (object instanceof Tuple) {
        return pigTupleToPyTuple((Tuple) object);
    } else if (object instanceof DataBag) {
        PyList list = new PyList();
        for (Tuple bagTuple : (DataBag) object) {
            list.add(pigTupleToPyTuple(bagTuple));
        }
        return list;
    } else if (object instanceof Map<?, ?>) {
        PyDictionary newMap = new PyDictionary();
        for (Map.Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) {
            newMap.put(entry.getKey(), pigToPython(entry.getValue()));
        }
        return newMap;
    } else if (object instanceof DataByteArray) {
        return Py.java2py(((DataByteArray) object).get());
    } else {
        return Py.java2py(object);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:22,代码来源:JythonUtils.java

示例6: configFromFile

import org.python.core.PyDictionary; //导入方法依赖的package包/类
@Deprecated
private PySystemState configFromFile(Integer appId, Integer dbId, long whExecId, String configFile) {

  prop = new Properties();
  if (appId != null) {
    prop.setProperty(Constant.APP_ID_KEY, String.valueOf(appId));
  }
  if (dbId != null) {
    prop.setProperty(Constant.DB_ID_KEY, String.valueOf(dbId));
  }
  prop.setProperty(Constant.WH_EXEC_ID_KEY, String.valueOf(whExecId));

  try {
    InputStream propFile = new FileInputStream(configFile);
    prop.load(propFile);
    propFile.close();
  } catch (IOException e) {
    logger.error("property file '{}' not found", configFile);
    e.printStackTrace();
  }

  PyDictionary config = new PyDictionary();

  for (String key : prop.stringPropertyNames()) {
    String value = prop.getProperty(key);
    config.put(new PyString(key), new PyString(value));
  }

  PySystemState sys = new PySystemState();
  sys.argv.append(config);
  return sys;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:33,代码来源:EtlJob.java

示例7: onReceive

import org.python.core.PyDictionary; //导入方法依赖的package包/类
@Override
public void onReceive(Object o) throws Exception {
  if (o instanceof String) {
    Properties whProps = EtlJobPropertyDao.getWherehowsProperties();
    PyDictionary config = new PyDictionary();
    for (String key : whProps.stringPropertyNames()) {
      String value = whProps.getProperty(key);
      config.put(new PyString(key), new PyString(value));
    }
    sys = new PySystemState();
    sys.argv.append(config);
    interpreter = new PythonInterpreter(null, sys);
    String msg = (String) o;
    Logger.info("Start build {} tree", msg);
    InputStream in = null;
    switch (msg) {
      case "dataset":
        in = EtlJob.class.getClassLoader().getResourceAsStream("jython/DatasetTreeBuilder.py");
        break;
      case "flow":
        //in = EtlJob.class.getClassLoader().getResourceAsStream("jython/FlowTreeBuilder.py");
        break;
      default:
        Logger.error("unknown message : {}", msg);
    }
    if (in != null) {
      interpreter.execfile(in);
      in.close();
      Logger.info("Finish build {} tree", msg);
    } else {
      Logger.error("can not find jython script");
    }
  } else {
    throw new Exception("message type is not supported!");
  }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:37,代码来源:TreeBuilderActor.java

示例8: getMutatorAsJythonObject

import org.python.core.PyDictionary; //导入方法依赖的package包/类
@Override
public Object getMutatorAsJythonObject() {
	JythonObjectFactory randomOffsetMutatorFactory = ScanPointGeneratorFactory.JRandomOffsetMutatorFactory();

       PyList pyAxes = new PyList(axes);

       PyDictionary maxOffset = new PyDictionary();
       for (String axis : maxOffsets.keySet()) {
	maxOffset.put(axis, maxOffsets.get(axis));
       }

	return randomOffsetMutatorFactory.createObject(seed, pyAxes, maxOffset);
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:14,代码来源:RandomOffsetMutator.java

示例9: testJLissajousGeneratorFactory

import org.python.core.PyDictionary; //导入方法依赖的package包/类
@Test
  public void testJLissajousGeneratorFactory() {
      JythonObjectFactory<ScanPointIterator> lissajousGeneratorFactory = ScanPointGeneratorFactory.JLissajousGeneratorFactory();

      PyDictionary box = new PyDictionary();
      box.put("width", 1.5);
      box.put("height", 1.5);
      box.put("centre", new double[] {0.0, 0.0});

      PyList names = new PyList(Arrays.asList(new String[] {"X", "Y"}));
      int numLobes = 2;
      int numPoints = 500;

      ScanPointIterator iterator = (ScanPointIterator) lissajousGeneratorFactory.createObject(
		names, "mm", box, numLobes, numPoints);

      List<Object> expectedPoints = new ArrayList<Object>();
   expectedPoints.add(new Point("X", 0, 0.0, "Y", 0, 0.0, false));
   expectedPoints.add(new Point("X", 1, 0.01884757158250311, "Y", 1, 0.028267637002450906, false));
   expectedPoints.add(new Point("X", 2, 0.03768323863482717, "Y", 2, 0.05649510414594954, false));
   expectedPoints.add(new Point("X", 3, 0.05649510414594954, "Y", 3, 0.08464228865511125, false));
   expectedPoints.add(new Point("X", 4, 0.07527128613841116, "Y", 4, 0.1126691918405678, false));
   expectedPoints.add(new Point("X", 5, 0.0939999251732282, "Y", 5, 0.14053598593929345, false));

      assertEquals(numPoints, iterator.size());
      assertEquals(1, iterator.getRank());
      assertArrayEquals(new int[] { numPoints }, iterator.getShape());

   int index = 0;
      while (iterator.hasNext() && index < 6){  // Just test first few points
          Object point = iterator.next();
          assertEquals(expectedPoints.get(index), point);
index++;
      }
  }
 
开发者ID:eclipse,项目名称:scanning,代码行数:36,代码来源:ScanPointGeneratorFactoryTest.java

示例10: createPyGradeDict

import org.python.core.PyDictionary; //导入方法依赖的package包/类
/**
 * Sets up a python dictionary of the students gradings of the exams.
 * The shortcut of a exam of the grading gets put as key of the dictionary,
 * the value of the grade of the grading gets put as value depending of
 * the grade type(see gradeValueToPyObject).
 * @param exams The list of exams for which should be included in the grade dict.
 * @param student The student which gradings should be put in the dict.
 * @return The Python dictionary of the exam shortcuts.
 */
private PyDictionary createPyGradeDict(List<Exam> exams, Student student) {
    log.debug("createPyGradeDict called with student " + student.getUser());
    PyDictionary pyGradeDict = new PyDictionary();
    for (Exam exam: exams) {
        Grading grading = student.getGradingFromExam(exam);
        log.debug("Got grading " + grading + " for exam " + exam.getName());
        pyGradeDict.put(new PyString(exam.getShortcut()),
                gradeValueToPyObject((grading == null) ? null : grading.getGrade()));
    }
    return pyGradeDict;
}
 
开发者ID:stefanoberdoerfer,项目名称:exmatrikulator,代码行数:21,代码来源:GradeScriptController.java

示例11: configFromProperties

import org.python.core.PyDictionary; //导入方法依赖的package包/类
/**
 * Copy all properties into jython environment
 * @return PySystemState A PySystemState that contain all the arguments.
 */
private PySystemState configFromProperties() {
  final PyDictionary config = new PyDictionary();
  for (String key : prop.stringPropertyNames()) {
    config.put(new PyString(key), new PyString(prop.getProperty(key)));
  }
  PySystemState sys = new PySystemState();
  sys.argv.append(config);
  return sys;
}
 
开发者ID:linkedin,项目名称:WhereHows,代码行数:14,代码来源:EtlJob.java

示例12: onReceive

import org.python.core.PyDictionary; //导入方法依赖的package包/类
@Override
public void onReceive(Object o) throws Exception {
  if (!(o instanceof String)) {
    throw new Exception("message type is not supported!");
  }

  String jobName = (String) o;
  Logger.info("Start tree job {}", jobName);

  Properties props = treeJobList.get(jobName);
  if (props == null) {
    Logger.error("unknown job {}", jobName);
    return;
  }

  PyDictionary config = new PyDictionary();
  for (String key : props.stringPropertyNames()) {
    String value = props.getProperty(key);
    config.put(new PyString(key), new PyString(value));
  }
  config.put(new PyString(Constant.WH_DB_URL_KEY), new PyString(WH_DB_URL));
  config.put(new PyString(Constant.WH_DB_USERNAME_KEY), new PyString(WH_DB_USERNAME));
  config.put(new PyString(Constant.WH_DB_PASSWORD_KEY), new PyString(WH_DB_PASSWORD));
  config.put(new PyString(Constant.WH_DB_DRIVER_KEY), new PyString(WH_DB_DRIVER));

  sys = new PySystemState();
  sys.argv.append(config);
  interpreter = new PythonInterpreter(null, sys);

  String script = props.getProperty(Constant.JOB_SCRIPT_KEY);
  InputStream in = EtlJob.class.getClassLoader().getResourceAsStream(script);
  if (in != null) {
    interpreter.execfile(in);
    in.close();
    Logger.info("Finish tree job {}", jobName);
  } else {
    Logger.error("can not find jython script {}", script);
  }
}
 
开发者ID:linkedin,项目名称:WhereHows,代码行数:40,代码来源:TreeBuilderActor.java

示例13: iteratorFromValidModel

import org.python.core.PyDictionary; //导入方法依赖的package包/类
@Override
public ScanPointIterator iteratorFromValidModel() {
	final RandomOffsetGridModel model = getModel();

	final int columns = model.getFastAxisPoints();
	final int rows = model.getSlowAxisPoints();
	final String xName = model.getFastAxisName();
	final String yName = model.getSlowAxisName();
	final double xStep = model.getBoundingBox().getFastAxisLength() / columns;
	final double yStep = model.getBoundingBox().getSlowAxisLength() / rows;
	final double minX = model.getBoundingBox().getFastAxisStart() + xStep / 2;
	final double minY = model.getBoundingBox().getSlowAxisStart() + yStep / 2;

       final JythonObjectFactory<ScanPointIterator> lineGeneratorFactory = ScanPointGeneratorFactory.JLineGenerator1DFactory();

	final ScanPointIterator outerLine = lineGeneratorFactory.createObject(
			yName, "mm", minY, minY + (rows - 1) * yStep, rows);
	final ScanPointIterator innerLine = lineGeneratorFactory.createObject(
			xName, "mm", minX, minX + (columns - 1) * xStep, columns, model.isSnake());

       final JythonObjectFactory<PyObject> randomOffsetMutatorFactory = ScanPointGeneratorFactory.JRandomOffsetMutatorFactory();

       final int seed = model.getSeed();
       final double offset = xStep * model.getOffset() / 100;

       final PyDictionary maxOffset = new PyDictionary();
       maxOffset.put(yName, offset);
       maxOffset.put(xName, offset);

       final PyList axes = new PyList(Arrays.asList(yName, xName));
	final PyObject randomOffset = randomOffsetMutatorFactory.createObject(seed, axes, maxOffset);

       final Iterator<?>[] generators = { outerLine, innerLine };
       final PyObject[] mutators = { randomOffset };

       final String[] axisNames = new String[] { xName, yName };
	final ScanPointIterator pyIterator = CompoundSpgIteratorFactory.createSpgCompoundGenerator(
			generators, getRegions().toArray(), axisNames, mutators, -1, model.isContinuous());

	return new SpgIterator(pyIterator);
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:42,代码来源:RandomOffsetGridGenerator.java

示例14: testJCompoundGeneratorFactoryWithMutatedRaster

import org.python.core.PyDictionary; //导入方法依赖的package包/类
@Test
   public void testJCompoundGeneratorFactoryWithMutatedRaster() {
       JythonObjectFactory<ScanPointIterator> lineGeneratorFactory = ScanPointGeneratorFactory.JLineGenerator1DFactory();

	ScanPointIterator line1 = (ScanPointIterator)  lineGeneratorFactory.createObject(
			"y", "mm", 2.0, 10.0, 5);

	ScanPointIterator line2 = (ScanPointIterator)  lineGeneratorFactory.createObject(
			"x", "mm", 1.0, 5.0, 5);

       JythonObjectFactory<?> randomOffsetMutatorFactory = ScanPointGeneratorFactory.JRandomOffsetMutatorFactory();

       int seed = 10;

       PyList axes = new PyList(Arrays.asList(new String[] {"y", "x"}));

       PyDictionary maxOffset = new PyDictionary();
       maxOffset.put("x", 0.5);
       maxOffset.put("y", 0.5);

	PyObject randomOffset = (PyObject) randomOffsetMutatorFactory.createObject(seed, axes, maxOffset);

       JythonObjectFactory<ScanPointIterator> compoundGeneratorFactory = ScanPointGeneratorFactory.JCompoundGeneratorFactory();

       Object[] generators = {line1, line2};
       Object[] excluders = CompoundSpgIteratorFactory.getExcluders(Arrays.asList(
		new ScanRegion<>(new RectangularROI(0,0,5,10,0), Arrays.asList("x", "y"))));
       Object[] mutators = {randomOffset};

	ScanPointIterator iterator = (ScanPointIterator)  compoundGeneratorFactory.createObject(
			generators, excluders, mutators);

	List<IPosition> vanillaPoints = new ArrayList<IPosition>(10);
	vanillaPoints.add(new Point("x", 0, 1.0, "y", 0, 2.0));
	vanillaPoints.add(new Point("x", 1, 2.0, "y", 0, 2.0));
	vanillaPoints.add(new Point("x", 2, 3.0, "y", 0, 2.0));
	vanillaPoints.add(new Point("x", 3, 4.0, "y", 0, 2.0));
	vanillaPoints.add(new Point("x", 4, 5.0, "y", 0, 2.0));
	vanillaPoints.add(new Point("x", 0, 1.0, "y", 1, 4.0));
	vanillaPoints.add(new Point("x", 1, 2.0, "y", 1, 4.0));
	vanillaPoints.add(new Point("x", 2, 3.0, "y", 1, 4.0));
	vanillaPoints.add(new Point("x", 3, 4.0, "y", 1, 4.0));
	vanillaPoints.add(new Point("x", 4, 5.0, "y", 1, 4.0));

    final int[] expectedShape = new int[] { 5, 5 };
    final int expectedSize = expectedShape[0] * expectedShape[1];
       assertEquals(expectedSize, iterator.size());
       assertEquals(2, iterator.getRank());
       assertArrayEquals(expectedShape, iterator.getShape());

	Iterator<IPosition> itV = vanillaPoints.iterator();
	while (iterator.hasNext() && itV.hasNext()) {
		IPosition point = iterator.next();
		IPosition vp = itV.next();
		assertEquals(vp.getIndices(), point.getIndices());
		assertEquals(vp.getNames(), point.getNames());
		for (String axis : vp.getNames()) {
			assertEquals(vp.getValue(axis), point.getValue(axis), (double) maxOffset.get(axis));
		}
	}
	assertFalse(itV.hasNext());
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:63,代码来源:ScanPointGeneratorFactoryTest.java


注:本文中的org.python.core.PyDictionary.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。