Handles a previously uncaught edge case where view.sort_by_similarity() would raise an error if view is empty.
import fiftyone as fo
import fiftyone.brain as fob
import fiftyone.zoo as foz
dataset = foz.load_zoo_dataset("quickstart", max_samples=5).clone()
results = fob.compute_similarity(dataset, brain_key="image_sim")
# Previously would raise an error; now succeeds
view = dataset.limit(0).sort_by_similarity(dataset.first().id)
Note that other methods like find_duplicates() and find_unique() will still raise an error on empty views, but I'm not going to do anything about that right now because:
The methods won't output anything useful in such cases anyway
The methods aren't currently used by the App, where fatal errors are less acceptable
Handles a previously uncaught edge case where
view.sort_by_similarity()
would raise an error ifview
is empty.Note that other methods like
find_duplicates()
andfind_unique()
will still raise an error on empty views, but I'm not going to do anything about that right now because: