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


Python sortedcontainers.SortedDict方法代码示例

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


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

示例1: __init__

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def __init__(self,
                 url="wss://ws-feed.pro.coinbase.com",
                 product_id='BTC-USD',
                 api_key="",
                 api_secret="",
                 api_passphrase="",
                 channels=None,
                 log_to=None):

        super(OrderBook, self).__init__(url=url, products=product_id,
            api_key=api_key, api_secret=api_secret,
            api_passphrase=api_passphrase, channels=channels)
        self._asks = SortedDict()
        self._bids = SortedDict()
        self._client = PublicClient()
        self._sequence = -1
        self._log_to = log_to
        if self._log_to:
            assert hasattr(self._log_to, 'write')
        self._current_ticker = None 
开发者ID:kkuette,项目名称:TradzQAI,代码行数:22,代码来源:order_book.py

示例2: reset_book

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def reset_book(self):
        self._asks = SortedDict()
        self._bids = SortedDict()
        res = self._client.get_product_order_book(product_id=self.product_id, level=3)
        for bid in res['bids']:
            self.add({
                'id': bid[2],
                'side': 'buy',
                'price': Decimal(bid[0]),
                'size': Decimal(bid[1])
            })
        for ask in res['asks']:
            self.add({
                'id': ask[2],
                'side': 'sell',
                'price': Decimal(ask[0]),
                'size': Decimal(ask[1])
            })
        self._sequence = res['sequence'] 
开发者ID:kkuette,项目名称:TradzQAI,代码行数:21,代码来源:order_book.py

示例3: state_actions_table

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def state_actions_table(self):
        # Make sure table is sorted by state for deterministic output (needed for testing)
        sorted_state_actions = sortedcontainers.SortedDict()
        for state in self.state_actions:
            (entry_actions, exit_actions) = self.state_actions[state]
            entry_action_names = list(map(_action_to_name, entry_actions))
            if entry_action_names == []:
                entry_action_names = "-"
            exit_action_names = list(map(_action_to_name, exit_actions))
            if exit_action_names == []:
                exit_action_names = "-"
            sorted_state_actions[state.name] = (entry_action_names, exit_action_names)
        tab = table.Table()
        tab.add_row(["State", "Entry Actions", "Exit Actions"])
        for state_name in sorted_state_actions:
            (entry_action_names, exit_action_names) = sorted_state_actions[state_name]
            tab.add_row([state_name, entry_action_names, exit_action_names])
        return tab 
开发者ID:brunorijsman,项目名称:rift-python,代码行数:20,代码来源:fsm.py

示例4: __init__

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def __init__(self, is_stack):
        """
        Constructor

        :param is_stack:    Whether this is a region map for stack frames or not. Different strategies apply for stack
                            regions.
        """
        self.is_stack = is_stack

        # A sorted list, which maps stack addresses to region IDs
        self._address_to_region_id = SortedDict()
        # A dict, which maps region IDs to memory address ranges
        self._region_id_to_address = { }

    #
    # Properties
    # 
开发者ID:angr,项目名称:angr,代码行数:19,代码来源:memory.py

示例5: __init__

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def __init__(self, intervals=None):
        """
        Set up a tree. If intervals is provided, add all the intervals
        to the tree.

        Completes in O(n*log n) time.
        """
        intervals = set(intervals) if intervals is not None else set()
        for iv in intervals:
            if iv.is_null():
                raise ValueError(
                    "IntervalTree: Null Interval objects not allowed in IntervalTree:"
                    " {0}".format(iv)
                )
        self.all_intervals = intervals
        self.top_node = Node.from_intervals(self.all_intervals)
        self.boundary_table = SortedDict()
        for iv in self.all_intervals:
            self._add_boundaries(iv) 
开发者ID:chaimleib,项目名称:intervaltree,代码行数:21,代码来源:intervaltree.py

示例6: __init__

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def __init__(self, ctx: mgl.Context):
        self.buffer = None
        self.ctx = ctx

        # Allocation id to sort key
        self.id_lookup: Dict[int, Tuple[Any, int]] = {}

        # Sorted list of sort keys to index arrays
        self.allocations: Mapping[Tuple[Any, int], np.ndarray] = SortedDict()

        # Track whether we have updates
        self.dirty: bool = True

        # We allocate identifiers for each allocation. These are sequential
        # and form part of the sort key; this ensures that insertion order
        # can be preserved.
        self.next_id: int = 1  # start at 1 so we can test bool(id) 
开发者ID:lordmauve,项目名称:wasabi2d,代码行数:19,代码来源:index.py

示例7: default

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def default(self, obj):
        if isinstance(obj, np.ndarray) and obj.ndim == 1:
            return obj.tolist()

        elif isinstance(obj, Quaternion):
            return obj.data.tolist()

        elif isinstance(obj, sortedcontainers.SortedDict):
            return dict(obj)

        elif isinstance(obj, (
                KeyFrame,
                KeyFrameList,
                TransformData,
                spimagine.models.transform_model.TransformData)):
            return obj.__dict__

        elif isinstance(obj, np.generic):
            return np.asscalar(obj)

        return json.JSONEncoder.default(self, obj) 
开发者ID:maweigert,项目名称:spimagine,代码行数:23,代码来源:keyframe_model.py

示例8: __init__

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def __init__(self, product_ids='ETH-USD', api_key=None, api_secret=None,
                 passphrase=None, use_heartbeat=False,
                 trade_log_file_path=None):

        super().__init__(product_ids=product_ids,
                         api_key=api_key,
                         api_secret=api_secret,
                         passphrase=passphrase,
                         use_heartbeat=use_heartbeat,
                         trade_log_file_path=trade_log_file_path)

        if not isinstance(product_ids, list):
            product_ids = [product_ids]

        self.traders = {product_id: gdax.trader.Trader(product_id=product_id)
                        for product_id in product_ids}
        self._asks = {product_id: SortedDict() for product_id in product_ids}
        self._bids = {product_id: SortedDict() for product_id in product_ids}
        self._sequences = {product_id: None for product_id in product_ids} 
开发者ID:csko,项目名称:gdax-python-api,代码行数:21,代码来源:orderbook.py

示例9: test_lenient_split

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def test_lenient_split(self):

        self.transcript.json_conf["pick"]["chimera_split"]["blast_check"] = True

        self.transcript.json_conf["pick"][
            "chimera_split"]["blast_params"]["leniency"] = "LENIENT"

        cds_boundaries = SortedDict()
        for orf in sorted(self.transcript.loaded_bed12,
                          key=operator.attrgetter("thick_start", "thick_end")):
            cds_boundaries[(orf.thick_start, orf.thick_end)] = [orf]

        self.assertEqual(1,
                         len(splitting.check_split_by_blast(self.transcript, cds_boundaries)))
        sl = loci.Superlocus(self.transcript, json_conf=self.transcript.json_conf)
        self.assertEqual(len(sl.transcripts), 1)
        sl.load_all_transcript_data(data_dict=dict())
        self.assertEqual(len(sl.transcripts), 1) 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:20,代码来源:test_splitting.py

示例10: test_stringent_split

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def test_stringent_split(self):

        self.transcript.json_conf["pick"]["chimera_split"]["blast_check"] = True

        self.transcript.json_conf["pick"][
            "chimera_split"]["blast_params"]["leniency"] = "STRINGENT"

        cds_boundaries = SortedDict()
        for orf in sorted(self.transcript.loaded_bed12,
                          key=operator.attrgetter("thick_start", "thick_end")):
            cds_boundaries[(orf.thick_start, orf.thick_end)] = [orf]

        self.assertEqual(1,
                         len(splitting.check_split_by_blast(self.transcript, cds_boundaries)))
        sl = loci.Superlocus(self.transcript, json_conf=self.transcript.json_conf)
        self.assertEqual(len(sl.transcripts), 1)
        sl.load_all_transcript_data(data_dict=dict())
        self.assertEqual(len(sl.transcripts), 1) 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:20,代码来源:test_splitting.py

示例11: test_permissive_split

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def test_permissive_split(self):

        self.transcript.logger = self.logger

        self.transcript.json_conf["pick"]["chimera_split"]["blast_check"] = True

        self.transcript.json_conf["pick"][
            "chimera_split"]["blast_params"]["leniency"] = "PERMISSIVE"

        cds_boundaries = SortedDict()
        for orf in sorted(self.transcript.loaded_bed12,
                          key=operator.attrgetter("thick_start", "thick_end")):
            cds_boundaries[(orf.thick_start, orf.thick_end)] = [orf]

        self.assertEqual(2, len(splitting.check_split_by_blast(self.transcript, cds_boundaries)))
        sl = loci.Superlocus(self.transcript, json_conf=self.transcript.json_conf)
        self.assertEqual(len(sl.transcripts), 1)
        sl.load_all_transcript_data(data_dict=dict())
        self.assertEqual(len(sl.transcripts), 2) 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:21,代码来源:test_splitting.py

示例12: load_settings

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def load_settings(self, directory):
        if not 'config'in directory:
            directory += 'config/'
        with open(directory+self.env_file_name, 'r') as fp:
            env = json.load(fp=fp, object_pairs_hook=SortedDict)
        with open(directory+self.agent_file_name, 'r') as fp:
            agent = json.load(fp=fp, object_pairs_hook=SortedDict)
        with open(directory+self.network_file_name, 'r') as fp:
            network = json.load(fp=fp)
        return env, agent, network 
开发者ID:kkuette,项目名称:TradzQAI,代码行数:12,代码来源:saver.py

示例13: load_agent_settings

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def load_agent_settings(self, directory):
        with open(directory+self.agent_file_name, 'r') as fp:
            agent = json.load(fp=fp, object_pairs_hook=SortedDict)
        return agent 
开发者ID:kkuette,项目名称:TradzQAI,代码行数:6,代码来源:saver.py

示例14: load_env_settings

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def load_env_settings(self, directory):
        with open(directory+self.env_file_name, 'r') as fp:
            env = json.load(fp=fp, object_pairs_hook=SortedDict)
        return env 
开发者ID:kkuette,项目名称:TradzQAI,代码行数:6,代码来源:saver.py

示例15: node_element_str

# 需要导入模块: import sortedcontainers [as 别名]
# 或者: from sortedcontainers import SortedDict [as 别名]
def node_element_str(element):
    lines = []
    if element.name is not None:
        lines.append("Name: " + str(element.name))
    lines.append("Level: " + str(element.level))
    if element.flags is not None:
        lines.append("Flags:")
        if element.flags.overload is not None:
            lines.append("  Overload: " + str(element.flags.overload))
    if element.capabilities is not None:
        lines.append("Capabilities:")
        if element.capabilities.flood_reduction is not None:
            lines.append("  Flood reduction: " + str(element.capabilities.flood_reduction))
        if element.capabilities.hierarchy_indications is not None:
            lines.append("  Leaf indications: " +
                         hierarchy_indications_str(element.capabilities.hierarchy_indications))
    sorted_neighbors = sortedcontainers.SortedDict(element.neighbors)
    for system_id, neighbor in sorted_neighbors.items():
        lines.append("Neighbor: " + utils.system_id_str(system_id))
        lines.append("  Level: " + str(neighbor.level))
        if neighbor.cost is not None:
            lines.append("  Cost: " + str(neighbor.cost))
        if neighbor.bandwidth is not None:
            lines.append("  Bandwidth: " + bandwidth_str(neighbor.bandwidth))
        if neighbor.link_ids is not None:
            sorted_link_ids = sorted(neighbor.link_ids)
            for link_id_pair in sorted_link_ids:
                lines.append("  Link: " + link_id_pair_str(link_id_pair))
    return lines 
开发者ID:brunorijsman,项目名称:rift-python,代码行数:31,代码来源:packet_common.py


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