当前位置: 首页>>代码示例>>Python>>正文


Python absltest.get_default_test_tmpdir方法代码示例

本文整理汇总了Python中absl.testing.absltest.get_default_test_tmpdir方法的典型用法代码示例。如果您正苦于以下问题:Python absltest.get_default_test_tmpdir方法的具体用法?Python absltest.get_default_test_tmpdir怎么用?Python absltest.get_default_test_tmpdir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在absl.testing.absltest的用法示例。


在下文中一共展示了absltest.get_default_test_tmpdir方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_run_pose_env_collect

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def test_run_pose_env_collect(self, demo_policy_cls):
    urdf_root = pose_env.get_pybullet_urdf_root()

    config_dir = 'research/pose_env/configs'
    gin_config = os.path.join(
        FLAGS.test_srcdir, config_dir, 'run_random_collect.gin')
    gin.parse_config_file(gin_config)
    tmp_dir = absltest.get_default_test_tmpdir()
    root_dir = os.path.join(tmp_dir, str(demo_policy_cls))
    gin.bind_parameter('PoseToyEnv.urdf_root', urdf_root)
    gin.bind_parameter(
        'collect_eval_loop.root_dir', root_dir)
    gin.bind_parameter('run_meta_env.num_tasks', 2)
    gin.bind_parameter('run_meta_env.num_episodes_per_adaptation', 1)
    gin.bind_parameter(
        'collect_eval_loop.policy_class', demo_policy_cls)
    continuous_collect_eval.collect_eval_loop()
    output_files = tf.io.gfile.glob(os.path.join(
        root_dir, 'policy_collect', '*.tfrecord'))
    self.assertLen(output_files, 2) 
开发者ID:google-research,项目名称:tensor2robot,代码行数:22,代码来源:continuous_collect_eval_test.py

示例2: setUp

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def setUp(self):
    super(MakeTrainTestSplitTest, self).setUp()
    test_data_directory = test_utils.test_dir('testdata/')
    self.temp_dir = tempfile.mkdtemp(dir=absltest.get_default_test_tmpdir())
    test_sdf_file_large = os.path.join(test_data_directory, 'test_14_mend.sdf')
    test_sdf_file_small = os.path.join(test_data_directory, 'test_2_mend.sdf')

    max_atoms = ms_constants.MAX_ATOMS
    self.mol_list_large = parse_sdf_utils.get_sdf_to_mol(
        test_sdf_file_large, max_atoms=max_atoms)
    self.mol_list_small = parse_sdf_utils.get_sdf_to_mol(
        test_sdf_file_small, max_atoms=max_atoms)
    self.inchikey_dict_large = train_test_split_utils.make_inchikey_dict(
        self.mol_list_large)
    self.inchikey_dict_small = train_test_split_utils.make_inchikey_dict(
        self.mol_list_small)
    self.inchikey_list_large = list(self.inchikey_dict_large.keys())
    self.inchikey_list_small = list(self.inchikey_dict_small.keys()) 
开发者ID:brain-research,项目名称:deep-molecular-massspec,代码行数:20,代码来源:make_train_test_split_test.py

示例3: test_atomic_write

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def test_atomic_write(self):
    for name in ['foo.csv', 'baz.csv.bz2']:
      dataframe = pd.DataFrame(dict(a=[1, 2], b=[4.0, 5.0]))
      output_file = os.path.join(absltest.get_default_test_tmpdir(), name)
      utils_impl.atomic_write_to_csv(dataframe, output_file)
      dataframe2 = pd.read_csv(output_file, index_col=0)
      pd.testing.assert_frame_equal(dataframe, dataframe2)

      # Overwriting
      dataframe3 = pd.DataFrame(dict(a=[1, 2, 3], b=[4.0, 5.0, 6.0]))
      utils_impl.atomic_write_to_csv(dataframe3, output_file)
      dataframe4 = pd.read_csv(output_file, index_col=0)
      pd.testing.assert_frame_equal(dataframe3, dataframe4) 
开发者ID:tensorflow,项目名称:federated,代码行数:15,代码来源:utils_impl_test.py

示例4: test_atomic_read

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def test_atomic_read(self):
    for name in ['foo.csv', 'baz.csv.bz2']:
      dataframe = pd.DataFrame(dict(a=[1, 2], b=[4.0, 5.0]))
      csv_file = os.path.join(absltest.get_default_test_tmpdir(), name)
      utils_impl.atomic_write_to_csv(dataframe, csv_file)

      dataframe2 = utils_impl.atomic_read_from_csv(csv_file)
      pd.testing.assert_frame_equal(dataframe, dataframe2) 
开发者ID:tensorflow,项目名称:federated,代码行数:10,代码来源:utils_impl_test.py

示例5: setUp

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def setUp(self):
    super(SpectraPredictorTest, self).setUp()
    self.np_fingerprint_input = np.ones((2, 4096))
    self.np_mol_weight_input = np.reshape(np.array([18., 16.]), (2, 1))
    self.test_data_directory = test_utils.test_dir("testdata/")
    self.temp_dir = tempfile.mkdtemp(dir=absltest.get_default_test_tmpdir())
    self.test_file_short = os.path.join(self.test_data_directory,
                                        "test_2_mend.sdf") 
开发者ID:brain-research,项目名称:deep-molecular-massspec,代码行数:10,代码来源:spectra_predictor_test.py

示例6: setUp

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def setUp(self):
    self.temp_dir = tempfile.mkdtemp(dir=absltest.get_default_test_tmpdir()) 
开发者ID:brain-research,项目名称:deep-molecular-massspec,代码行数:4,代码来源:util_test.py

示例7: testLoadValidationResult

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def testLoadValidationResult(self):
    result = validation_result_pb2.ValidationResult(validation_ok=True)
    path = os.path.join(absltest.get_default_test_tmpdir(), 'results.tfrecord')
    with tf.io.TFRecordWriter(path) as writer:
      writer.write(result.SerializeToString())
    loaded_result = model_eval_lib.load_validation_result(path)
    self.assertTrue(loaded_result.validation_ok) 
开发者ID:tensorflow,项目名称:model-analysis,代码行数:9,代码来源:model_eval_lib_test.py

示例8: testLoadValidationResultDir

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def testLoadValidationResultDir(self):
    result = validation_result_pb2.ValidationResult(validation_ok=True)
    path = os.path.join(absltest.get_default_test_tmpdir(),
                        constants.VALIDATIONS_KEY)
    with tf.io.TFRecordWriter(path) as writer:
      writer.write(result.SerializeToString())
    loaded_result = model_eval_lib.load_validation_result(os.path.dirname(path))
    self.assertTrue(loaded_result.validation_ok) 
开发者ID:tensorflow,项目名称:model-analysis,代码行数:10,代码来源:model_eval_lib_test.py

示例9: testLoadValidationResultEmptyFile

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def testLoadValidationResultEmptyFile(self):
    path = os.path.join(absltest.get_default_test_tmpdir(),
                        constants.VALIDATIONS_KEY)
    with tf.io.TFRecordWriter(path):
      pass
    with self.assertRaises(AssertionError):
      model_eval_lib.load_validation_result(path) 
开发者ID:tensorflow,项目名称:model-analysis,代码行数:9,代码来源:model_eval_lib_test.py

示例10: setUpModule

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def setUpModule():
  # Flags are not parsed when this test is invoked by `nosetests`, so we fall
  # back on using the default value for `--test_tmpdir`.
  if not FLAGS.is_parsed():
    FLAGS.test_tmpdir = absltest.get_default_test_tmpdir()
    FLAGS.mark_as_parsed() 
开发者ID:deepmind,项目名称:dm_control,代码行数:8,代码来源:export_with_assets_as_zip_test.py

示例11: setUpModule

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def setUpModule():
  # Flags are not parsed when this test is invoked by `nosetests`, so we fall
  # back on using the default value for ``--test_tmpdir`.
  if not FLAGS.is_parsed():
    FLAGS.test_tmpdir = absltest.get_default_test_tmpdir()
    FLAGS.mark_as_parsed() 
开发者ID:deepmind,项目名称:dm_control,代码行数:8,代码来源:export_with_assets_test.py

示例12: setup_debug_mode

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def setup_debug_mode(self, debug_mode_enabled, full_dump_enabled=False):
    if debug_mode_enabled:
      debugging.enable_debug_mode()
    else:
      debugging.disable_debug_mode()
    if full_dump_enabled:
      base_dir = absltest.get_default_test_tmpdir()
      self.dump_dir = os.path.join(base_dir, 'mjcf_debugging_test')
      shutil.rmtree(self.dump_dir, ignore_errors=True)
      os.mkdir(self.dump_dir)
    else:
      self.dump_dir = ''
    debugging.set_full_dump_dir(self.dump_dir) 
开发者ID:deepmind,项目名称:dm_control,代码行数:15,代码来源:debugging_test.py

示例13: test_save_images_on_failure

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def test_save_images_on_failure(self):
    random_state = np.random.RandomState(SEED)
    image1 = random_state.randint(0, 255, size=(64, 64, 3), dtype=np.uint8)
    image2 = random_state.randint(0, 255, size=(64, 64, 3), dtype=np.uint8)
    diff = (0.5 * (image2.astype(np.int16) - image1 + 255)).astype(np.uint8)
    message = 'exception message'
    output_dir = absltest.get_default_test_tmpdir()

    @image_utils.save_images_on_failure(output_dir=output_dir)
    def func():
      raise image_utils.ImagesNotCloseError(message, image1, image2)

    with six.assertRaisesRegex(self, image_utils.ImagesNotCloseError,
                               '{}.*'.format(message)):
      func()

    def validate_saved_file(name, expected_contents):
      path = os.path.join(output_dir, '{}-{}.png'.format('func', name))
      self.assertTrue(os.path.isfile(path))
      image = Image.open(path)
      actual_contents = np.array(image)
      np.testing.assert_array_equal(expected_contents, actual_contents)

    validate_saved_file('expected', image1)
    validate_saved_file('actual', image2)
    validate_saved_file('difference', diff) 
开发者ID:deepmind,项目名称:dm_control,代码行数:28,代码来源:image_utils_test.py

示例14: setUp

# 需要导入模块: from absl.testing import absltest [as 别名]
# 或者: from absl.testing.absltest import get_default_test_tmpdir [as 别名]
def setUp(self):
    """Sets up a dataset json for regular, baseline, and all_predicted cases."""
    super(MoleculeEstimatorTest, self).setUp()
    self.test_data_directory = test_utils.test_dir('testdata/')
    record_file = os.path.join(self.test_data_directory, 'test_14_record.gz')

    self.num_eval_examples = parse_sdf_utils.parse_info_file(record_file)[
        'num_examples']
    self.temp_dir = tempfile.mkdtemp(dir=absltest.get_default_test_tmpdir())
    self.default_dataset_config_file = os.path.join(self.temp_dir,
                                                    'dataset_config.json')
    self.baseline_dataset_config_file = os.path.join(
        self.temp_dir, 'baseline_dataset_config.json')
    self.all_predicted_dataset_config_file = os.path.join(
        self.temp_dir, 'all_predicted_dataset_config.json')

    dataset_names = [
        ds_constants.SPECTRUM_PREDICTION_TRAIN_KEY,
        ds_constants.SPECTRUM_PREDICTION_TEST_KEY,
        ds_constants.LIBRARY_MATCHING_OBSERVED_KEY,
        ds_constants.LIBRARY_MATCHING_PREDICTED_KEY,
        ds_constants.LIBRARY_MATCHING_QUERY_KEY
    ]

    default_dataset_config = {key: [record_file] for key in dataset_names}
    default_dataset_config[
        ds_constants.TRAINING_SPECTRA_ARRAY_KEY] = os.path.join(
            self.test_data_directory, 'test_14.spectra_library.npy')
    with tf.gfile.Open(self.default_dataset_config_file, 'w') as f:
      json.dump(default_dataset_config, f)

    # Test estimator behavior when predicted set is empty
    baseline_dataset_config = dict(
        [(key, [record_file])
         if key != ds_constants.LIBRARY_MATCHING_PREDICTED_KEY else (key, [])
         for key in dataset_names])
    baseline_dataset_config[
        ds_constants.TRAINING_SPECTRA_ARRAY_KEY] = os.path.join(
            self.test_data_directory, 'test_14.spectra_library.npy')
    with tf.gfile.Open(self.baseline_dataset_config_file, 'w') as f:
      json.dump(baseline_dataset_config, f)

    # Test estimator behavior when observed set is empty
    all_predicted_dataset_config = dict(
        [(key, [record_file])
         if key != ds_constants.LIBRARY_MATCHING_OBSERVED_KEY else (key, [])
         for key in dataset_names])
    all_predicted_dataset_config[
        ds_constants.TRAINING_SPECTRA_ARRAY_KEY] = os.path.join(
            self.test_data_directory, 'test_14.spectra_library.npy')
    with tf.gfile.Open(self.all_predicted_dataset_config_file, 'w') as f:
      json.dump(all_predicted_dataset_config, f) 
开发者ID:brain-research,项目名称:deep-molecular-massspec,代码行数:54,代码来源:molecule_estimator_test.py


注:本文中的absl.testing.absltest.get_default_test_tmpdir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。