當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。