def run_string_conversions1(self): basestr = 200000 * b" " li = [] for i in range(1000): if (i + 1) % 100 == 0: show_mem("%4d runs" % i) dv = pyopenms.DataValue(basestr) dv = pyopenms.DataValue(basestr) li.append(dv) del li
def run_string_lists(self): basestr = 10000 * b" " li = [] for i in range(100): if (i + 1) % 100 == 0: show_mem("%4d runs" % i) sl = pyopenms.DataValue([basestr] * 30) sl = pyopenms.DataValue([basestr] * 30) li.append(sl) del sl del li
def getModelDefaults(default_model): params = pms.Param() params.setValue("type", pms.DataValue(default_model), "Type of model") model_types = [ "linear", "b_spline", "interpolated"] if default_model not in model_types: model_types.insert(0, default_model) params.setValidStrings("type", model_types) model_params = pms.Param() pms.TransformationModelLinear.getDefaultParameters(model_params) params.insert("linear:", model_params) params.setSectionDescription("linear", "Parameters for 'linear' model") pms.TransformationModelBSpline.getDefaultParameters(model_params) params.insert("b_spline:", model_params) params.setSectionDescription("b_spline", "Parameters for 'b_spline' model") pms.TransformationModelInterpolated.getDefaultParameters(model_params) entry = model_params.getEntry("interpolation_type") interpolation_types = entry.valid_strings if "polynomial" in interpolation_types: interpolation_types.remove("polynomial") model_params.setValidStrings("interpolation_type", interpolation_types) params.insert("interpolated:", model_params) params.setSectionDescription("interpolated", "Parameters for 'interpolated' model") return params
def _addDataProcessing(item, params): dp = item.getDataProcessing() p = pms.DataProcessing() p.setProcessingActions(set([pms.ProcessingAction.ALIGNMENT])) sw = p.getSoftware() sw.setName(os.path.basename(sys.argv[0])) sw.setVersion(pms.VersionInfo.getVersion()) p.setSoftware(sw) p.setCompletionTime(pms.DateTime.now()) for k, v in params.asDict().items(): p.setMetaValue("parameter: "+k, pms.DataValue(v)) dp.append(p) item.setDataProcessing(dp) return item
def testDataValue(): """ @tests: DataValue.__init__ DataValue.isEmpty DataValue.toDoubleList DataValue.toDouble DataValue.toInt DataValue.toIntList DataValue.toString DataValue.toStringList DataValue.valueType """ a = pyopenms.DataValue() assert a.isEmpty() a = pyopenms.DataValue(1) assert not a.isEmpty() assert a.toInt() == 1 assert a.valueType() == pyopenms.DataType.INT_VALUE a = pyopenms.DataValue(1.0) assert not a.isEmpty() assert a.toDouble() == 1.0 assert a.valueType() == pyopenms.DataType.DOUBLE_VALUE a = pyopenms.DataValue("1") assert not a.isEmpty() assert a.toString() == "1" assert a.valueType() == pyopenms.DataType.STRING_VALUE a = pyopenms.DataValue([1]) assert not a.isEmpty() assert a.toIntList() == [1] assert a.valueType() == pyopenms.DataType.INT_LIST a = pyopenms.DataValue([1.0]) assert not a.isEmpty() assert a.toDoubleList() == [1.0] assert a.valueType() == pyopenms.DataType.DOUBLE_LIST a = pyopenms.DataValue(["1.0"]) assert not a.isEmpty() assert a.toStringList() == ["1.0"] assert a.valueType() == pyopenms.DataType.STRING_LIST
def _testMetaInfoInterface(what): #void getKeys(libcpp_vector[String] & keys) #void getKeys(libcpp_vector[unsigned int] & keys) #DataValue getMetaValue(unsigned int) nogil except + #DataValue getMetaValue(String) nogil except + #void setMetaValue(unsigned int, DataValue) nogil except + #void setMetaValue(String, DataValue) nogil except + #bool metaValueExists(String) nogil except + #bool metaValueExists(unsigned int) nogil except + #void removeMetaValue(String) nogil except + #void removeMetaValue(unsigned int) nogil except + what.setMetaValue("key", pyopenms.DataValue(42)) what.setMetaValue("key2", pyopenms.DataValue(42)) keys = [] what.getKeys(keys) keys = [0] what.getKeys(keys) assert len(keys) and all(isinstance(k, (long, int)) for k in keys) assert what.getMetaValue(keys[0]).toInt() == 42 keys = [""] what.getKeys(keys) assert len(keys) and all(isinstance(k, str) for k in keys) assert what.getMetaValue(keys[0]).toInt() == 42 assert what.metaValueExists("key") what.removeMetaValue("key") what.setMetaValue(1024, pyopenms.DataValue(42)) keys = [] what.getKeys(keys) keys = [0] what.getKeys(keys) assert len(keys) and all(isinstance(k, (long, int)) for k in keys) assert what.getMetaValue(keys[0]).toInt() == 42 keys = [""] what.getKeys(keys) assert len(keys) and all(isinstance(k, str) for k in keys) assert what.getMetaValue(keys[0]).toInt() == 42 what.setMetaValue("key", pyopenms.DataValue(42)) what.setMetaValue("key2", pyopenms.DataValue(42)) assert what.metaValueExists("key") what.removeMetaValue("key") keys = [] what.getKeys(keys) assert len(keys) == 2 what.removeMetaValue("key2") keys = [] what.getKeys(keys) assert len(keys) == 1 what.clearMetaInfo() keys = [] what.getKeys(keys) assert len(keys) == 0