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

Assign operator #314

Merged
merged 1 commit into from
Nov 23, 2023
Merged

Assign operator #314

merged 1 commit into from
Nov 23, 2023

Conversation

javiber
Copy link
Collaborator

@javiber javiber commented Nov 20, 2023

No description provided.

@javiber javiber marked this pull request as ready for review November 21, 2023 19:16
Copy link

Coverage report

Main: 91.10% | PR: 91.12% | Diff: 0.02 ✅

Copy link
Collaborator

@ianspektor ianspektor left a comment

Choose a reason for hiding this comment

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

Great work :) Left some nits

def assign(
self: EventSetOrNode, **others: EventSetOrNode
) -> EventSetOrNode:
"""Assign new features to an EventSet
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing fullstop, missing crosslink to EventSet ([EventSet][temporian.EventSet])

Comment on lines +4391 to +4392
If the name provided already exists on the EventSet, the feature is
overriden.
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the feature names provided already exist on the EventSet, those features are replaced by the new ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes! I replicated that functionality from pandas.

Inside the assign, I first drop the existing ones otherwise the glue would fail

>>> ab = a.assign(new_name=b)
>>> ab
indexes: []
features: [('A', int64), ('new_name', int64)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

normalize using ' or " for strings

for name, other in others.items():
if len(other.schema.features) != 1:
raise ValueError(
"Cannot assign an EventSets with multiple features"
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo, an EventSet. but would change to: The assigned EventSets must have a single feature (since it also covers the case of it having 0)

... features={"B": [3, 4]},
... same_sampling_as=a,
... )
>>> ab = a.assign(new_name=b)
Copy link
Collaborator

Choose a reason for hiding this comment

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

adding an example with more than one feature would be useful

Copy link

Coverage report

Main: 91.10% | PR: 91.12% | Diff: 0.02 ✅

@javiber javiber merged commit 17b2f2f into main Nov 23, 2023
18 of 19 checks passed
@javiber javiber deleted the assign-operator branch November 23, 2023 12:37
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.

2 participants