コード例 #1
0
ファイル: iterables.py プロジェクト: ethanjli/phylline
def test_remove_none():
    """Test whether remove_none removes Nones correctly."""
    assert len(tuple(range(5))) == len(tuple(remove_none(range(5))))
    for (initial, filtered) in zip(range(5), remove_none(range(5))):
        assert initial == filtered
    assert len(tuple(remove_none([1, 2, None, 3]))) == 3
    assert tuple(remove_none([1, 2, None, 3])) == (1, 2, 3)
コード例 #2
0
ファイル: pipes.py プロジェクト: ethanjli/phylline
 def update_clock_request(self, event):
     """Update the next clock request based on the event."""
     clock_requests = [self._next_clock_request, event]
     clock_requests = list(remove_none(clock_requests))
     try:
         self._next_clock_request = min(clock_requests)
     except ValueError:
         self._next_clock_request = None
コード例 #3
0
ファイル: pipelines.py プロジェクト: ethanjli/phylline
 def next_clock_request(self):
     """Return the next clock update requested by the pipeline."""
     clock_requests = list(remove_none(
         pipe.next_clock_request for pipe in self.pipes_clocked
     ))
     if not clock_requests:
         return None
     # print('Next clock request for pipeline {}: {}'.format(self, min(clock_requests)))
     return min(clock_requests)
コード例 #4
0
ファイル: pipes.py プロジェクト: ethanjli/phylline
 def next_clock_request(self):
     """Return the next clock update requested by the pipeline."""
     clock_requests = [self._next_clock_request]
     clock_requests.extend(
         remove_none(clocked.next_clock_request
                     for clocked in itertools.chain(self.bottom_clocked,
                                                    self.top_clocked)))
     if not clock_requests:
         return None
     # print('Next clock request for pipe {}: {}'.format(self, min(clock_requests)))
     return min(clock_requests)
コード例 #5
0
ファイル: pipes.py プロジェクト: ethanjli/phylline
    def sync_down(self):
        """Synchronize the queues or buffers from the top layer to the bottom layer.

        The to_send() of top will be passed down to the send() of bottom.

        Returns the earliest clock update requested by the sender of any link
        in the top layer.
        """
        clock_requests = list(
            remove_none(self._sync_down(top) for top in self.top))
        if clock_requests:
            self.update_clock_request(min(clock_requests))
        return self.next_clock_request
コード例 #6
0
ファイル: pipes.py プロジェクト: ethanjli/phylline
    def sync_up(self):
        """Synchronize the queues or buffers from the bottom layer to the top layer.

        The receive() of bottom will be passed up to the to_receive() of top.

        Returns the earliest clock update requested by the receiver of any link
        in the bottom layer.
        """
        clock_requests = list(
            remove_none(self._sync_up(bottom) for bottom in self.bottom))
        if clock_requests:
            self.update_clock_request(min(clock_requests))
        return self.next_clock_request