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
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()
def neighborlist(self): return usertypes.NeighborList()
def test_invalid_reset(self): """Test reset without default.""" nl = usertypes.NeighborList([1, 2, 3, 4, 5]) with pytest.raises(ValueError): nl.reset()
def test_unset(self): """Test unset default value.""" nl = usertypes.NeighborList([1, 2, 3]) assert nl._idx is None
def test_none(self): """Test default 'None'.""" nl = usertypes.NeighborList([1, 2, None], default=None) assert nl._idx == 2
def test_simple(self): """Test default with a numeric argument.""" nl = usertypes.NeighborList([1, 2, 3], default=2) assert nl._idx == 1
def test_invalid_mode(self): """Test with an invalid mode.""" with pytest.raises(TypeError): usertypes.NeighborList(mode='blah')
def test_contains(self): """Test 'in' on NeighborList.""" nl = usertypes.NeighborList([1, 2, 3]) assert 2 in nl assert 4 not in nl
def test_len(self): """Test len() on NeighborList.""" nl = usertypes.NeighborList([1, 2, 3]) assert len(nl) == 3
def test_items(self): """Test constructing a NeighborList with items.""" nl = usertypes.NeighborList([1, 2, 3]) assert nl.items == [1, 2, 3]
def test_empty(self): """Test constructing an empty NeighborList.""" nl = usertypes.NeighborList() assert nl.items == []
def neighborlist(self): return usertypes.NeighborList([20, 9, 1, 5])
def neighborlist(self): return usertypes.NeighborList( [1, 2, 3, 4, 5], default=3, mode=usertypes.NeighborList.Modes.exception)
def neighborlist(self): return usertypes.NeighborList([1], default=1)
def neighborlist(self): return usertypes.NeighborList([1, 2, 3, 4, 5], default=3)