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

Fix mypy errors in core.py - chunk_reduce #154

Closed
wants to merge 7 commits into from

Conversation

Illviljan
Copy link
Contributor

@Illviljan Illviljan commented Sep 26, 2022

Splitting up #150 as I had trouble finding typos.

@Illviljan Illviljan changed the title Type chunk reduce Fix mypy errors in core.py - chunk_reduce Sep 26, 2022
flox/core.py Show resolved Hide resolved
dict
"""

if not (isinstance(func, str) or callable(func)):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I llike this but we shoudl do this at the groupby_reduce level. Otherwise for dask stuff it will only raise at compute time. Unless you're checking that we've created Aggregation objects correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to make sure funcs is always a sequence. chunk_reduce is used on too many places though, it would require too many unrelated typing changes. I think it's for another PR once the mypy CI is active.

dtypes = dtype
else:
dtypes = (dtype,) * nfuncs
assert len(dtypes) >= nfuncs
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assert len(dtypes) >= nfuncs
assert len(dtypes) == nfuncs

IMO we should be more strict here. This looseness has resulted in bugs/confusions before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I tried it out and some parts of the code actually relies on this behaviour. >= was in the original code so I'm going to leave it the same in this PR.

@Illviljan Illviljan marked this pull request as ready for review September 27, 2022 18:01
@Illviljan Illviljan closed this Oct 6, 2022
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