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

add python multiset util #291

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add python multiset util #291

wants to merge 1 commit into from

Conversation

jorendumoulin
Copy link
Contributor

@jorendumoulin jorendumoulin commented Nov 12, 2024

functionality for multisets: https://en.wikipedia.org/wiki/Multiset

( a set, where each element has a cardinality (how many times is this element in the set))

I will use this for scheduling tensor operations on accelerators

Copy link
Contributor

@JosseVanDelm JosseVanDelm left a comment

Choose a reason for hiding this comment

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

Nice!


def __init__(self, iterable=None):
"""Initialize the multiset with an optional iterable"""
self.counter = Counter(iterable) if iterable is not None else Counter()
Copy link
Contributor

Choose a reason for hiding this comment

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

This also seems to work, not sure if pyright agrees

Suggested change
self.counter = Counter(iterable) if iterable is not None else Counter()
self.counter = Counter(iterable)

@JosseVanDelm
Copy link
Contributor

Is this okay to merge? @jorendumoulin

@jorendumoulin
Copy link
Contributor Author

I'm not 100% sure I will need it after some refactoring, probably I will but I'll let this one sit for a while if that's okay

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