dianna icon indicating copy to clipboard operation
dianna copied to clipboard

Unclear error message when mistyping a method name

Open cwmeijer opened this issue 2 years ago • 6 comments

image image It should have given the valid options as well (RISE, LIME, kernelSHAP).

cwmeijer avatar Sep 08 '22 05:09 cwmeijer

I happend to have fixed this in my attempt to split the method classes, see PR #325

loostrum avatar Sep 08 '22 08:09 loostrum

    try:
         method_submodule = importlib.import_module(f'dianna.methods.{method.lower()}')
     except ImportError as err:
         raise Exception(f"Method {method} does not exist") from err
     try:
         method_class = getattr(method_submodule, f"{method}{modality}")
     except AttributeError as err:
         raise Exception(f"Data modality {modality} is not available for method {method}") from err```

loostrum avatar Sep 08 '22 08:09 loostrum

This also handles the case of KernelSHAP for text, which isn't available.

loostrum avatar Sep 08 '22 08:09 loostrum

My version doesn't give the valid methods / modalities though. Would it be doable to automatically get a list of those? I guess having them hardcoded in init.py is much easier.

loostrum avatar Sep 08 '22 09:09 loostrum

@loostrum can we close this issue?

elboyran avatar Dec 01 '22 13:12 elboyran

Not yet I think. The method name is no longer case sensitive and the error is better: ValueError: Method RRISE does not exist, but you don't get a list of the available methods yet, which was also part of this issue. I can add some code to do that as well.

loostrum avatar Dec 01 '22 13:12 loostrum