From 124bfea9cdb1792eeacfb279c815e74dd55c6af2 Mon Sep 17 00:00:00 2001 From: Ashrockzzz2003 Date: Fri, 3 Jan 2025 12:24:39 +0530 Subject: [PATCH] Replace .sample with .choice to fix cxOnePointLeafBiased to support python 3.12. --- deap/gp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deap/gp.py b/deap/gp.py index ccc47b6b..c5282283 100644 --- a/deap/gp.py +++ b/deap/gp.py @@ -744,7 +744,7 @@ def cxOnePointLeafBiased(ind1, ind2, termpb): if len(common_types) > 0: # Set does not support indexing - type_ = random.sample(common_types, 1)[0] + type_ = random.choice(list(common_types)) index1 = random.choice(types1[type_]) index2 = random.choice(types2[type_])