From 408fb089cf8c8ae905fab655505db6f1cde171fd Mon Sep 17 00:00:00 2001 From: LudoRNLT <102245368+LudoRNLT@users.noreply.github.com> Date: Thu, 7 Mar 2024 11:09:28 +0100 Subject: [PATCH 1/3] Update overlap.py to fix_factorial2 @D-TheProgrammer and I, think we solved the fix_factiorial issue#308 --- iodata/overlap.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/iodata/overlap.py b/iodata/overlap.py index 6ae5ab58..e5d41127 100644 --- a/iodata/overlap.py +++ b/iodata/overlap.py @@ -45,9 +45,14 @@ def factorial2(n, exact=False): """ # Scipy 1.11.x returns an integer when n is an integer, but 1.10.x returns an array, # so np.array(n) is passed to make sure the output is always an array. - out = scipy.special.factorial2(np.array(n), exact=exact) - out[out <= 0] = 1.0 - out[out <= -2] = 0.0 + if exact == False : #Keep when exact=False + out = scipy.special.factorial2(np.array(n), exact=exact) + else : + if n is not int: + n = np.array([n]) # convert n to a np.array + for x in range(len(n)): + x = n[x] + out = scipy.special.factorial2(x, exact) #compute on each individual element x of the array n return out From 6ff6bd82572da0bf22941b182973321057415cb5 Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Fri, 3 May 2024 08:07:37 +0200 Subject: [PATCH 2/3] Update iodata/overlap.py --- iodata/overlap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iodata/overlap.py b/iodata/overlap.py index e5d41127..a7f91e98 100644 --- a/iodata/overlap.py +++ b/iodata/overlap.py @@ -48,7 +48,7 @@ def factorial2(n, exact=False): if exact == False : #Keep when exact=False out = scipy.special.factorial2(np.array(n), exact=exact) else : - if n is not int: + if not isinstance(n, int): n = np.array([n]) # convert n to a np.array for x in range(len(n)): x = n[x] From 9d014bec8216f444124e69f7ba31779f21ea494b Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Fri, 3 May 2024 08:07:53 +0200 Subject: [PATCH 3/3] Update iodata/overlap.py --- iodata/overlap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iodata/overlap.py b/iodata/overlap.py index a7f91e98..ce0df94c 100644 --- a/iodata/overlap.py +++ b/iodata/overlap.py @@ -45,7 +45,7 @@ def factorial2(n, exact=False): """ # Scipy 1.11.x returns an integer when n is an integer, but 1.10.x returns an array, # so np.array(n) is passed to make sure the output is always an array. - if exact == False : #Keep when exact=False + if not exact: out = scipy.special.factorial2(np.array(n), exact=exact) else : if not isinstance(n, int):