Skip to content

Commit c4d8143

Browse files
committed
Fix Pandas indexing.
Workaround around pandas-dev/pandas#42430.
1 parent 05c8a80 commit c4d8143

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

skfda/_utils/_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ def _int_to_real(array: np.ndarray) -> np.ndarray:
645645
def _check_array_key(array: np.ndarray, key: Any) -> Any:
646646
"""Check a getitem key."""
647647
key = check_array_indexer(array, key)
648+
if isinstance(key, tuple):
649+
non_ellipsis = [i for i in key if i is not Ellipsis]
650+
if len(non_ellipsis) > 1:
651+
raise KeyError(key)
652+
key = non_ellipsis[0]
648653

649654
if isinstance(key, numbers.Integral): # To accept also numpy ints
650655
key = int(key)

skfda/exploratory/stats/_stats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77

8-
from ...misc.metrics import l2_distance, l2_norm
8+
from ...misc.metrics import Metric, l2_distance, l2_norm
99
from ...representation import FData, FDataGrid
1010
from ..depth import Depth, ModifiedBandDepth
1111

@@ -121,7 +121,7 @@ def geometric_median(
121121
X: T,
122122
*,
123123
tol: float = 1.e-8,
124-
metric: Callable[[T, T], np.ndarray] = l2_distance,
124+
metric: Metric[T] = l2_distance,
125125
) -> T:
126126
r"""Compute the geometric median.
127127

0 commit comments

Comments
 (0)