From f9066f8fc428322655d32a398634dd094c413950 Mon Sep 17 00:00:00 2001 From: "Alexander V. Hopp" Date: Wed, 11 Dec 2024 12:23:15 +0100 Subject: [PATCH] Save feature_names_out in variable to avoid unnecessary call --- baybe/utils/chemistry.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/baybe/utils/chemistry.py b/baybe/utils/chemistry.py index 7e7e93d03..6e42bcd9c 100644 --- a/baybe/utils/chemistry.py +++ b/baybe/utils/chemistry.py @@ -149,12 +149,11 @@ def smiles_to_fingerprint_features( ) name = f"{encoding.name}_" prefix = prefix + "_" if prefix else "" - no_descriptor_names = all( - "fingerprint" in f for f in fingerprint_encoder.get_feature_names_out() - ) + feature_names_out = fingerprint_encoder.get_feature_names_out() + no_descriptor_names = all("fingerprint" in f for f in feature_names_out) suffixes = [ f.split("fingerprint")[1] if no_descriptor_names else f - for f in fingerprint_encoder.get_feature_names_out() + for f in feature_names_out ] col_names = [prefix + name + suffix for suffix in suffixes] df = pd.DataFrame(features, columns=col_names, dtype=DTypeFloatNumpy)