本文整理汇总了Python中opus_core.session_configuration.SessionConfiguration.get_package_order方法的典型用法代码示例。如果您正苦于以下问题:Python SessionConfiguration.get_package_order方法的具体用法?Python SessionConfiguration.get_package_order怎么用?Python SessionConfiguration.get_package_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opus_core.session_configuration.SessionConfiguration
的用法示例。
在下文中一共展示了SessionConfiguration.get_package_order方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _compute_variable_for_prior_year
# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import get_package_order [as 别名]
def _compute_variable_for_prior_year(self, dataset, full_name, time, resources=None):
"""Create a new dataset for this variable, compute the variable, and then return
the values for this variable."""
calling_dataset_pool = SessionConfiguration().get_dataset_pool()
calling_time = SimulationState().get_current_time()
SimulationState().set_current_time(time)
try:
# Get an empty dataset pool with same search paths.
my_dataset_pool = DatasetPool(
package_order=calling_dataset_pool.get_package_order(),
storage=AttributeCache())
ds = dataset.empty_dataset_like_me(in_storage=AttributeCache())
# Don't pass any datasets via resources, since they may be from a different time.
my_resources = Resources(resources)
for key in my_resources:
if isinstance(key, Dataset):
del my_resources[key]
ds.compute_variables(full_name, my_dataset_pool, resources=my_resources)
values = ds.get_attribute(full_name)
return values
finally:
SimulationState().set_current_time(calling_time)
示例2: _compute_variable_for_prior_year
# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import get_package_order [as 别名]
def _compute_variable_for_prior_year(self, dataset, full_name, time, resources=None):
"""Create a new dataset for this variable, compute the variable, and then return
the values for this variable."""
calling_dataset_pool = SessionConfiguration().get_dataset_pool()
calling_time = SimulationState().get_current_time()
SimulationState().set_current_time(time)
# Do not flush any variables when computing dependencies for a lag variable.
prior_flush_state = SimulationState().get_flush_datasets()
SimulationState().set_flush_datasets(False)
try:
# Get an empty dataset pool with same search paths.
my_dataset_pool = DatasetPool(
package_order=calling_dataset_pool.get_package_order(), storage=AttributeCache()
)
try:
ds = dataset.empty_dataset_like_me(in_storage=AttributeCache())
except FileNotFoundError:
## necessary when a dataset is not cached, but created on-the-fly, e.g submarket
ds = my_dataset_pool.get_dataset(dataset.dataset_name)
# Don't pass any datasets via resources, since they may be from a different time.
my_resources = Resources(resources)
for key in my_resources:
if isinstance(key, Dataset):
del my_resources[key]
ds.compute_variables(full_name, my_dataset_pool, resources=my_resources)
values = ds.get_attribute(full_name)
return values
finally:
SimulationState().set_current_time(calling_time)
SimulationState().set_flush_datasets(prior_flush_state)
示例3: _get_attribute_for_year
# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import get_package_order [as 别名]
def _get_attribute_for_year(self, dataset_name, attribute_name, year):
"""Return the attribute values for this year."""
calling_dataset_pool = SessionConfiguration().get_dataset_pool()
calling_time = SimulationState().get_current_time()
SimulationState().set_current_time(year)
try:
my_dataset_pool = DatasetPool(
package_order=calling_dataset_pool.get_package_order(),
storage=AttributeCache())
dataset = my_dataset_pool.get_dataset(dataset_name)
attribute_name = attribute_name.replace('DDDD',repr(year))
dataset.compute_variables(attribute_name, my_dataset_pool)
values = dataset.get_attribute(attribute_name)
return values
finally:
SimulationState().set_current_time(calling_time)