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


Python attr.evolve方法代码示例

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


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

示例1: test_commit_metadata_not_interesting

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_commit_metadata_not_interesting(self, attr_checker, git, isdir):
    attr_checker.side_effect = [False]
    isdir.return_value = False
    spec = attr.evolve(self.default_spec, recipes_path='recipes')

    git.side_effect = multi(*([
      self.g(['init', 'dir']),
      self.g_ls_remote(),
    ] + self.g_metadata_calls(config=spec)))

    result = fetch.GitBackend('dir', 'repo').commit_metadata('ref')
    self.assertEqual(result, fetch.CommitMetadata(
      revision = 'a'*40,
      author_email = 'foo@example.com',
      commit_timestamp = 1492131405,
      message_lines = ('hello', 'world'),
      spec = spec,
      roll_candidate = False,
    ))
    self.assertMultiDone(git)
    attr_checker.assert_called_with('a'*40, set(['foo', 'bar'])) 
开发者ID:luci,项目名称:recipes-py,代码行数:23,代码来源:fetch_test.py

示例2: test_commit_metadata_IRC_change

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_commit_metadata_IRC_change(self, git, isdir):
    isdir.return_value = False
    spec = attr.evolve(self.default_spec, recipes_path='recipes')

    git.side_effect = multi(*([
      self.g(['init', 'dir']),
      self.g_ls_remote(),
    ] + self.g_metadata_calls(config=spec, diff=tuple([IRC]))))

    result = fetch.GitBackend('dir', 'repo').commit_metadata('ref')
    self.assertEqual(result, fetch.CommitMetadata(
      revision = 'a'*40,
      author_email = 'foo@example.com',
      commit_timestamp = 1492131405,
      message_lines = ('hello', 'world'),
      spec = spec,
      roll_candidate = True,
    ))
    self.assertMultiDone(git) 
开发者ID:luci,项目名称:recipes-py,代码行数:21,代码来源:fetch_test.py

示例3: test_commit_metadata_recipes_change

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_commit_metadata_recipes_change(self, git, isdir):
    isdir.return_value = False
    spec = attr.evolve(self.default_spec, recipes_path='recipes')

    git.side_effect = multi(*([
      self.g(['init', 'dir']),
      self.g_ls_remote()
    ] + self.g_metadata_calls(config=spec, diff=tuple(['recipes/foo']))))

    result = fetch.GitBackend('dir', 'repo').commit_metadata('ref')
    self.assertEqual(result, fetch.CommitMetadata(
      revision = 'a'*40,
      author_email = 'foo@example.com',
      commit_timestamp = 1492131405,
      message_lines = ('hello', 'world'),
      spec = spec,
      roll_candidate = True,
    ))
    self.assertMultiDone(git) 
开发者ID:luci,项目名称:recipes-py,代码行数:21,代码来源:fetch_test.py

示例4: test_commit_metadata_tagged_change

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_commit_metadata_tagged_change(self, attr_checker, git, isdir):
    attr_checker.side_effect = [True]
    isdir.return_value = False
    spec = attr.evolve(self.default_spec, recipes_path='recipes')

    git.side_effect = multi(*([
      self.g(['init', 'dir']),
      self.g_ls_remote()
    ] + self.g_metadata_calls(config=spec)))

    result = fetch.GitBackend('dir', 'repo').commit_metadata('ref')
    self.assertEqual(result, fetch.CommitMetadata(
      revision = 'a'*40,
      author_email = 'foo@example.com',
      commit_timestamp = 1492131405,
      message_lines = ('hello', 'world'),
      spec = spec,
      roll_candidate = True,
    ))
    self.assertMultiDone(git)
    attr_checker.assert_called_with('a'*40, set(['foo', 'bar'])) 
开发者ID:luci,项目名称:recipes-py,代码行数:23,代码来源:fetch_test.py

示例5: test_commit_metadata_only_gitattributes_file

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_commit_metadata_only_gitattributes_file(self, git, isdir):
    isdir.return_value = False
    spec = attr.evolve(self.default_spec, recipes_path='recipes')

    git.side_effect = multi(*([
      self.g(['init', 'dir']),
      self.g_ls_remote()
    ] + self.g_metadata_calls(config=spec, diff=['.gitattributes'])))

    result = fetch.GitBackend('dir', 'repo').commit_metadata('ref')
    self.assertEqual(result, fetch.CommitMetadata(
      revision = 'a'*40,
      author_email = 'foo@example.com',
      commit_timestamp = 1492131405,
      message_lines = ('hello', 'world'),
      spec = spec,
      roll_candidate = True,
    ))
    self.assertMultiDone(git) 
开发者ID:luci,项目名称:recipes-py,代码行数:21,代码来源:fetch_test.py

示例6: _style_columns

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def _style_columns(columns):
    """Generate a list of column styles given some styled columns.

    The 'Table' object in Grafana separates column definitions from column
    style definitions. However, when defining dashboards it can be very useful
    to define the style next to the column. This function helps that happen.

    :param columns: A list of (Column, ColumnStyle) pairs. The associated
        ColumnStyles must not have a 'pattern' specified. You can also provide
       'None' if you want to use the default styles.
    :return: A list of ColumnStyle values that can be used in a Grafana
        definition.
    """
    new_columns = []
    styles = []
    for column, style in columns:
        new_columns.append(column)
        if not style:
            continue
        if style.pattern and style.pattern != column.text:
            raise ValueError(
                "ColumnStyle pattern (%r) must match the column name (%r) if "
                "specified" % (style.pattern, column.text))
        styles.append(attr.evolve(style, pattern=column.text))
    return new_columns, styles 
开发者ID:weaveworks,项目名称:grafanalib,代码行数:27,代码来源:core.py

示例7: auto_bucket_agg_ids

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def auto_bucket_agg_ids(self):
        """Give unique IDs all bucketAggs without ID.

        Returns a new ``ElasticsearchTarget`` that is the same as this one,
        except all of the bucketAggs have their ``id`` property set. Any panels
        which had an ``id`` property set will keep that property, all others
        will have auto-generated IDs provided for them.

        If the bucketAggs don't have unique ID associated with it, the
        generated graph will be broken.
        """
        ids = set([agg.id for agg in self.bucketAggs if agg.id])
        auto_ids = (i for i in itertools.count(1) if i not in ids)

        def set_id(agg):
            if agg.id:
                return agg

            return attr.evolve(agg, id=next(auto_ids))

        return self._map_bucket_aggs(set_id) 
开发者ID:weaveworks,项目名称:grafanalib,代码行数:23,代码来源:elasticsearch.py

示例8: clear_caches

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def clear_caches(self):
        for key in ["executables", "python_executables", "version_dict", "path_entries"]:
            if key in self.__dict__:
                del self.__dict__[key]
        for finder in list(self.__finders.keys()):
            del self.__finders[finder]
        self.__finders = {}
        return attr.evolve(
            self,
            executables=[],
            python_executables={},
            python_version_dict=defaultdict(list),
            version_dict=defaultdict(list),
            pyenv_finder=None,
            windows_finder=None,
            asdf_finder=None,
            path_order=[],
            paths=defaultdict(PathEntry),
        ) 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:21,代码来源:path.py

示例9: rename_files

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def rename_files(self, rename):
        """Rename files using the path mapping function."""
        files = []

        for file_ in self.files:
            new_path = rename(file_.path)
            new_file = attr.evolve(file_, path=new_path)
            if not self.find_file(new_file.path):
                files.append(new_file)
            else:
                raise FileExistsError

        renamed = attr.evolve(self, files=files)
        setattr(renamed, '__reference__', self.__reference__)

        if self.__source__:
            setattr(renamed, '__source__', self.__source__.copy())

        return renamed 
开发者ID:SwissDataScienceCenter,项目名称:renku-python,代码行数:21,代码来源:datasets.py

示例10: test_visual_advanced_ppo

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_visual_advanced_ppo(vis_encode_type, num_visual):
    env = SimpleEnvironment(
        [BRAIN_NAME],
        use_discrete=True,
        num_visual=num_visual,
        num_vector=0,
        step_size=0.5,
        vis_obs_size=(36, 36, 3),
    )
    new_networksettings = attr.evolve(
        SAC_CONFIG.network_settings, vis_encode_type=EncoderType(vis_encode_type)
    )
    new_hyperparams = attr.evolve(PPO_CONFIG.hyperparameters, learning_rate=3.0e-4)
    config = attr.evolve(
        PPO_CONFIG,
        hyperparameters=new_hyperparams,
        network_settings=new_networksettings,
        max_steps=500,
        summary_freq=100,
    )
    # The number of steps is pretty small for these encoders
    _check_environment_trains(env, {BRAIN_NAME: config}, success_threshold=0.5) 
开发者ID:StepNeverStop,项目名称:RLs,代码行数:24,代码来源:test_simple_rl.py

示例11: test_recurrent_ppo

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_recurrent_ppo(use_discrete):
    env = MemoryEnvironment([BRAIN_NAME], use_discrete=use_discrete)
    new_network_settings = attr.evolve(
        PPO_CONFIG.network_settings,
        memory=NetworkSettings.MemorySettings(memory_size=16),
    )
    new_hyperparams = attr.evolve(
        PPO_CONFIG.hyperparameters, learning_rate=1.0e-3, batch_size=64, buffer_size=128
    )
    config = attr.evolve(
        PPO_CONFIG,
        hyperparameters=new_hyperparams,
        network_settings=new_network_settings,
        max_steps=5000,
    )
    _check_environment_trains(env, {BRAIN_NAME: config}, success_threshold=0.9) 
开发者ID:StepNeverStop,项目名称:RLs,代码行数:18,代码来源:test_simple_rl.py

示例12: test_recurrent_sac

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_recurrent_sac(use_discrete):
    step_size = 0.2 if use_discrete else 1.0
    env = MemoryEnvironment(
        [BRAIN_NAME], use_discrete=use_discrete, step_size=step_size
    )
    new_networksettings = attr.evolve(
        SAC_CONFIG.network_settings,
        memory=NetworkSettings.MemorySettings(memory_size=16, sequence_length=16),
    )
    new_hyperparams = attr.evolve(
        SAC_CONFIG.hyperparameters,
        batch_size=128,
        learning_rate=1e-3,
        buffer_init_steps=1000,
        steps_per_update=2,
    )
    config = attr.evolve(
        SAC_CONFIG,
        hyperparameters=new_hyperparams,
        network_settings=new_networksettings,
        max_steps=5000,
    )
    _check_environment_trains(env, {BRAIN_NAME: config}) 
开发者ID:StepNeverStop,项目名称:RLs,代码行数:25,代码来源:test_simple_rl.py

示例13: test_simple_asymm_ghost_fails

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_simple_asymm_ghost_fails(use_discrete):
    # Make opponent for asymmetric case
    brain_name_opp = BRAIN_NAME + "Opp"
    env = SimpleEnvironment(
        [BRAIN_NAME + "?team=0", brain_name_opp + "?team=1"], use_discrete=use_discrete
    )
    # This config should fail because the team that us not learning when both have reached
    # max step should be executing the initial, untrained poliy.
    self_play_settings = SelfPlaySettings(
        play_against_latest_model_ratio=0.0,
        save_steps=5000,
        swap_steps=5000,
        team_change=2000,
    )
    config = attr.evolve(PPO_CONFIG, self_play=self_play_settings, max_steps=2000)
    _check_environment_trains(
        env, {BRAIN_NAME: config, brain_name_opp: config}, success_threshold=None
    )
    processed_rewards = [
        default_reward_processor(rewards) for rewards in env.final_rewards.values()
    ]
    success_threshold = 0.9
    assert any(reward > success_threshold for reward in processed_rewards) and any(
        reward < success_threshold for reward in processed_rewards
    ) 
开发者ID:StepNeverStop,项目名称:RLs,代码行数:27,代码来源:test_simple_rl.py

示例14: test_gail_visual_ppo

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_gail_visual_ppo(simple_record, use_discrete):
    demo_path = simple_record(use_discrete, num_visual=1, num_vector=0)
    env = SimpleEnvironment(
        [BRAIN_NAME],
        num_visual=1,
        num_vector=0,
        use_discrete=use_discrete,
        step_size=0.2,
    )
    bc_settings = BehavioralCloningSettings(demo_path=demo_path, steps=1500)
    reward_signals = {
        RewardSignalType.GAIL: GAILSettings(encoding_size=32, demo_path=demo_path)
    }
    hyperparams = attr.evolve(PPO_CONFIG.hyperparameters, learning_rate=3e-4)
    config = attr.evolve(
        PPO_CONFIG,
        reward_signals=reward_signals,
        hyperparameters=hyperparams,
        behavioral_cloning=bc_settings,
        max_steps=1000,
    )
    _check_environment_trains(env, {BRAIN_NAME: config}, success_threshold=0.9) 
开发者ID:StepNeverStop,项目名称:RLs,代码行数:24,代码来源:test_simple_rl.py

示例15: test_gail_visual_sac

# 需要导入模块: import attr [as 别名]
# 或者: from attr import evolve [as 别名]
def test_gail_visual_sac(simple_record, use_discrete):
    demo_path = simple_record(use_discrete, num_visual=1, num_vector=0)
    env = SimpleEnvironment(
        [BRAIN_NAME],
        num_visual=1,
        num_vector=0,
        use_discrete=use_discrete,
        step_size=0.2,
    )
    bc_settings = BehavioralCloningSettings(demo_path=demo_path, steps=1000)
    reward_signals = {
        RewardSignalType.GAIL: GAILSettings(encoding_size=32, demo_path=demo_path)
    }
    hyperparams = attr.evolve(
        SAC_CONFIG.hyperparameters, learning_rate=3e-4, batch_size=16
    )
    config = attr.evolve(
        SAC_CONFIG,
        reward_signals=reward_signals,
        hyperparameters=hyperparams,
        behavioral_cloning=bc_settings,
        max_steps=500,
    )
    _check_environment_trains(env, {BRAIN_NAME: config}, success_threshold=0.9) 
开发者ID:StepNeverStop,项目名称:RLs,代码行数:26,代码来源:test_simple_rl.py


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