Skip to content
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

[BUG] utils/weighted_metrics.py non arguments #2134

Closed
TonyBagnall opened this issue Oct 2, 2024 · 0 comments · Fixed by #2137
Closed

[BUG] utils/weighted_metrics.py non arguments #2134

TonyBagnall opened this issue Oct 2, 2024 · 0 comments · Fixed by #2137
Assignees
Labels
bug Something isn't working

Comments

@TonyBagnall
Copy link
Contributor

Describe the bug

some legacy code in weighted_metrics allows None arguments for the weights, then tests weights.ndim, so crashes if you dont pass weights. I would KWF but its used in performance metrics

def _weighted_geometric_mean(y, weights=None, axis=None):
    """Calculate weighted version of geometric mean.

    Parameters
    ----------
    y : np.ndarray
        Values to take the weighted geometric mean of.
    weights: np.ndarray
        Weights for each value in `array`. Must be same shape as `array` or
        of shape `(array.shape[0],)` if axis=0 or `(array.shape[1], ) if axis=1.
    axis : int
        The axis of `y` to apply the weights to.

    Returns
    -------
    geometric_mean : float
        Weighted geometric mean
    """
    if weights.ndim == 1:

Steps/Code to reproduce the bug

from aeon.utils.weighted_metrics import _weighted_geometric_mean
import numpy as np
y = np.array([1.0,2.0, 3.0])
w = _weighted_geometric_mean(y)

Expected results

it should I think just require weights, otherwise whats the point?

Actual results

        geometric_mean : float
            Weighted geometric mean
        """
>       if weights.ndim == 1:
E       AttributeError: 'NoneType' object has no attribute 'ndim'

axis       = None
weights    = None
y          = array([1., 2., 3.])

..\weighted_metrics.py:34: AttributeError

Versions

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant