• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyrsistent.pmap函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyrsistent.pmap函数的典型用法代码示例。如果您正苦于以下问题:Python pmap函数的具体用法?Python pmap怎么用?Python pmap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: __init__

  def __init__(self,agents=pvector([]),times=pset([]),forward=pmap({}),
               costs=pmap({}),requirements=pmap({}),backward=None,
               unsatisfied=None):
    self.cache = {}

    #### schedule bounds
    self.agents = agents  # vector of valid agents
    self.times = times  # set of valid times

    #### the schedule itself
    self.forward = forward  # agents -> times -> meeting ids

    # mids -> meeting (time, agents)
    if backward is None: self.backward = _backward_from_forward(self.forward)
    else: self.backward = backward

    #### schedule constraints
    self.requirements = requirements  # mids -> requirement type -> requirement

    # mids -> requirement type
    if unsatisfied is None:
      self.unsatisfied = pmap({mid: pset(self.requirements[mid].keys())
                               for mid in self.requirements.keys()})
    else: self.unsatisfied = unsatisfied

    self.costs = costs  # map from agents to meeting time costs functions
开发者ID:haberdashPI,项目名称:CSDscheduling,代码行数:26,代码来源:__init__.py


示例2: parse_file

def parse_file(excel_file):
  excel = pd.ExcelFile(excel_file)

  df = excel.parse('Schedule',index_col=0)
  df.columns = clean_up(df.columns)
  times,agents = parse_schedule(df)

  df = excel.parse('Meetings',index_col=None)
  df.columns = clean_up(df.columns)
  del df['area']
  df.name = clean_up(df.name)
  meetings = parse_student_meetings(df,3)

  offset = meetings[-1].mid+1
  df = excel.parse('Lab Meetings',index_col=None)
  df.columns = clean_up(df.columns)
  meetings += parse_lab_meetings(df,offset=offset)

  df = excel.parse('Schedule Preferences')
  df.columns = clean_up(df.columns)
  costs = parse_costs(df)

  final_meetings = {}
  for requirement in meetings:
    old = final_meetings.get(requirement.mid,pset())
    final_meetings[requirement.mid] = old.add(requirement)

  return Schedule(list(agents),pmap(),pmap(times),costs,
                  pmap(final_meetings),pmap())
开发者ID:haberdashPI,项目名称:CSDscheduling,代码行数:29,代码来源:parse.py


示例3: read_schedule_json

def read_schedule_json(obj):
    # reconstruct schedule information from json
    agents = pvector(obj['agents'])
    costs = pmap(obj['costs'])
    times = pset(map(as_timerange,obj['times']))
    forward = pmap({a: pmap({as_timerange(t): int(t['mid'])
                             for t in obj['meetings'][a] if t['mid'] != -1})
                    for a in agents})

    mids = pset([mid for ts in forward.values() for mid in ts.values()])

    # remove the mid 0, which marks an empty meeting (for unavailable times)
    if 0 in mids:
      mids = mids.remove(0)

    # update meetings and their requirements
    requirements = pmap({int(mid): pmap({r['type']: read_jsonable_requirement(r)
                                        for r in rs.values()})
                         for mid,rs in obj['requirements'].iteritems()})

    schedule = Schedule(agents=agents,times=times,forward=forward,
                        requirements=requirements,costs=costs)

    new_unsatisfied = schedule.unsatisfied
    for mid,rs in schedule.unsatisfied.iteritems():
      for rtype in rs:
        r = schedule.requirements[mid][rtype]
        if r.satisfied(schedule):
          new_unsatisfied = _mark_satisfied(new_unsatisfied,r)
        elif not r.satisfiable(schedule):
          raise RequirementException(r)
    schedule.unsatisfied = new_unsatisfied

    return schedule
开发者ID:haberdashPI,项目名称:CSDscheduling,代码行数:34,代码来源:__init__.py


示例4: test_dont_filter_out_non_recently_converged

 def test_dont_filter_out_non_recently_converged(self):
     """
     If a group was converged in the past but not recently, it will be
     cleaned from the ``recently_converged`` map, and it will be converged.
     """
     # g1: converged a while ago; divergent -> removed and converged
     # g2: converged recently; not divergent -> not converged
     # g3: converged a while ago; not divergent -> removed and not converged
     eff = self._converge_all_groups(['00_g1'])
     sequence = [
         (ReadReference(ref=self.currently_converging), lambda i: pset([])),
         (Log('converge-all-groups',
              dict(group_infos=[self.group_infos[0]],
                   currently_converging=[])),
          noop),
         (ReadReference(ref=self.recently_converged),
          lambda i: pmap({'g1': 4, 'g2': 10, 'g3': 0})),
         (Func(time.time), lambda i: 20),
         (ModifyReference(self.recently_converged,
                          match_func("literally anything",
                                     pmap({'g2': 10}))),
          noop),
         parallel_sequence([[self._expect_group_converged('00', 'g1')]])
     ]
     self.assertEqual(perform_sequence(sequence, eff), ['converged g1!'])
开发者ID:pratikmallya,项目名称:otter,代码行数:25,代码来源:test_service.py


示例5: setUp

 def setUp(self):
     self.format = mock.MagicMock(return_value=lambda x: str(x))
     self.label_1 = "a"
     self.label_2 = "b"
     self.true_positive = 8
     self.true_negative = 8
     self.false_positive = 8
     self.false_negative = 8
     self.confusion_table = ConfusionTable(
         self.label_1,
         self.true_positive,
         self.true_negative,
         self.false_positive,
         self.false_negative,
         self.format
     )
     self.predictions = pmap({
         self.label_1: pmap({
             self.label_1: self.true_positive,
             self.label_2: self.false_positive,
         }),
         self.label_2: pmap({
             self.label_1: self.false_negative,
             self.label_2: self.true_negative
         })
     })
开发者ID:RamonAranda,项目名称:ConfusionMatrix,代码行数:26,代码来源:confusion_table_generator_test.py


示例6: merge_results

def merge_results(results):
    """
    Given a list of dictionary results from episodes and the interesting keys, merge them into a single dictionary.
    Example: [{episode_id: 1, steps: 22}, {episode_id: 2, steps: 30}] -> {episode_id: [1, 2], steps: [22, 30]}
    """
    seed_dictionary = pmap({key: v() for key, _ in results[0].items()})
    return pmap(reduce(lambda result1, y: {key: value.append(y[key]) for key, value in result1.items()}, [seed_dictionary] + results))
开发者ID:xanderdunn,项目名称:options,代码行数:7,代码来源:results_writer.py


示例7: test_returns_new_pmap_given_pmap

 def test_returns_new_pmap_given_pmap(self):
     """
     If a PMap is passed in, a new PMap is returned, and even the new value
     that was passed in gets frozen.
     """
     self.assertEquals(set_in(pmap({1: 2}), (1,), {1: 3}),
                       pmap({1: pmap({1: 3})}))
开发者ID:rackerlabs,项目名称:otter,代码行数:7,代码来源:test_fp.py


示例8: test_filters_clb_types

 def test_filters_clb_types(self):
     """
     Only one CLB step is returned per CLB
     """
     steps = pbag([
         AddNodesToCLB(
             lb_id='5',
             address_configs=s(('1.1.1.1',
                                CLBDescription(lb_id='5', port=80)))),
         RemoveNodesFromCLB(lb_id='5', node_ids=s('1')),
         # Unoptimizable step
         CreateServer(server_config=pmap({})),
     ])
     # returned steps could be pbag of any of the 2 lists below depending
     # on how `one_clb_step` iterates over the steps. Since it is pbag the
     # order of elements is not guaranteed
     list1 = [
         AddNodesToCLB(
             lb_id='5',
             address_configs=s(
                 ('1.1.1.1', CLBDescription(lb_id='5', port=80)))),
         CreateServer(server_config=pmap({}))
     ]
     list2 = [
         RemoveNodesFromCLB(lb_id='5', node_ids=s('1')),
         CreateServer(server_config=pmap({}))
     ]
     self.assertEqual(
         matches(MatchesAny(Equals(pbag(list1)), Equals(pbag(list2)))),
         optimize_steps(steps)
     )
开发者ID:rackerlabs,项目名称:otter,代码行数:31,代码来源:test_transforming.py


示例9: test_returns_new_pmap_given_dict

 def test_returns_new_pmap_given_dict(self):
     """
     If a dictionary is passed in, a new PMap is returned and the old
     dictionary is unaffected.
     """
     a = {1: 2}
     self.assertEquals(set_in(a, (1,), {1: 3}), pmap({1: pmap({1: 3})}))
     self.assertEquals(a, {1: 2})
开发者ID:rackerlabs,项目名称:otter,代码行数:8,代码来源:test_fp.py


示例10: test_hash_parameters

 def test_hash_parameters(self):
     self.assertEqual(
         {
             http.MediaRange(type="a", parameters=pmap({"a": "b"})),
             http.MediaRange(type="a", parameters=pmap({"a": "b"})),
         },
         {http.MediaRange(type="a", parameters=pmap({"a": "b"}))},
     )
开发者ID:Julian,项目名称:Minion,代码行数:8,代码来源:test_http.py


示例11: test_set_with_relocation

def test_set_with_relocation():
    x = pmap({'a':1000}, pre_size=1)
    x = x.set('b', 3000)
    x = x.set('c', 4000)
    x = x.set('d', 5000)
    x = x.set('d', 6000)

    assert len(x) == 4
    assert x == pmap({'a': 1000, 'b': 3000, 'c': 4000, 'd': 6000})
开发者ID:alx-,项目名称:pyrsistent,代码行数:9,代码来源:map_test.py


示例12: test_equal_with_different_insertion_order

def test_equal_with_different_insertion_order():
    x = pmap([(i, i) for i in range(50)], 10)
    y = pmap([(i, i) for i in range(49, -1, -1)], 10)

    assert x == y
    assert not (x != y)

    assert y == x
    assert not (y != x)
开发者ID:tobgu,项目名称:pyrsistent,代码行数:9,代码来源:map_test.py


示例13: __init__

 def __init__(self, nodes=None, this_node_uuid=uuid4()):
     self._configured_datasets = pmap()
     self._configured_containers = pmap()
     self._leases = LeasesModel()
     if nodes is None:
         nodes = []
     self._nodes = nodes
     self._this_node_uuid = this_node_uuid
     self.synchronize_state()
开发者ID:Kaffa-MY,项目名称:flocker,代码行数:9,代码来源:_client.py


示例14: test_equal_with_different_bucket_sizes

def test_equal_with_different_bucket_sizes():
    x = pmap({'a': 1, 'b': 2}, 50)
    y = pmap({'a': 1, 'b': 2}, 10)

    assert x == y
    assert not (x != y)

    assert y == x
    assert not (y != x)
开发者ID:tobgu,项目名称:pyrsistent,代码行数:9,代码来源:map_test.py


示例15: test_same_hash_when_content_the_same_but_underlying_vector_size_differs

def test_same_hash_when_content_the_same_but_underlying_vector_size_differs():
    x = pmap(dict((x, x) for x in range(1000)))
    y = pmap({10: 10, 200: 200, 700: 700})

    for z in x:
        if z not in y:
            x = x.remove(z)

    assert x == y
    assert hash(x) == hash(y)
开发者ID:alx-,项目名称:pyrsistent,代码行数:10,代码来源:map_test.py


示例16: __get_basic_metrics_for_class

 def __get_basic_metrics_for_class(confusion_table):
     return pmap({
         str(confusion_table.get_class_name()): pmap({
             "Accuracy": confusion_table.accuracy,
             "Precision": confusion_table.precision,
             "Recall": confusion_table.recall,
             "Specificity": confusion_table.specificity,
             "F1score": confusion_table.f1score
         })
     })
开发者ID:RamonAranda,项目名称:ConfusionMatrix,代码行数:10,代码来源:_confusion_matrix.py


示例17: log_metrics

 def log_metrics(self, log_level='basic'):
     avg_metrics_dict = pmap({
         "basic": self.__get_basic_average_metrics,
         "all": self.__get_all_average_metrics
     })[log_level]()
     metrics_dict = pmap({
         "basic": self.__get_basic_metrics_for_each_class,
         "all": self.__get_all_metrics_for_each_class
     })[log_level]()
     return self.__format_function(avg_metrics_dict), self.__format_function(metrics_dict)
开发者ID:RamonAranda,项目名称:ConfusionMatrix,代码行数:10,代码来源:_confusion_matrix.py


示例18: test_evolver_update_with_relocation

def test_evolver_update_with_relocation():
    x = pmap({'a':1000}, pre_size=1)
    e = x.evolver()
    e['b'] = 3000
    e['c'] = 4000
    e['d'] = 5000
    e['d'] = 6000

    assert len(e) == 4
    assert e.persistent() == pmap({'a': 1000, 'b': 3000, 'c': 4000, 'd': 6000})
开发者ID:alx-,项目名称:pyrsistent,代码行数:10,代码来源:map_test.py


示例19: __get_basic_average_metrics

 def __get_basic_average_metrics(self):
     return pmap({
         "average": pmap({
             "accuracy": self.average_accuracy,
             "precision": self.average_precision,
             "recall": self.average_recall,
             "specificity": self.average_specificity,
             "f1score": self.average_f1score
         })
     })
开发者ID:RamonAranda,项目名称:ConfusionMatrix,代码行数:10,代码来源:_confusion_matrix.py


示例20: compute_check_result_for_job

def compute_check_result_for_job(client, job):
    kwargs = m(
        name="check_tron_job.{}".format(job['name']),
        source="tron",
    )
    if 'realert_every' not in kwargs:
        kwargs = kwargs.set('realert_every', guess_realert_every(job))
    kwargs = kwargs.set('check_every', f"{_run_interval}s")

    # We want to prevent a monitoring config from setting the check_every
    # attribute, since one config should not dictate how often this script runs
    sensu_kwargs = (
        pmap(job['monitoring']).discard(PRECIOUS_JOB_ATTR)
        .discard('check_every')
    )
    kwargs = kwargs.update(sensu_kwargs)

    kwargs_list = []
    if job["status"] == "disabled":
        kwargs = kwargs.set(
            'output',
            "OK: {} is disabled and won't be checked.".format(job['name'], )
        )
        kwargs = kwargs.set('status', 0)
        kwargs_list.append(kwargs)
    else:
        # The job is not disabled, therefore we have to look at its run history
        url_index = client.index()
        tron_id = get_object_type_from_identifier(url_index, job["name"])
        job_content = pmap(
            client.job(
                tron_id.url,
                include_action_runs=True,
            )
        )

        if job['monitoring'].get(PRECIOUS_JOB_ATTR, False):
            dated_runs = sort_runs_by_interval(job_content, interval='day')
        else:
            dated_runs = {'': job_content['runs']}

        for date, runs in dated_runs.items():
            results = compute_check_result_for_job_runs(
                job=job,
                job_content=job_content.set('runs', runs),
                client=client,
            )
            dated_kwargs = kwargs.update(results)
            if date:  # if empty date, leave job name alone
                dated_kwargs = dated_kwargs.set(
                    'name', f"{kwargs['name']}-{date}"
                )
            kwargs_list.append(dated_kwargs)

    return [dict(kws) for kws in kwargs_list]
开发者ID:Yelp,项目名称:Tron,代码行数:55,代码来源:check_tron_jobs.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyrsistent.pset函数代码示例发布时间:2022-05-27
下一篇:
Python pyrsistent.plist函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap