Skip to content

Commit

Permalink
chore: fix up coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisjared committed Sep 21, 2023
1 parent f7a176e commit 5bd6eb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ show_missing = true
# Regexes for lines to exclude from consideration in addition to the defaults
exclude_also = [
# Don't complain about missing type checking code:
"if TYPE_CHECKING",
"if TYPE_CHECKING:",
]

[tool.mypy]
Expand Down
24 changes: 4 additions & 20 deletions src/scmdata/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,6 @@
P = ParamSpec("P")

Check warning on line 21 in src/scmdata/groupby.py

View check run for this annotation

Codecov / codecov/patch

src/scmdata/groupby.py#L21

Added line #L21 was not covered by tests


def _maybe_wrap_array(original, new_array):
"""
Wrap a transformed array with ``__array_wrap__`` if it can be done safely.
This lets us treat arbitrary functions that take and return ndarray objects
like ufuncs, as long as they return an array with the same shape.
"""
# in case func lost array's metadata
if isinstance(new_array, np.ndarray) and new_array.shape == original.shape:
return original.__array_wrap__(new_array)
else:
return new_array


class RunGroupBy(ImplementsArrayReduce, Generic[GenericRun]):
"""
GroupBy object specialized to grouping ScmRun objects
Expand Down Expand Up @@ -137,9 +123,7 @@ def apply(
The result of splitting, applying and combining this array.
"""
grouped = self._iter_grouped()
applied = [
_maybe_wrap_array(arr, func(arr, *args, **kwargs)) for arr in grouped
]
applied = [func(arr, *args, **kwargs) for arr in grouped]
return self._combine(applied)

def apply_parallel(
Expand Down Expand Up @@ -191,7 +175,7 @@ def apply_parallel(
"""
try:
import joblib # type: ignore
except ImportError as e:
except ImportError as e: # pragma: no cover
raise ImportError(
"joblib is not installed. Run 'pip install joblib'"
) from e
Expand Down Expand Up @@ -236,8 +220,8 @@ def _combine(
def reduce(
self,
func: "Callable[Concatenate[NDArray[np.float_], P], NDArray[np.float_]]",
dim: Optional[Union[str, Iterable[str]]] = None,
axis: Optional[Union[str, Iterable[int]]] = None,
dim: "Optional[Union[str, Iterable[str]]]" = None,
axis: "Optional[Union[str, Iterable[int]]]" = None,
*args: "P.args",
**kwargs: "P.kwargs",
) -> "GenericRun":
Expand Down

0 comments on commit 5bd6eb3

Please sign in to comment.