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

Simplify suffix_union function #531

Closed
wants to merge 2 commits into from

Conversation

maresb
Copy link
Contributor

@maresb maresb commented Oct 16, 2023

Description

Closes #530. Let's see if the tests pass...

@maresb maresb requested a review from a team as a code owner October 16, 2023 11:54
@netlify
Copy link

netlify bot commented Oct 16, 2023

Deploy Preview for conda-lock ready!

Name Link
🔨 Latest commit e1ead32
🔍 Latest deploy log https://app.netlify.com/sites/conda-lock/deploys/652d308411618100080d3c9e
😎 Deploy Preview https://deploy-preview-531--conda-lock.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@maresb
Copy link
Contributor Author

maresb commented Oct 16, 2023

Attn @jacksmith15

@maresb maresb force-pushed the simplify-suffix-union branch from 14deef0 to f567e46 Compare October 16, 2023 11:57

result: List["SupportsRichComparisonT"] = []

def prefix_union(collections: Iterable[Sequence]) -> List:
Copy link
Contributor

@jacksmith15 jacksmith15 Oct 16, 2023

Choose a reason for hiding this comment

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

Seems an improvement to me!

I wonder if part of the confusion has stemmed from the generic naming of these functions.

Could it be instead called unify_package_sources or merge_package_sources?

FWIW the way I reason about this logic is a bit different, not sure if this is more or less confusing to others (probably a tad less performant):

def unify_package_sources(collections: Iterable[Sequence[str]]) -> List[str]:
    result = max(collections, key=len)
    for collection in collections:
        if collection != result[-len(collection):]:
            raise ValueError(f"{collection} is not an ordered subset of {result}")
    return result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice!! I think there's an edge case when len(collection) == 0. But making sure that's in order, would you like to make a PR to supersede mine?

Copy link
Contributor

Choose a reason for hiding this comment

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

Happy to do so 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@maresb
Copy link
Contributor Author

maresb commented Oct 16, 2023

Superseded by #532

@maresb maresb closed this Oct 16, 2023
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.

Why is suffix_union so complicated?
2 participants