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

ACF calculation 'division by zero' bugfix #774

Merged
merged 3 commits into from
Jun 18, 2024
Merged

Conversation

AviadAvr
Copy link
Contributor

@AviadAvr AviadAvr commented Jun 14, 2024

Short Description

Calculating the autocorrelation function of certain timeseries raises the division by zero error.
The error arises when a timeseries of hourly frequency and equidistant timesteps is analyzed.
Hourly frequency causes the dt_mu variable to be <1, which when converted to an int returns 0.
This only triggers if the timesteps can be inferred:

    if x.index.inferred_freq and y.index.inferred_freq:
        bin_method = "regular"
 ...
    if isinstance(lags, int) and bin_method == "regular":
        lags = arange(int(dt_mu), lags + 1, int(dt_mu), dtype=float)

The testing functions were also updated to include a scenario where the timesteps are of hourly frequency and where no lags are provided (and are therefore type(lags)==int).

Checklist before PR can be merged:

  • closes issue #771
  • is documented
  • Format code with Black formatting
  • type hints for functions and methods
  • tests added / passed
  • Example Notebook (for new features)
  • Remove output for all notebooks with changes

@raoulcollenteur
Copy link
Member

Hi @AviadAvr, Thanks for the PR, looks good! Quick question before merging. Could you open another issue with a feature request to adapt the ACF function to work on hourly data? Then we keep track of all new features for the next release :)

Cheers
Raoul

@AviadAvr
Copy link
Contributor Author

Hi @AviadAvr, Thanks for the PR, looks good! Quick question before merging. Could you open another issue with a feature request to adapt the ACF function to work on hourly data? Then we keep track of all new features for the next release :)

Cheers Raoul

Hey @raoulcollenteur, anything specific in mind that needs to be updated in the ACF function regarding hourly data?

@raoulcollenteur
Copy link
Member

Hi @AviadAvr, Thanks for the PR, looks good! Quick question before merging. Could you open another issue with a feature request to adapt the ACF function to work on hourly data? Then we keep track of all new features for the next release :)
Cheers Raoul

Hey @raoulcollenteur, anything specific in mind that needs to be updated in the ACF function regarding hourly data?

No nothing specific, but I thought you also fixed an issue for hourly data or not? Otherwise I'll just merge this.

@raoulcollenteur raoulcollenteur merged commit 438d36b into pastas:dev Jun 18, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants