Пример #1
0
    def _init_neighborlist(self) -> None:
        """Initialize self._neighborlist.

        It is a NeighborList with the zoom levels."""
        levels = config.val.zoom.levels
        self._neighborlist = usertypes.NeighborList(
            levels, mode=usertypes.NeighborList.Modes.edge)
        self._neighborlist.fuzzyval = config.val.zoom.default
Пример #2
0
    def start(self, text):
        """Start browsing to the history.

        Called when the user presses the up/down key and wasn't browsing the
        history already.

        Args:
            text: The preset text.
        """
        log.misc.debug("Preset text: '{}'".format(text))
        if text:
            items = [e for e in self.history if e.startswith(text)]
        else:
            items = self.history
        if not items:
            raise HistoryEmptyError
        self._tmphist = usertypes.NeighborList(items)
        return self._tmphist.lastitem()
Пример #3
0
 def neighborlist(self):
     return usertypes.NeighborList()
Пример #4
0
 def test_invalid_reset(self):
     """Test reset without default."""
     nl = usertypes.NeighborList([1, 2, 3, 4, 5])
     with pytest.raises(ValueError):
         nl.reset()
Пример #5
0
 def test_unset(self):
     """Test unset default value."""
     nl = usertypes.NeighborList([1, 2, 3])
     assert nl._idx is None
Пример #6
0
 def test_none(self):
     """Test default 'None'."""
     nl = usertypes.NeighborList([1, 2, None], default=None)
     assert nl._idx == 2
Пример #7
0
 def test_simple(self):
     """Test default with a numeric argument."""
     nl = usertypes.NeighborList([1, 2, 3], default=2)
     assert nl._idx == 1
Пример #8
0
 def test_invalid_mode(self):
     """Test with an invalid mode."""
     with pytest.raises(TypeError):
         usertypes.NeighborList(mode='blah')
Пример #9
0
 def test_contains(self):
     """Test 'in' on NeighborList."""
     nl = usertypes.NeighborList([1, 2, 3])
     assert 2 in nl
     assert 4 not in nl
Пример #10
0
 def test_len(self):
     """Test len() on NeighborList."""
     nl = usertypes.NeighborList([1, 2, 3])
     assert len(nl) == 3
Пример #11
0
 def test_items(self):
     """Test constructing a NeighborList with items."""
     nl = usertypes.NeighborList([1, 2, 3])
     assert nl.items == [1, 2, 3]
Пример #12
0
 def test_empty(self):
     """Test constructing an empty NeighborList."""
     nl = usertypes.NeighborList()
     assert nl.items == []
Пример #13
0
 def neighborlist(self):
     return usertypes.NeighborList([20, 9, 1, 5])
Пример #14
0
 def neighborlist(self):
     return usertypes.NeighborList(
         [1, 2, 3, 4, 5],
         default=3,
         mode=usertypes.NeighborList.Modes.exception)
Пример #15
0
 def neighborlist(self):
     return usertypes.NeighborList([1], default=1)
Пример #16
0
 def neighborlist(self):
     return usertypes.NeighborList([1, 2, 3, 4, 5], default=3)