From 5dbb8fca94e8cfd624560ea6182b66a5a48ac844 Mon Sep 17 00:00:00 2001 From: Janis Heuel Date: Thu, 29 Aug 2024 10:59:36 +0200 Subject: [PATCH] added if clause for more than two given ordinal parameters --- propulate/propagators/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/propulate/propagators/base.py b/propulate/propagators/base.py index f56b7796..a1ffb112 100644 --- a/propulate/propagators/base.py +++ b/propulate/propagators/base.py @@ -537,7 +537,10 @@ def __call__(self, *inds: Individual) -> Individual: # type: ignore[override] if isinstance( self.limits[limit][0], int ): # If ordinal trait of type integer. - position[limit] = self.rng.randint(*self.limits[limit]) + if len(self.limits[limit]) == 2: # Selecting one value in range of ordinal parameter + position[limit] = self.rng.randint(*self.limits[limit]) + else: # Selecting one distinct value from ordinal parameters + position[limit] = self.rng.choice(self.limits[limit]) elif isinstance( self.limits[limit][0], float ): # If interval trait of type float.