本文整理汇总了Python中TestUtilities.TestUtilities.generateTestFilePath方法的典型用法代码示例。如果您正苦于以下问题:Python TestUtilities.generateTestFilePath方法的具体用法?Python TestUtilities.generateTestFilePath怎么用?Python TestUtilities.generateTestFilePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestUtilities.TestUtilities
的用法示例。
在下文中一共展示了TestUtilities.generateTestFilePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBackengineDefaultPaths
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testBackengineDefaultPaths(self):
""" Test that we can start a calculation with default paths given. """
# Prepare input.
shutil.copytree( TestUtilities.generateTestFilePath( 'pmi_out' ), os.path.abspath( 'pmi' ) )
# Ensure proper cleanup.
self.__dirs_to_remove.append( os.path.abspath( 'pmi') )
self.__dirs_to_remove.append( os.path.abspath( 'diffr' ) )
parameters={ 'uniform_rotation': True,
'calculate_Compton' : False,
'slice_interval' : 100,
'number_of_slices' : 2,
'pmi_start_ID' : 1,
'pmi_stop_ID' : 1,
'number_of_diffraction_patterns' : 2,
'beam_parameter_file' : TestUtilities.generateTestFilePath('s2e.beam'),
'beam_geometry_file' : TestUtilities.generateTestFilePath('s2e.geom'),
'number_of_MPI_processes' : 2,
}
# Construct the object.
diffractor = SingFELPhotonDiffractor(parameters=parameters)
# Call backengine.
status = diffractor.backengine()
# Check successful completion.
self.assertEqual(status, 0)
# Check expected files exist.
self.assertTrue( os.path.isdir( os.path.abspath( 'diffr' ) ) )
self.assertIn( 'diffr_out_0000001.h5', os.listdir( os.path.abspath( 'diffr' ) ) )
self.assertIn( 'diffr_out_0000002.h5', os.listdir( os.path.abspath( 'diffr' ) ) )
示例2: testBackengineInputDir
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testBackengineInputDir(self):
""" Test that we can start a test calculation if the input path is a directory. """
# Cleanup.
self.__dirs_to_remove.append('diffr')
parameters={ 'uniform_rotation': True,
'calculate_Compton' : False,
'slice_interval' : 100,
'number_of_slices' : 2,
'pmi_start_ID' : 1,
'pmi_stop_ID' : 2,
'number_of_diffraction_patterns' : 2,
'beam_parameter_file': TestUtilities.generateTestFilePath('s2e.beam'),
'beam_geometry_file' : TestUtilities.generateTestFilePath('s2e.geom'),
'number_of_MPI_processes' : 2,
}
# Construct the object.
diffractor = SingFELPhotonDiffractor(parameters=parameters, input_path=TestUtilities.generateTestFilePath('pmi_out'), output_path='diffr')
# Call backengine.
status = diffractor.backengine()
# Check successful completion.
self.assertEqual(status, 0)
示例3: testConstruction
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testConstruction(self):
""" Test the default constructor of this class. """
# Setup a minimal experiment simulation.
source_input = TestUtilities.generateTestFilePath('FELsource_out.h5')
diffr_input = TestUtilities.generateTestFilePath('pmi_out.h5')
pmi_input = TestUtilities.generateTestFilePath('prop_out.h5')
photon_source = XFELPhotonSource(parameters=None, input_path=source_input, output_path='FELsource_out.h5')
photon_propagator = XFELPhotonPropagator(parameters=None, input_path='FELsource_out.h5', output_path='prop_out.h5')
photon_interactor = FakePhotonMatterInteractor(parameters=None, input_path=pmi_input, output_path='pmi_out.h5')
diffraction_parameters={ 'uniform_rotation': True,
'calculate_Compton' : False,
'slice_interval' : 100,
'number_of_slices' : 2,
'pmi_start_ID' : 1,
'pmi_stop_ID' : 1,
'number_of_diffraction_patterns' : 2,
'beam_parameter_file' : TestUtilities.generateTestFilePath('s2e.beam'),
'beam_geometry_file' : TestUtilities.generateTestFilePath('s2e.geom'),
}
photon_diffractor = SingFELPhotonDiffractor(parameters=diffraction_parameters, input_path=diffr_input, output_path='diffr_out.h5')
photon_detector = PerfectPhotonDetector(parameters = None, input_path='diffr_out.h5', output_path='detector_out.h5')
photon_analyzer = S2EReconstruction(parameters=None, input_path='detector_out.h5', output_path='analyzer_out.h5')
pxs = PhotonExperimentSimulation(photon_source=photon_source,
photon_propagator=photon_propagator,
photon_interactor=photon_interactor,
photon_diffractor=photon_diffractor,
photon_detector=photon_detector,
photon_analyzer=photon_analyzer,
)
# Check instance.
self.assertIsInstance( pxs, PhotonExperimentSimulation )
示例4: testDefaultConstruction
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testDefaultConstruction(self):
""" Testing the default construction of the class. """
# Prepare input.
shutil.copytree( TestUtilities.generateTestFilePath( 'pmi_out' ), os.path.abspath( 'pmi' ) )
# Ensure proper cleanup.
self.__dirs_to_remove.append( os.path.abspath( 'pmi') )
self.__dirs_to_remove.append( os.path.abspath( 'diffr' ) )
# Set up parameters.
parameters={ 'uniform_rotation': True,
'calculate_Compton' : False,
'slice_interval' : 100,
'number_of_slices' : 2,
'pmi_start_ID' : 1,
'pmi_stop_ID' : 1,
'number_of_diffraction_patterns' : 2,
'beam_parameter_file' : TestUtilities.generateTestFilePath('s2e.beam'),
'beam_geometry_file' : TestUtilities.generateTestFilePath('s2e.geom'),
'number_of_MPI_processes' : 2,
}
# Construct the object.
diffractor = SingFELPhotonDiffractor(parameters=parameters)
self.assertIsInstance(diffractor, SingFELPhotonDiffractor)
self.assertEqual( diffractor.input_path, os.path.abspath( 'pmi') )
self.assertEqual( diffractor.output_path, os.path.abspath( 'diffr') )
示例5: testDataInterfaceQueries
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testDataInterfaceQueries(self):
""" Check that the data interface queries work. """
# Get test instance.
# Setup pmi parameters.
pmi_parameters = {'number_of_trajectories' : 1,
'number_of_steps' : 100,
'sample_path' : TestUtilities.generateTestFilePath('sample.h5')
}
test_interactor = XMDYNDemoPhotonMatterInteractor(parameters=pmi_parameters,
input_path=self.input_h5,
output_path='pmi_out.h5',
sample_path = TestUtilities.generateTestFilePath('sample.h5') )
# Get expected and provided data descriptors.
expected_data = test_interactor.expectedData()
provided_data = test_interactor.providedData()
# Check types are correct.
self.assertIsInstance(expected_data, list)
self.assertIsInstance(provided_data, list)
for d in expected_data:
self.assertIsInstance(d, str)
self.assertEqual(d[0], '/')
for d in provided_data:
self.assertIsInstance(d, str)
self.assertEqual(d[0], '/')
示例6: testCalculatorQueries
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testCalculatorQueries(self):
""" Test that the calculator queries return the correct calculators. """
# Setup a minimal experiment simulation.
source_input = TestUtilities.generateTestFilePath("FELsource_out.h5")
diffr_input = TestUtilities.generateTestFilePath("pmi_out_0000001.h5")
pmi_input = TestUtilities.generateTestFilePath("prop_out.h5")
photon_source = XFELPhotonSource(parameters=None, input_path=source_input, output_path="FELsource_out.h5")
photon_propagator = XFELPhotonPropagator(
parameters=None, input_path="FELsource_out.h5", output_path="prop_out.h5"
)
photon_interactor = XMDYNDemoPhotonMatterInteractor(
parameters=None, input_path=pmi_input, output_path="pmi_out.h5", sample_path=self.__sample_path
)
diffraction_parameters = {
"uniform_rotation": True,
"calculate_Compton": False,
"slice_interval": 100,
"number_of_slices": 2,
"pmi_start_ID": 1,
"pmi_stop_ID": 1,
"number_of_diffraction_patterns": 2,
"beam_parameter_file": TestUtilities.generateTestFilePath("s2e.beam"),
"beam_geometry_file": TestUtilities.generateTestFilePath("s2e.geom"),
"number_of_MPI_processes": 2,
}
photon_diffractor = SingFELPhotonDiffractor(
parameters=diffraction_parameters, input_path=diffr_input, output_path="diffr_out.h5"
)
photon_detector = IdealPhotonDetector(parameters=None, input_path="diffr_out.h5", output_path="detector_out.h5")
photon_analyzer = S2EReconstruction(
parameters=None, input_path="detector_out.h5", output_path="analyzer_out.h5"
)
pxs = PhotonExperimentSimulation(
photon_source=photon_source,
photon_propagator=photon_propagator,
photon_interactor=photon_interactor,
photon_diffractor=photon_diffractor,
photon_detector=photon_detector,
photon_analyzer=photon_analyzer,
)
# Check queries.
self.assertIs(pxs.photon_source, photon_source)
self.assertIs(pxs.photon_propagator, photon_propagator)
self.assertIs(pxs.photon_interactor, photon_interactor)
self.assertIs(pxs.photon_diffractor, photon_diffractor)
self.assertIs(pxs.photon_detector, photon_detector)
self.assertIs(pxs.photon_analyzer, photon_analyzer)
示例7: testSingleDiffrFileMultiplePatterns
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testSingleDiffrFileMultiplePatterns(self):
""" Test that EMC accepts a single (new style) input file from diffraction containing multiple patterns. """
# Cleanup.
self.__files_to_remove.append('orient_out.h5')
# Construct the object.
emc_parameters = {"initial_number_of_quaternions" : 3,
"max_number_of_quaternions" : 4,
"max_number_of_iterations" : 3,
"min_error" : 1.e-6,
"beamstop" : True,
"detailed_output" : True,
}
emc = EMCOrientation(parameters=emc_parameters,
input_path=TestUtilities.generateTestFilePath("diffr_newstyle.h5"),
output_path='orient_out.h5',
tmp_files_path=None,
run_files_path=None,)
# Call backengine.
status = emc.backengine()
# Check success.
self.assertEqual(status, 0)
示例8: testDefaultConstruction
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testDefaultConstruction(self):
""" Testing the default construction of the class. """
# Construct the object.
interactor = XMDYNDemoPhotonMatterInteractor(sample_path = TestUtilities.generateTestFilePath('sample.h5') )
self.assertIsInstance(interactor, XMDYNDemoPhotonMatterInteractor)
示例9: testBackengine
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testBackengine(self):
""" Check that the backengine method works correctly. """
# Clean up.
self.__dirs_to_remove.append('pmi')
# Get test instance.
pmi_parameters = {'number_of_trajectories' : 1,
'number_of_steps' : 100,
}
test_interactor = XMDYNDemoPhotonMatterInteractor(parameters=pmi_parameters,
input_path=self.input_h5,
output_path='pmi',
sample_path = TestUtilities.generateTestFilePath('sample.h5') )
# Call backengine
status = test_interactor.backengine()
# Check that the backengine returned zero.
self.assertEqual(status, 0)
# Check we have generated the expected output.
self.assertTrue( 'pmi_out_0000001.h5' in os.listdir( test_interactor.output_path ) )
示例10: testSingleFile
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testSingleFile(self):
""" Test that saveH5() generates only one linked hdf. """
diffraction_parameters={ 'uniform_rotation': True,
'calculate_Compton' : True,
'slice_interval' : 100,
'number_of_slices' : 2,
'pmi_start_ID' : 1,
'pmi_stop_ID' : 4,
'number_of_diffraction_patterns' : 2,
'beam_parameter_file': TestUtilities.generateTestFilePath('s2e.beam'),
'beam_geometry_file' : TestUtilities.generateTestFilePath('s2e.geom'),
'number_of_MPI_processes' : 8,
}
photon_diffractor = SingFELPhotonDiffractor(
parameters=diffraction_parameters,
input_path=TestUtilities.generateTestFilePath('pmi_out'),
output_path='diffr_newstyle')
# Cleanup.
self.__dirs_to_remove.append(photon_diffractor.output_path)
# Run backengine and convert files.
photon_diffractor.backengine()
photon_diffractor.saveH5()
# Cleanup new style files.
self.__files_to_remove.append(photon_diffractor.output_path)
# Check that only one file was generated.
self.assertTrue( os.path.isfile( photon_diffractor.output_path ))
# Open the file for reading.
h5_filehandle = h5py.File( photon_diffractor.output_path, 'r')
# Count groups under /data.
number_of_patterns = len(h5_filehandle.keys()) - 3
self.assertEqual( number_of_patterns, 8 )
# Assert global metadata is present.
self.assertIn("params", h5_filehandle.keys() )
self.assertIn("version", h5_filehandle.keys() )
self.assertIn("info", h5_filehandle.keys() )
self.assertIn("geom", h5_filehandle["params"].keys() )
示例11: testConstructionParameters
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testConstructionParameters(self):
""" Check we can construct with a parameter object. """
parameters = SingFELPhotonDiffractorParameters(uniform_rotation = True,
calculate_Compton = False,
slice_interval = 100,
number_of_slices = 2,
pmi_start_ID = 1,
pmi_stop_ID = 1,
number_of_diffraction_patterns = 2,
beam_parameter_file = TestUtilities.generateTestFilePath('s2e.beam'),
beam_geometry_file = TestUtilities.generateTestFilePath('s2e.geom'),
number_of_MPI_processes = 2,
)
diffractor = SingFELPhotonDiffractor(parameters=parameters, input_path=self.input_h5, output_path='diffr_out.h5')
# Check instance.
self.assertIsInstance( diffractor, SingFELPhotonDiffractor )
示例12: testShapedConstruction
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testShapedConstruction(self):
""" Testing the construction of the class with parameters. """
parameters={ 'uniform_rotation': True,
'calculate_Compton' : False,
'slice_interval' : 100,
'number_of_slices' : 2,
'pmi_start_ID' : 1,
'pmi_stop_ID' : 1,
'number_of_diffraction_patterns' : 2,
'beam_parameter_file' : TestUtilities.generateTestFilePath('s2e.beam'),
'beam_geometry_file' : TestUtilities.generateTestFilePath('s2e.geom'),
'number_of_MPI_processes' : 2,
}
# Construct the object.
diffractor = SingFELPhotonDiffractor(parameters=parameters, input_path=self.input_h5, output_path='diffr_out.h5')
self.assertIsInstance(diffractor, SingFELPhotonDiffractor)
示例13: testOPMD
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testOPMD(self):
""" Check that the input directory scanner filters out the opmd files."""
# Clean up.
self.__dirs_to_remove.append('pmi')
# Setup parameters.
pmi_parameters = {'number_of_trajectories' : 10,
'number_of_steps' : 100,
}
test_interactor = XMDYNDemoPhotonMatterInteractor(parameters=pmi_parameters,
input_path=TestUtilities.generateTestFilePath('prop_out'),
output_path='pmi',
sample_path=TestUtilities.generateTestFilePath('sample.h5') )
# Call backengine
status = test_interactor.backengine()
self.assertEqual(status, 0 )
示例14: testBackengineDefaultPaths
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testBackengineDefaultPaths(self):
""" Check that the backengine method works correctly. """
# Prepare input.
shutil.copytree( TestUtilities.generateTestFilePath('prop_out'), os.path.abspath( 'prop' ) )
self.__dirs_to_remove.append( 'prop' )
self.__dirs_to_remove.append( 'pmi' )
test_interactor = XMDYNDemoPhotonMatterInteractor(sample_path=TestUtilities.generateTestFilePath('sample.h5') )
# Call backengine
status = test_interactor.backengine()
# Check that the backengine returned zero.
self.assertEqual(status, 0)
# Check we have generated the expected output.
self.assertTrue( os.path.isdir( os.path.abspath( 'prop' ) ) )
self.assertIn( 'pmi_out_0000001.h5' , os.listdir( test_interactor.output_path ) )
self.assertIn( 'pmi_out_0000002.h5' , os.listdir( test_interactor.output_path ) )
示例15: testBackengineMultipleInputFile
# 需要导入模块: from TestUtilities import TestUtilities [as 别名]
# 或者: from TestUtilities.TestUtilities import generateTestFilePath [as 别名]
def testBackengineMultipleInputFile(self):
""" Test a backengine run with multiple input files. """
# Construct the object.
xfel_propagator = XFELPhotonPropagator( parameters=None, input_path=TestUtilities.generateTestFilePath( 'FELsource_out' ), output_path='prop_out' )
# Call the backengine.
status = xfel_propagator.backengine()
# Check backengine returned sanely.
self.assertEqual( status, 0 )
# Ensure clean-up.
self.__dirs_to_remove.append(xfel_propagator.output_path)