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] _coerce_to_period fails when not passed a freq argument #1346

Closed
TonyBagnall opened this issue Mar 26, 2024 · 1 comment · Fixed by #1514
Closed

[BUG] _coerce_to_period fails when not passed a freq argument #1346

TonyBagnall opened this issue Mar 26, 2024 · 1 comment · Fixed by #1514
Assignees
Labels
bug Something isn't working forecasting Forecasting package

Comments

@TonyBagnall
Copy link
Contributor

TonyBagnall commented Mar 26, 2024

Describe the bug

whilst writing tests noticed that this fails

def _coerce_to_period(x, freq=None):
    if isinstance(x, pd.Timestamp) and freq is None:
        freq = x.freq
        raise ValueError(
            "_coerce_to_period requires freq argument to be passed if x is pd.Timestamp"
        )

it is never called without a freq argument and its a private method, and then it raises an error, so not sure what freq=x.freq is meant to do

Steps/Code to reproduce the bug

from aeon.forecasting.base._fh import _coerce_to_period

import pandas as pd
import pytest

timestamp = pd.Timestamp("2022-01-01")
result = _coerce_to_period(timestamp)

Expected results

freq = x.freq

Actual results

  File "C:\Code\aeon\aeon\local\debug.py", line 35, in <module>
    result = _coerce_to_period(timestamp)
  File "C:\Code\aeon\aeon\forecasting\base\_fh.py", line 792, in _coerce_to_period
    freq = x.freq
AttributeError: 'Timestamp' object has no attribute 'freq'

Versions

No response

@TonyBagnall TonyBagnall added bug Something isn't working forecasting Forecasting package labels Mar 26, 2024
@TonyBagnall TonyBagnall changed the title [BUG] _coerce_to_period fails when not passed a freq argumeny [BUG] _coerce_to_period fails when not passed a freq argument Mar 27, 2024
@baraline
Copy link
Contributor

Isn't the freq=None argument meant to be used when x is a series or a dataframe ? In which case, x.freq do make sense. But if it is never used, as it is a private function, I also see no use of it.

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

Successfully merging a pull request may close this issue.

3 participants