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

ValueError: Length of passed values is 1, index implies 5844. #5

Closed
fotakide opened this issue Oct 26, 2020 · 3 comments
Closed

ValueError: Length of passed values is 1, index implies 5844. #5

fotakide opened this issue Oct 26, 2020 · 3 comments

Comments

@fotakide
Copy link

Hello,

It's great we now have bfast for python.
I'm quite new in the field. I'm trying to implement the technic in a time-series with 180 dates, but I'm getting the value error that the length of the passed values is not equal to the required, after processing row 0. I've also tested the example "small-Peru" and raised the same error. I've checked that the required dependencies meet the desired versions and also reinstalled NumPy, but I keep getting the same error. Below are the errors I get.

Small Peru Example

`First date: 2003-07-14 00:00:00
Last date: 2016-09-27 00:00:00
Shape of data array: (216, 334, 334)
Processing row 0
Traceback (most recent call last):
File "C:/Users/vfota/diploma/test_bfast.py", line 63, in
model.fit(data, dates, nan_value=-32768)
File "C:\Users\vfota\diploma\venv\lib\site-packages\bfast\models.py", line 180, in fit
nan_value=nan_value)
File "C:\Users\vfota\diploma\venv\lib\site-packages\bfast\monitor\python\base.py", line 144, in fit
self.fit_single(y, dates)
File "C:\Users\vfota\diploma\venv\lib\site-packages\bfast\monitor\python\base.py", line 175, in fit_single
self.mapped_indices = self._map_indices(dates).astype(numpy.int32)
File "C:\Users\vfota\diploma\venv\lib\site-packages\bfast\monitor\python\base.py", line 299, in _map_indices
indices = numpy.argwhere(~numpy.isnan(ts)).T[0]
File "<array_function internals>", line 6, in argwhere
File "C:\Users\vfota\diploma\venv\lib\site-packages\numpy\core\numeric.py", line 584, in argwhere
return transpose(nonzero(a))
File "<array_function internals>", line 6, in nonzero
File "C:\Users\vfota\diploma\venv\lib\site-packages\numpy\core\fromnumeric.py", line 1896, in nonzero
return _wrapfunc(a, 'nonzero')
File "C:\Users\vfota\diploma\venv\lib\site-packages\numpy\core\fromnumeric.py", line 58, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "C:\Users\vfota\diploma\venv\lib\site-packages\numpy\core\fromnumeric.py", line 51, in _wrapit
result = wrap(result)
File "C:\Users\vfota\diploma\venv\lib\site-packages\pandas\core\generic.py", line 1917, in array_wrap
return self._constructor(result, **d).finalize(self)
File "C:\Users\vfota\diploma\venv\lib\site-packages\pandas\core\series.py", line 292, in init
f"Length of passed values is {len(data)}, "
ValueError: Length of passed values is 1, index implies 5114.

Process finished with exit code 1
`

My Time-Series

`First date: 2000-01-21 00:00:00
Last date: 2015-12-24 00:00:00
Shape of data array: (181, 2669, 4094)
Start monitor: 2010-02-17 00:00:00
Processing row 0
Traceback (most recent call last):
File "C:/Users/vfota/diploma/bfast_euboea.py", line 71, in
nan_value=np.nan)
File "C:\Users\vfota\diploma\venv\lib\site-packages\bfast\models.py", line 180, in fit
nan_value=nan_value)
File "C:\Users\vfota\diploma\venv\lib\site-packages\bfast\monitor\python\base.py", line 144, in fit
self.fit_single(y, dates)
File "C:\Users\vfota\diploma\venv\lib\site-packages\bfast\monitor\python\base.py", line 175, in fit_single
self.mapped_indices = self._map_indices(dates).astype(numpy.int32)
File "C:\Users\vfota\diploma\venv\lib\site-packages\bfast\monitor\python\base.py", line 299, in _map_indices
indices = numpy.argwhere(~numpy.isnan(ts)).T[0]
File "<array_function internals>", line 6, in argwhere
File "C:\Users\vfota\diploma\venv\lib\site-packages\numpy\core\numeric.py", line 584, in argwhere
return transpose(nonzero(a))
File "<array_function internals>", line 6, in nonzero
File "C:\Users\vfota\diploma\venv\lib\site-packages\numpy\core\fromnumeric.py", line 1896, in nonzero
return _wrapfunc(a, 'nonzero')
File "C:\Users\vfota\diploma\venv\lib\site-packages\numpy\core\fromnumeric.py", line 58, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "C:\Users\vfota\diploma\venv\lib\site-packages\numpy\core\fromnumeric.py", line 51, in _wrapit
result = wrap(result)
File "C:\Users\vfota\diploma\venv\lib\site-packages\pandas\core\generic.py", line 1917, in array_wrap
return self._constructor(result, **d).finalize(self)
File "C:\Users\vfota\diploma\venv\lib\site-packages\pandas\core\series.py", line 292, in init
f"Length of passed values is {len(data)}, "
ValueError: Length of passed values is 1, index implies 5844.

Process finished with exit code 1`

bfast==0.5
matplotlib==3.1.3
numpy==1.19.2
pandas==1.0.0
pyopencl== 2020.2.2+cl12
pyOpenSSL== 19.0.0
scikit-learn==0.23.2
scipy==1.5.2
Sphinx==3.2.1
sphinx-bootstrap-theme==0.7.1
wget== 3.2
numpydoc==1.0.0

@Carolina710
Copy link

Hello, I'm not entirely sure but I think I had the same problem as you. In the function map_indices, in the file base, in your case, in "C:\Users\vfota\diploma\venv\lib\site-packages\bfast\monitor\python\base.py", I changed the line "drange = pandas.date_range(start, end, freq="d")", where is "d" of day I changed for "S". But it depends on the frequency of your dates, I think.

Good luck!

@jdries
Copy link

jdries commented Nov 10, 2020

I also ran into this, it is caused by this regression in numpy/pandas:
numpy/numpy#15555
There's also a simple workaround in _map_indices:
indices = numpy.argwhere(~numpy.isnan(ts.to_numpy())).T[0]

I would recommend this, as it doesn't look like the issue will be fixed soon in numpy.

@mortvest
Copy link
Collaborator

mortvest commented Nov 10, 2020

We have encountered this error. It is fixed in the develop branch #4 and will be pushed to master soon. Thanks

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

No branches or pull requests

4 participants