-
Notifications
You must be signed in to change notification settings - Fork 59
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
standardized_index_fit_params with method="ML" raises TypeError in scipy #1617
Comments
It seems that the only way the function can be run with |
Hi! Thanks for the report. This is weird, because this case is already tested in our test suite. I used xclim version 0.47 here and it worked fine. Can you confirm that this example is what you were trying to do but with different data, I didn't miss anything (plus the actual spi computation at the end)? from xclim.testing import open_dataset
from xclim.indices.stats import standardized_index_fit_params
ds = open_dataset("sdba/CanESM2_1950-2100.nc").chunk({"location":1})
precipitation = ds.pr.sel(time=slice("1950", "1980"))
params = standardized_index_fit_params(
precipitation,
freq="MS",
window=12,
dist="gamma",
method="ML",
)
params.compute()
I agree. I can't tell from your screenshot if your data is daily or already monthly, but I tested both cases and they work. Could you:
|
Thanks @coxipi for looking into this. I just ran your example and it failed with the same error message. I am attaching my pdm.lock file in case you wanna see all of my dependencies, I had to change it to a txt file for Github to allow me to attach it) A summary: I am going to downgrade dask and xarray and see what happens |
Oh and scipy is 1.6.1 |
@saschahofmann Think you could run the following instead?:
|
Of course. Here you go
|
I downgraded dask to an early 2023 version but it still failed now playing around with Scipy versions. |
I tried to understand the traceback but its not clear to me where could be |
Using scipy==1.6.1 on a fresh install, from scipy import stats
stats.gamma.fit([1,2,3], method="mle") I get the error you pointed out:
So we need to update our dependencies to enforce a minimal working version of scipy with xclim. Sorry about that! For now, you could update scipy directly? When your environment is already activated:
I will check now which version (1.X.Y) is needed. EDIT: I didn't find info on this particular point in the release notes, but I just checked and scipy==1.7 works with the code above |
@Zeitsperre I'm not familiar with changing dependencies. |
This is actually great timing: We'll be raising the version pins quite a bit in #1565! |
@saschahofmann If you could tell us if updating to scipy>=1.9 solves all your issues, it would be great! If you're using conda and don't want to mess with your environment, you could create a clone and update scipy in the clone instead:
But eventually, to use Cheers! |
🎉 Just upgraded to 1.12.0 and both my case and the example you've sent me succeeded! Thanks for being so fast to help me, would love to give you 5 stars 😄 . Do you want me to close this or shall I leave it open until the version is pinned? |
Haha, thanks for the good words, it's appreciated. I'm glad you're good to go now! You can leave the issue open, we'll close it once the pull request solving it has been merged. Thanks again for the feedback. |
Setup Information
Description
When I try to compute the params to compute SPI using
standardized_index_fit_params
fromxclim.indices.stats
withmethod="ML"
, the computation fails within scipy/_distn_infrastructure.py:2395.
Changing the method to
APP
fixes the failure.###Note
Make sure to call
.compute()
if you are working with DaskArrays.Steps To Reproduce
This is the code I have been running
At least from my perspective I don't see what could cause this based on the input
Additional context
Full stack trace
Contribution
Code of Conduct
The text was updated successfully, but these errors were encountered: