Skip to content
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
151 changes: 0 additions & 151 deletions ml_metrics/_src/types.py

This file was deleted.

117 changes: 0 additions & 117 deletions ml_metrics/_src/types_test.py

This file was deleted.

5 changes: 3 additions & 2 deletions ml_metrics/_src/utils/math_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Math Utils."""

from ml_metrics._src import types
from ml_metrics._src.aggregates import types as agg_types
import numpy as np

Expand Down Expand Up @@ -70,7 +69,9 @@ def where(
condition: agg_types.NumbersT, x: agg_types.NumbersT, y: agg_types.NumbersT
):
"""Like np.where, but directly returns itself if condition is scalar."""
if types.is_array_like(condition):
if isinstance(condition, (list, tuple)) or (
hasattr(condition, '__array__') and condition.ndim > 0
):
return np.where(condition, x, y)
# If x or y is scalar, return it directly to keep its type (vs. np.where
# that wraps it in a one-element array).
Expand Down
Loading