December 2019
Intermediate to advanced
368 pages
11h 10m
English
This function allows the addition of new novelty points to the archive while maintaining its size. It has the following implementation:
if len(self.novel_items) >= MAXNoveltyArchiveSize: # check if this item has higher novelty than # last item in the archive (minimal novelty) if item > self.novel_items[-1]: # replace it self.novel_items[-1] = item else: # just add new item self.novel_items.append(item) # sort items array in descending order by novelty score self.novel_items.sort(reverse=True)
The code first checks whether the size of the novelty archive has not been exceeded yet and directly appends a new novelty point to it in this case. Otherwise, a new novelty point replaces the last item in the archive, ...
Read now
Unlock full access