Skip to content

Commit

Permalink
Refactor distance functions: change default dim from 'warn' to 'mean'
Browse files Browse the repository at this point in the history
Removed deprecation warning code for dimension handling in both
`paired_distance` and `pairwise_distance`.
  • Loading branch information
isaksamsten committed Aug 23, 2024
1 parent 514cca7 commit 10872c0
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions src/wildboar/distance/_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ def paired_distance( # noqa: PLR0912
x,
y,
*,
dim="warn",
dim="mean",
metric="euclidean",
metric_params=None,
n_jobs=None,
Expand Down Expand Up @@ -899,16 +899,6 @@ def paired_distance( # noqa: PLR0912

n_dims = x.shape[1] if x.ndim == 3 else 1

# TODO(1.3)
if dim == "warn":
if n_dims > 1:
warnings.warn(
"The default value for dim will change to 'mean' from 0 in 1.3. "
"Explicitly set dim=0 to keep the current behaviour for 3d-arrays.",
FutureWarning,
)
dim = 0

if n_dims == 1 and dim == "mean":
dim = 0

Expand All @@ -934,7 +924,7 @@ def pairwise_distance( # noqa: PLR0912, PLR0915
x,
y=None,
*,
dim="warn",
dim="mean",
metric="euclidean",
metric_params=None,
n_jobs=None,
Expand Down Expand Up @@ -997,16 +987,6 @@ def pairwise_distance( # noqa: PLR0912, PLR0915
x_ = _check_ts_array(x)
n_dims = x.shape[1] if x.ndim == 3 else 1

# TODO(1.3)
if dim == "warn":
if n_dims > 1:
warnings.warn(
"The default value for dim will change to 'mean' from 0 in 1.3. "
"Explicitly set dim=0 to keep the current behaviour for 3d-arrays.",
FutureWarning,
)
dim = 0

if n_dims == 1 and dim == "mean":
dim = 0

Expand Down Expand Up @@ -1048,16 +1028,6 @@ def pairwise_distance( # noqa: PLR0912, PLR0915
y_ = _check_ts_array(y)
n_dims = x.shape[1] if x.ndim == 3 else 1

# TODO(1.3)
if dim == "warn":
if n_dims > 1:
warnings.warn(
"The default value for dim will change to 'mean' from 0 in 1.3. "
"Explicitly set dim=0 to keep the current behaviour for 3d-arrays.",
FutureWarning,
)
dim = 0

if n_dims == 1 and dim == "mean":
dim = 0

Expand Down

0 comments on commit 10872c0

Please sign in to comment.