Skip to content

Fix some typing errors in asv_bench and tests #253

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

Merged
merged 17 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions asv_bench/benchmarks/cohorts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def track_num_layers(self):
)[0]
return len(result.dask.layers)

track_num_tasks.unit = "tasks"
track_num_tasks_optimized.unit = "tasks"
track_num_layers.unit = "layers"
track_num_tasks.unit = "tasks" # type: ignore[attr-defined] # Lazy
track_num_tasks_optimized.unit = "tasks" # type: ignore[attr-defined] # Lazy
track_num_layers.unit = "layers" # type: ignore[attr-defined] # Lazy


class NWMMidwest(Cohorts):
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def construct_member(groups) -> dict[str, Any]:
]
self.kwargs = {
"agg": flox.aggregations._initialize_aggregation(
"sum", "float64", np.float64, 0, None, {}
"sum", "float64", np.float64, 0, 0, {}
),
"axis": (3,),
}
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ known-third-party = [

[tool.mypy]
allow_redefinition = true
exclude = "properties|asv_bench|doc|tests|flycheck"
files = "flox/*.py"
files = "**/*.py"
show_error_codes = true
warn_unused_ignores = true

Expand All @@ -115,7 +114,8 @@ module=[
"cftime",
"dask.*",
"importlib_metadata",
"numpy_groupies",
"numba",
"numpy_groupies.*",
"matplotlib.*",
"pandas",
"setuptools",
Expand Down
14 changes: 8 additions & 6 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def dask_array_ones(*args):
)

if TYPE_CHECKING:
from flox.core import T_Engine, T_ExpectedGroupsOpt, T_Func2
from flox.core import T_Agg, T_Engine, T_ExpectedGroupsOpt, T_Method


def _get_array_func(func: str) -> Callable:
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_alignment_error():
)
def test_groupby_reduce(
engine: T_Engine,
func: T_Func2,
func: T_Agg,
array: np.ndarray,
by: np.ndarray,
expected: list[float],
Expand Down Expand Up @@ -992,14 +992,14 @@ def test_map_reduce_blockwise_mixed() -> None:
dask.array.from_array(data.values, chunks=365),
t.dt.month,
func="mean",
method="split-reduce",
method="map-reduce",
)
expected, _ = groupby_reduce(data, t.dt.month, func="mean")
assert_equal(expected, actual)


@requires_dask
@pytest.mark.parametrize("method", ["split-reduce", "blockwise", "map-reduce", "cohorts"])
@pytest.mark.parametrize("method", ["blockwise", "map-reduce", "cohorts"])
def test_group_by_datetime(engine, method):
kwargs = dict(
func="mean",
Expand Down Expand Up @@ -1356,13 +1356,15 @@ def test_validate_reindex_map_reduce(


def test_validate_reindex() -> None:
for method in ["map-reduce", "cohorts"]:
methods: list[T_Method] = ["map-reduce", "cohorts"]
for method in methods:
with pytest.raises(NotImplementedError):
_validate_reindex(
True, "argmax", method, expected_groups=None, any_by_dask=False, is_dask_array=True
)

for method in ["blockwise", "cohorts"]:
methods: list[T_Method] = ["blockwise", "cohorts"]
for method in methods:
with pytest.raises(ValueError):
_validate_reindex(
True, "sum", method, expected_groups=None, any_by_dask=False, is_dask_array=True
Expand Down