From 4e576fe2656c77b4a2572b11ad8611a7fc564e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Fri, 28 Apr 2023 13:21:02 +0200 Subject: [PATCH] Don't try to find closest match if input is empty (#5700) --- holoviews/core/util.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/holoviews/core/util.py b/holoviews/core/util.py index 3576dcfb8a..e07cb09d2c 100644 --- a/holoviews/core/util.py +++ b/holoviews/core/util.py @@ -2204,6 +2204,8 @@ def closest_match(match, specs, depth=0): Recursively iterates over type, group, label and overlay key, finding the closest matching spec. """ + if len(match) == 0: + return None new_specs = [] match_lengths = [] for i, spec in specs: @@ -2226,11 +2228,10 @@ def closest_match(match, specs, depth=0): elif new_specs: depth = depth+1 return closest_match(match[1:], new_specs, depth) + elif depth == 0 or not match_lengths: + return None else: - if depth == 0 or not match_lengths: - return None - else: - return sorted(match_lengths, key=lambda x: -x[1])[0][0] + return sorted(match_lengths, key=lambda x: -x[1])[0][0] def cast_array_to_int64(array):