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

Added before and after operators #316

Merged
merged 1 commit into from Nov 28, 2023
Merged

Added before and after operators #316

merged 1 commit into from Nov 28, 2023

Conversation

javiber
Copy link
Collaborator

@javiber javiber commented Nov 23, 2023

No description provided.

Copy link

Coverage report

Main: 91.12% | PR: 91.15% | Diff: 0.03 ✅

@javiber javiber marked this pull request as ready for review November 23, 2023 15:10
Copy link
Collaborator

@achoum achoum left a comment

Choose a reason for hiding this comment

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

Awesome

self: EventSetOrNode,
timestamp: Union[int, float, datetime],
) -> EventSetOrNode:
"""Filter events [`EventSet`][temporian.EventSet] that happened before a
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Some of the functions use the 3rd person e.g. "Filters events ...".

timestamps.

The comparison is strict, meaning that the obtained timestamps would be
less than (`<`) the provided timestamp.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to say something like?:
This operation is equivalent to "input.filter(input.timestamps() < timestamp)"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can add it, do you think I should also add a link to filter?

self: EventSetOrNode,
timestamp: Union[int, float, datetime],
) -> EventSetOrNode:
"""Filter events [`EventSet`][temporian.EventSet] that happened before a
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not a native speaker, but I think "filter events before A" might be understood as removing the ones before A (i.e. the opposite of this operator). I wonder if this could be made less ambiguous.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would understand "filter out..." as the opposite, since I'm not a native speaker either, run it through chatGPT the question:

Given the following documentation of a function called f:

"Filters events that happened before a particular timestamp."

What do you understand that the function should do?

And it understood the correct thing:

def f(events, timestamp):
    # Filter events that happened before the specified timestamp
    filtered_events = [event for event in events if event['timestamp'] < timestamp]
    return filtered_events

```

Args:
timestamp: EventSet with a single boolean feature.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about something like: Strict timestamp upper boundary (or something like that).


if isinstance(timestamp, datetime):
if not input.schema.is_unix_timestamp:
raise ValueError(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want the opposite to be allowed? e.g. timestamp is a float and the input is a unix timestamp.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good question, I didn't want to be too restrictive but if you feel that it's a good restriction I'm happy to add it.

My only concern was if the user can somehow get the internal timestamps from an eventset they would be floats because that's how we represent them but I don't know if the users can even do that.

Copy link

Coverage report

Main: 91.15% | PR: 91.15% | Diff: 0.01 ✅

1 similar comment
Copy link

Coverage report

Main: 91.15% | PR: 91.15% | Diff: 0.01 ✅

@javiber javiber merged commit 69867bd into main Nov 28, 2023
19 checks passed
@javiber javiber deleted the before-after-operator branch November 28, 2023 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants