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

Create ComparerCollection in init #320

Merged
merged 4 commits into from
Dec 12, 2023
Merged

Create ComparerCollection in init #320

merged 4 commits into from
Dec 12, 2023

Conversation

ecomodeller
Copy link
Member

@ecomodeller ecomodeller commented Dec 10, 2023

Instead of creating an empy ComparerCollection and then inserting Comparers in it.

@ecomodeller ecomodeller marked this pull request as ready for review December 11, 2023 09:10
Copy link
Member

@jsmariegaard jsmariegaard left a comment

Choose a reason for hiding this comment

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

Great stuff - ready for merge IMO, but if you like it would also be great if it could take a list of names

@@ -235,18 +214,36 @@ def __repr__(self):
out.append(f"{type(value).__name__}: {key}")
return str.join("\n", out)

def __getitem__(self, x) -> Comparer:
@overload
def __getitem__(self, x: slice) -> ComparerCollection:
Copy link
Member

Choose a reason for hiding this comment

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

It says slice, but can I also provide a list of names? e.g. cc[["stn3", "stn1"]] ? (like pandas or xarray)

Copy link
Member Author

Choose a reason for hiding this comment

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

no, not yet

Copy link
Member Author

@ecomodeller ecomodeller Dec 11, 2023

Choose a reason for hiding this comment

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

Now it is possible, but I can not get type hints to work 100%

In this case it should be a Comparer🤔
image

@ecomodeller ecomodeller merged commit 0e70b2e into main Dec 12, 2023
@ecomodeller ecomodeller deleted the collection-api branch December 12, 2023 05:47
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