本文整理汇总了Python中gnome.outputters.Renderer.rewind方法的典型用法代码示例。如果您正苦于以下问题:Python Renderer.rewind方法的具体用法?Python Renderer.rewind怎么用?Python Renderer.rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnome.outputters.Renderer
的用法示例。
在下文中一共展示了Renderer.rewind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rewind
# 需要导入模块: from gnome.outputters import Renderer [as 别名]
# 或者: from gnome.outputters.Renderer import rewind [as 别名]
def test_rewind(output_dir):
'test rewind calls base function and clear_output_dir'
r = Renderer(bna_sample, output_dir)
bg_name = r.background_map_name
fg_format = r.foreground_filename_format
# dump some files into output dir:
open(os.path.join(output_dir, bg_name), 'w').write('some junk')
for i in range(5):
open(os.path.join(output_dir, fg_format.format(i)), 'w'
).write('some junk')
now = datetime.now()
r.prepare_for_model_run(model_start_time=now)
assert r._model_start_time == now
r.rewind()
assert r._model_start_time is None # check super is called correctly
# there should only be a background image now.
files = os.listdir(output_dir)
assert files == []
示例2: test_rewind
# 需要导入模块: from gnome.outputters import Renderer [as 别名]
# 或者: from gnome.outputters.Renderer import rewind [as 别名]
def test_rewind(output_dir):
'test rewind calls base function and clear_output_dir'
r = Renderer(bna_sample, output_dir)
bg_name = r.background_map_name
fg_format = r.foreground_filename_format
# dump some files into output dir:
open(os.path.join(output_dir, bg_name), 'w').write('some junk')
for i in range(5):
open(os.path.join(output_dir, fg_format.format(i)), 'w'
).write('some junk')
now = datetime.now()
r.prepare_for_model_run(model_start_time=now)
assert r._model_start_time == now
r.rewind()
# check super is called correctly
assert r._model_start_time is None
assert r._dt_since_lastoutput is None
assert r._write_step is True
# changed renderer and netcdf ouputter to delete old files in
# prepare_for_model_run() rather than rewind()
# -- rewind() was getting called a lot
# -- before there was time to change the ouput file names, etc.
# So for this unit test, there should only be a background image now.
files = os.listdir(output_dir)
assert files == ['background_map.png']