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

tsdisplay errs with input arrays y of length less than 51. #440

Closed
jasmyace opened this issue Jun 30, 2021 · 2 comments
Closed

tsdisplay errs with input arrays y of length less than 51. #440

jasmyace opened this issue Jun 30, 2021 · 2 comments

Comments

@jasmyace
Copy link

Describe the bug
Function tsdisplay, via its lag_max default value of 50, assumes that array y has at least 51 observations. A total of (at least) 51 observations is required to produce 50 lags.

Not directly specifying lag_max, when y is not of sufficient length, leads to a (perhaps) cryptic error.

To Reproduce

import pmdarima as pm
from pmdarima.utils import tsdisplay

x = pm.datasets.load_sunspots()
x51 = x[0:51]   # 51 obs.
x50 = x[0:50]   # 50 obs. 
x49 = x[0:49]   # 49 obs.
tsdisplay(x51)  # yay!  :)
tsdisplay(x50)  # oh no!  :(
tsdisplay(x49)  # oh no!  :(

Versions

System:
    python: 3.8.10 (default, May 19 2021, 11:01:55)  [Clang 10.0.0 ]
executable: /Users/Jason/opt/anaconda3/envs/python38_2/bin/python
   machine: macOS-10.14.6-x86_64-i386-64bit

Python dependencies:
        pip: 21.1.2
 setuptools: 52.0.0.post20210125
    sklearn: 0.24.2
statsmodels: 0.12.2
      numpy: 1.19.0
      scipy: 1.6.2
     Cython: 0.29.17
     pandas: 1.2.5
     joblib: 1.0.1
   pmdarima: 1.8.0

Not using the most recent version of pmdarima, but GitHub suggests most of pmdarima.utils has not undergone revisions recently.

Expected behavior
In the case that y is of length 50 or less, tsdisplay would ideally adapt to feed len(y) - 1, or an appropriate equivalent, into the internal call to plot_acf. For what it's worth, it looks like tsaplots uses np.arange to help in this area inplot_acf.

Actual behavior
Calling tsdisplay via

tsdisplay(x50)  # oh no!  :(

leads to

blahblahblah
ValueError: could not broadcast input array from shape (50) into shape (51)

Additional context
n/a

@tgsmith61591
Copy link
Member

Hey great find and thanks so much for filing such a nicely documented issue. This is indeed a bug on our end, and it has to do with the lag_max=50 default. I will add a check to ensure lag_max is not larger than the series length; if it is, it should be an error, but it should be an error that the user can understand.

tgsmith61591 added a commit that referenced this issue Jul 21, 2021
tgsmith61591 added a commit that referenced this issue Jul 21, 2021
* Circle CI changes:
  - Refactor Circle CI to build wheels during each unit test stage. This is in direct response to several issues we've had during the last several deployments, which were not discovered until the release was cut. Each unit test stage builds a wheel, runs the tests, and then persists the wheel to the workspace for the deployment stage. After merging, we will need to cut a new test release to ensure we are properly restoring the workspace.
  - Consolidate smaller, miscellaneous tests into a single stage to reduce the concurrency contention imposed by Circle CI's rate limits
* Address issue #440
* Speed up some tests & examples
* Add to documentation
tgsmith61591 added a commit that referenced this issue Jul 22, 2021
Rework Circle CI + several minor fixes

* Circle CI changes:
  - Refactor Circle CI to build wheels during each unit test stage. This is in direct response to several issues we've had during the last several deployments, which were not discovered until the release was cut. Each unit test stage builds a wheel, runs the tests, and then persists the wheel to the workspace for the deployment stage. After merging, we will need to cut a new test release to ensure we are properly restoring the workspace.
  - Consolidate smaller, miscellaneous tests into a single stage to reduce the concurrency contention imposed by Circle CI's rate limits
* Address issue #440
* Speed up some tests & examples
* Add to documentation
@tgsmith61591
Copy link
Member

This is fixed in 1.8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants