From ca332ab476f645794e26a6f3bf8dae6378d7c320 Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Tue, 13 Feb 2024 18:18:23 -0500 Subject: [PATCH] Better error message --- xclim/indices/stats.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xclim/indices/stats.py b/xclim/indices/stats.py index d479fff9d..e08bb12e6 100644 --- a/xclim/indices/stats.py +++ b/xclim/indices/stats.py @@ -117,6 +117,11 @@ def fit( # Get the distribution dist = get_dist(dist) + if method == "PWM" and not hasattr(dist, "lmom_fit"): + raise ValueError( + f"The given distribution {dist} does not implement the PWM fitting method. Please pass an instance from the lmoments3 package." + ) + shape_params = [] if dist.shapes is None else dist.shapes.split(",") dist_params = shape_params + ["loc", "scale"]