-
Notifications
You must be signed in to change notification settings - Fork 512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fields, expressions, filters, matching, oh my! #290
Conversation
Wow! Just wow! First impressions:
|
Yes! I had a similar thought when looking at Tyler's PR but I couldn't think of a good way of implementing it but I like this! I think having standard python syntax like |
UPDATE Usage with import fiftyone as fo
from fiftyone import ViewField as F
dataset = fo.Dataset()
dataset.add_samples(
[
fo.Sample(filepath="filepath1.jpg", age=10),
fo.Sample(filepath="filepath2.jpg", age=15),
fo.Sample(filepath="filepath3.jpg", age=20),
fo.Sample(filepath="filepath4.jpg", age=25),
fo.Sample(filepath="filepath5.jpg", age=30),
fo.Sample(filepath="filepath6.jpg", age=35),
]
)
view = dataset.view().match(F("age") > 20)
print(view)
|
Note that, unfortunately, |
Alternative DatasetView summaries
…iew-shortcut Expressions V3 without dataset view shortcut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to just start reviewing PRs by making new PRs. thats my new thing
Inspired by @tylerganter's great work in #282 and #284, I'd like to propose this alternative implementation to implement fields, expressions, filtering, sorting, etc.
The two key differences are:
(1) Rather than encapsulating the operations in classes, we encapsulate the field to which the operation is being applied. This allows us to use standard operator overloading to achieve a pretty clean syntax for building list filters
(2) Implements the filtering as a standard pipeline stage so that it can be included anywhere within a pipeline, as desired
I like the syntax of (1), but, regardless of whether we go with (1) or #282, I would definitely like to adopt (2) because it leverages the full power of pipelines
Example use:
AND... ONE LAST THING
The
F
syntax works withDatasetView.match()
too!