本文整理汇总了Python中JSBSim_utils.SandBox.exists方法的典型用法代码示例。如果您正苦于以下问题:Python SandBox.exists方法的具体用法?Python SandBox.exists怎么用?Python SandBox.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSBSim_utils.SandBox
的用法示例。
在下文中一共展示了SandBox.exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestScriptOutput
# 需要导入模块: from JSBSim_utils import SandBox [as 别名]
# 或者: from JSBSim_utils.SandBox import exists [as 别名]
class TestScriptOutput(unittest.TestCase):
def setUp(self):
self.sandbox = SandBox()
self.script_path = self.sandbox.path_to_jsbsim_file('scripts',
'c1722.xml')
def tearDown(self):
self.sandbox.erase()
def test_no_output(self):
fdm = CreateFDM(self.sandbox)
fdm.load_script(self.script_path)
fdm.run_ic()
ExecuteUntil(fdm, 10.)
self.assertFalse(self.sandbox.exists('output.csv'),
msg="Results have unexpectedly been written to 'output.csv'")
def test_output_from_file(self):
tree = et.parse(self.sandbox.elude(self.script_path))
output_tag = et.SubElement(tree.getroot(), 'output')
output_tag.attrib['file'] = self.sandbox.elude(self.sandbox.path_to_jsbsim_file('tests', 'output.xml'))
tree.write(self.sandbox('c1722_0.xml'))
fdm = CreateFDM(self.sandbox)
fdm.load_script('c1722_0.xml')
fdm.run_ic()
ExecuteUntil(fdm, 10.)
self.assertTrue(self.sandbox.exists('output.csv'),
msg="The file 'output.csv' has not been created")
def test_output(self):
tree = et.parse(self.sandbox.elude(self.script_path))
output_tag = et.SubElement(tree.getroot(), 'output')
output_tag.attrib['name'] = 'test.csv'
output_tag.attrib['type'] = 'CSV'
output_tag.attrib['rate'] = '10'
property_tag = et.SubElement(output_tag, 'property')
property_tag.text = 'position/vrp-radius-ft'
tree.write(self.sandbox('c1722_0.xml'))
fdm = CreateFDM(self.sandbox)
fdm.load_script('c1722_0.xml')
fdm.run_ic()
ExecuteUntil(fdm, 10.)
self.assertTrue(self.sandbox.exists(output_tag.attrib['name']),
msg="The file 'output.csv' has not been created")
orig = pd.read_csv(self.sandbox('JSBout172B.csv'))
test = pd.read_csv(self.sandbox('test.csv'))
self.assertEqual(np.max(orig['Time']-test['Time']), 0.0)
pname = '/fdm/jsbsim/' + property_tag.text
self.assertEqual(np.max(orig[pname]-test[pname]), 0.0)
示例2: SandBox
# 需要导入模块: from JSBSim_utils import SandBox [as 别名]
# 或者: from JSBSim_utils.SandBox import exists [as 别名]
from JSBSim_utils import CreateFDM, ExecuteUntil, SandBox
sandbox = SandBox()
#
# Regular run that checks the correct CSV file is created
# We are just checking its existence, not its content. To accelerate the test
# execution, the simulation is interrupted after 1.0sec of simulated time.
#
fdm = CreateFDM(sandbox)
fdm.load_script(sandbox.path_to_jsbsim_file('scripts', 'c1722.xml'))
fdm.run_ic()
ExecuteUntil(fdm, 1.0)
if not sandbox.exists('JSBout172B.csv'):
print "Standard run: the file 'JSBout172B.csv' should exist."
sys.exit(-1) # 'make test' will report the test failed.
#
# Reset the simulation and check that iteration number is correctly appended to
# the filename.
#
fdm.reset_to_initial_conditions(1)
ExecuteUntil(fdm, 1.0)
if not sandbox.exists('JSBout172B_0.csv'):
print "Reset: the file 'JSBout172B_0.csv' should exist."
sys.exit(-1) # 'make test' will report the test failed.
#
示例3: ResetOutputFiles
# 需要导入模块: from JSBSim_utils import SandBox [as 别名]
# 或者: from JSBSim_utils.SandBox import exists [as 别名]
class ResetOutputFiles(unittest.TestCase):
def setUp(self):
self.sandbox = SandBox()
def tearDown(self):
self.sandbox.erase()
def test_reset_output_files(self):
#
# Regular run that checks the correct CSV file is created
# We are just checking its existence, not its content. To accelerate the
# test execution, the simulation is interrupted after 1.0sec of simulated
# time.
#
fdm = CreateFDM(self.sandbox)
fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', 'c1722.xml'))
fdm.run_ic()
ExecuteUntil(fdm, 1.0)
self.assertTrue(self.sandbox.exists('JSBout172B.csv'),
msg="Standard run: the file 'JSBout172B.csv' should exist.")
#
# Reset the simulation and check that iteration number is correctly
# appended to the filename.
#
fdm.reset_to_initial_conditions(1)
ExecuteUntil(fdm, 1.0)
self.assertTrue(self.sandbox.exists('JSBout172B_0.csv'),
msg="Reset: the file 'JSBout172B_0.csv' should exist.")
#
# Change the output filename and check that the naming logic is reset
# (e.g. that no iteration number is appended to the filename)
#
fdm.set_output_filename(0, 'dummy.csv')
fdm.reset_to_initial_conditions(1)
ExecuteUntil(fdm, 1.0)
self.assertTrue(self.sandbox.exists('dummy.csv'),
msg="Output name renaming: the file 'dummy.csv' should exist.")
#
# Call FGFDMExec::SetOutputFileName() after the simulation is reset. And
# verify that the new output file name is ignored until the next call to
# FGOutput::SetStartNewOutput(). This should be so according to the
# documentation of FGOutput::SetOutputName().
#
fdm.reset_to_initial_conditions(1)
fdm.set_output_filename(0, 'dummyx.csv')
ExecuteUntil(fdm, 1.0)
self.assertTrue(not self.sandbox.exists('dummyx.csv'),
msg="Late renaming: 'dummyx.csv' should not exist.")
self.assertTrue(self.sandbox.exists('dummy_0.csv'),
msg="Late renaming: 'dummy_0.csv' should exist.")
#
# Check that the new filename is taken into account when the simulation is
# reset.
#
fdm.reset_to_initial_conditions(1)
ExecuteUntil(fdm, 1.0)
self.assertTrue(self.sandbox.exists('dummyx.csv'),
msg="Reset after late renaming: 'dummyx.csv' should exist.")
#
# Check against multiple calls to FGFDMExec::SetOutputFileName()
#
fdm.set_output_filename(0, 'this_one.csv')
fdm.set_output_filename(0, 'that_one.csv')
fdm.reset_to_initial_conditions(1)
ExecuteUntil(fdm, 1.0)
self.assertTrue(not self.sandbox.exists('this_one.csv'),
msg="Output name overwritten: 'this_one.csv' should not exist.")
self.assertTrue(self.sandbox.exists('that_one.csv'),
msg="Output name overwritten: 'that_one.csv' should exist.")
#
# Check again on a brand new FDM
#
self.sandbox.delete_csv_files()
# Because JSBSim internals use static pointers, we cannot rely on Python
# garbage collector to decide when the FDM is destroyed otherwise we can
# get dangling pointers.
del fdm
fdm = CreateFDM(self.sandbox)
fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', 'c1722.xml'))
fdm.run_ic()
fdm.set_output_filename(0,'oops.csv') # Oops!! Changed my mind
ExecuteUntil(fdm, 1.0)
self.assertTrue(not self.sandbox.exists('oops.csv'),
#.........这里部分代码省略.........