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

Remove split_out #170

Merged
merged 2 commits into from
Oct 12, 2022
Merged

Remove split_out #170

merged 2 commits into from
Oct 12, 2022

Conversation

dcherian
Copy link
Collaborator

Closes #166
Closes #11

Closes #166
Closes #11
@dcherian
Copy link
Collaborator Author

@Illviljan this mypy failure makes no sense to me.

flox/core.py Outdated
expected_groups = None
else:
expected_groups = _get_expected_groups(by_input, sort=sort)
group_chunks = ((len(expected_groups),) if expected_groups is not None else (np.nan,),)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
group_chunks = ((len(expected_groups),) if expected_groups is not None else (np.nan,),)
group_chunks: tuple[tuple[float, ...]] = ((len(expected_groups),) if expected_groups is not None else (np.nan,),)

Try explicitly defining how group_chunks is supposed to look like.

mypy get's the type hint from the first time a variable is defined, it's not clear from this line that it can be multiple floats like later on line 1302.

flox/core.py:1302: error: Incompatible types in assignment (expression has type "Tuple[Tuple[int, ...]]", variable has type "Tuple[Tuple[float]]")  [assignment]
Found 2 errors in 1 file (checked 10 source files)
flox/core.py:1322: error: Incompatible types in assignment (expression has type "Tuple[Tuple[int, ...]]", variable has type "Tuple[Tuple[float]]")  [assignment]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh right. it's only ever float in that one clase and tuple[tuple[int]] otherwise

Copy link
Contributor

@Illviljan Illviljan Oct 11, 2022

Choose a reason for hiding this comment

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

For tuples you have to add ... to imply multiple elements of that same type and those loops in 1302 will add multiple ints.
np.nan is a float so the entire thing then becomes float: tuple[tuple[float, ...]]

@dcherian dcherian enabled auto-merge (squash) October 12, 2022 01:24
@dcherian dcherian merged commit 878e284 into main Oct 12, 2022
@dcherian dcherian deleted the remove-split-out branch October 12, 2022 01:26
dcherian added a commit that referenced this pull request Oct 17, 2022
* main: (29 commits)
  Major fix to subset_to_blocks (#173)
  Performance improvements for cohorts detection (#172)
  Remove split_out (#170)
  Deprecate resample_reduce (#169)
  More efficient cohorts. (#165)
  Allow specifying output dtype (#131)
  Add a dtype check for numpy arrays in assert_equal (#158)
  Update ci-additional.yaml (#167)
  Refactor before redoing cohorts (#164)
  Fix mypy errors in core.py (#150)
  Add link to numpy_groupies (#160)
  Bump codecov/codecov-action from 3.1.0 to 3.1.1 (#159)
  Use math.prod instead of np.prod (#157)
  Remove None output from _get_expected_groups (#152)
  Fix mypy errors in xarray.py, xrutils.py, cache.py (#144)
  Raise error if multiple by's are used with Ellipsis (#149)
  pre-commit autoupdate (#148)
  Add mypy ignores (#146)
  Get pre commit bot to update (#145)
  Remove duplicate examples headers (#147)
  ...
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.

delete split_out code paths use "hash split" with split_out
2 participants