Skip to content
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

More intuitive behavior of exists() for frame fields #2209

Merged
merged 2 commits into from
Nov 2, 2022
Merged

Conversation

brimoor
Copy link
Contributor

@brimoor brimoor commented Oct 31, 2022

Updates the logic of the exists() stage to be more intuitive for frame fields:

import fiftyone as fo

sample1 = fo.Sample(filepath="video1.mp4", index=1)
sample1.frames[1] = fo.Frame()

sample2 = fo.Sample(filepath="video2.mp4", foo="bar", index=2)
sample2.frames[1] = fo.Frame(foo="bar")

sample3 = fo.Sample(filepath="video3.mp4", index=3)

dataset = fo.Dataset()
dataset.add_samples([sample1, sample2, sample3])

# Only contains samples with a `foo` attribute
view = dataset.exists("foo")
assert view.values("index") == [2]

# Only contains samples without a `foo` attribute
view = dataset.exists("foo", bool=False)
assert view.values("index") == [1, 3]

# Only contains samples with >= 1 frame
view = dataset.exists("frames")
assert view.values("index") == [1, 2]

# Only contains samples with no frames
view = dataset.exists("frames", bool=False)
assert view.values("index") == [3]

# Only contains samples with a `foo` attribute on >= 1 frame
view = dataset.exists("frames.foo")
assert view.values("index") == [2]

# Only contains samples with no `foo` attribute on any frames
view = dataset.exists("frames.foo", bool=False)
assert view.values("index") == [1, 3]

@brimoor brimoor added the bug Bug fixes label Oct 31, 2022
@brimoor brimoor requested review from ehofesmann and a team October 31, 2022 16:52
@brimoor brimoor self-assigned this Oct 31, 2022
@brimoor brimoor changed the title Handling exists("frames") Consistent handling of exists("frames") Oct 31, 2022
@brimoor brimoor marked this pull request as ready for review October 31, 2022 20:09
@brimoor brimoor changed the title Consistent handling of exists("frames") More intuitive behavior of exists() for frame fields Oct 31, 2022
Copy link
Contributor

@benjaminpkane benjaminpkane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brimoor brimoor merged commit a763547 into develop Nov 2, 2022
@brimoor brimoor deleted the bugfix/exists branch November 2, 2022 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants