本文整理汇总了Python中PyDSTool.loadObjects方法的典型用法代码示例。如果您正苦于以下问题:Python PyDSTool.loadObjects方法的具体用法?Python PyDSTool.loadObjects怎么用?Python PyDSTool.loadObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyDSTool
的用法示例。
在下文中一共展示了PyDSTool.loadObjects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import loadObjects [as 别名]
def __init__(self, cwd, model_name, name_base, gen_type, gen_version=0):
"""
Internal utility to manage versions of Generator objects within single
session.
cwd = current working directory (string)
Option to set known gen version # to reuse:
Version 0 means not yet created.
Works across saved and restarted sessions
"""
self.cwd = cwd
self.model_name = model_name
self.name_base = name_base
self.gen_version = gen_version
self.gen_type = gen_type
# keyed by version
self.used_dsargs = {}
self.logfile = os.path.join(self.cwd, 'models', 'gen_dsargs_log.sav')
if os.path.exists(self.logfile):
# reload previous list of versions
self.used_dsargs = dst.loadObjects(self.logfile)[0]
self.classes = {'vode': dst.Generator.Vode_ODEsystem,
'dopri': dst.Generator.Dopri_ODEsystem,
'radau': dst.Generator.Radau_ODEsystem,
'euler': dst.Generator.Euler_ODEsystem}
self.targetlang = self._targetlangs[gen_type]
示例2: make
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import loadObjects [as 别名]
def make(self, dsargs):
# use cache if available
for gen_ver, prev_dsargs in self.used_dsargs.items():
if dst.filteredDict(dsargs, 'name', True) == dst.filteredDict(prev_dsargs,
'name', True):
# compare everything but the name, but check all up to final '_ver<X>'
parts1 = dsargs.name.split('_')
parts2 = prev_dsargs.name.split('_') # will have one more part
if parts1 == parts2[:-2]:
print("Reusing identical build")
return dst.loadObjects(os.path.join(self.cwd, 'models',
prev_dsargs.name+'.sav'))[0]
# no matches
return self.build(dsargs)
示例3: load_gen
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import loadObjects [as 别名]
def load_gen(self, name):
if self.gen_version == 0:
raise ValueError("No current version known: set gen_version")
return dst.loadObjects(os.path.join(self.cwd, 'models', name + '_' + \
self.gen_type + \
'_ver%i'%self.gen_version+'.sav'))[0]