Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

amitsubhashchejara
Copy link
Contributor

@amitsubhashchejara amitsubhashchejara commented Mar 31, 2025

Fixes #8082

Summary

This PR updates the test case in TestAllForecastingPtMetrics to strictly check that forecasting metrics return a Python np.float64 instead of allowing any float types (float, etc.).

Changes Made

  • Updated the assertion in test_metric_output_direct:
    if isinstance(multioutput, np.ndarray) or multioutput == "uniform_average":
        assert all(type(x) is np.float64 for x in res.values())  # Ensures strict Python float

…est .

This PR updates the test case in TestAllForecastingPtMetrics to strictly check that forecasting metrics return a Python float instead of allowing NumPy float types (np.float64, etc.).
@yarnabrina
Copy link
Member

Sorry, but why do we need to ensure it must be native float and not numpy.float64 object?

@fkiraly fkiraly added enhancement Adding new functionality module:metrics&benchmarking metrics and benchmarking modules labels Mar 31, 2025
@fkiraly
Copy link
Collaborator

fkiraly commented Mar 31, 2025

That was a specification I gave in the issue - FYI @felipeangelimvieira.

However, after revisiting the topic, I think we should check np.float64, why:

  • this is a subclass of float, so it will actually be float
  • this seems to be the status quo, so we should not change the contract (without deprecation).

@fkiraly fkiraly changed the title Ensure Forecasting Metrics Return Python Float [ENH] Ensure Forecasting Metrics Return np.float64 Mar 31, 2025
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Planning to quick merge as this tests the status quo and does not change the contract.

@amitsubhashchejara
Copy link
Contributor Author

@fkiraly , does that mean no changes are required?

@fkiraly
Copy link
Collaborator

fkiraly commented Apr 1, 2025

@fkiraly , does that mean no changes are required?

yes, thanks!

@fkiraly fkiraly merged commit b21e3f0 into sktime:main Apr 1, 2025
48 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding new functionality module:metrics&benchmarking metrics and benchmarking modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENH] forecasting metrics test should check scalar output type
3 participants