From 6e33886064bffcff49eee935d2671ef410bbb0d7 Mon Sep 17 00:00:00 2001 From: comatrion <31922007+comatrion@users.noreply.github.com> Date: Wed, 16 Oct 2019 18:22:06 +0100 Subject: [PATCH] Update doe_factorial.py Include n in range --- pyDOE2/doe_factorial.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyDOE2/doe_factorial.py b/pyDOE2/doe_factorial.py index 565c968..1ac5d81 100644 --- a/pyDOE2/doe_factorial.py +++ b/pyDOE2/doe_factorial.py @@ -309,7 +309,7 @@ def fracfact_by_res(n, res): """ # Determine minimum required number of base-factors. min_fac = next(dropwhile(lambda n_: _n_fac_at_res(n_, res) < n, - range(res - 1, n)), None) + range(res - 1, n + 1)), None) if min_fac is None: raise ValueError('design not possible') @@ -349,7 +349,7 @@ def _n_fac_at_res(n, res): """ Calculate number of possible factors for fractional factorial design with `n` base factors at resolution `res`. """ - return sum(binom(n, r) for r in range(res - 1, n)) + n + return sum(binom(n, r) for r in range(res - 1, n + 1)) + n ################################################################################