BUG: Docs (or implementation) for negative inputs to factorial2 are incorrect
See original GitHub issueDescribe your issue.
The docstring for factorial2 says:
If
n < 0
, the return value is 0.
However directly below that in the code, we can see this is not the case for n==-1
if exact:
if n < -1:
return 0
if n <= 0:
return 1
This will give a value of 1 for factorial2(-1)
(if exact
is false, it returns 1.0).
The code could be made consistent with the documentation (either making the result for n==-1 be 0 or saying that for n<-1, factorial2 is 0).
Alternatively, the code could be adapted to perform the extended double factorial which allows for negative inputs.
Reproducing Code Example
scipy.special.factorial(-1)
Error message
None
SciPy/NumPy/Python version information
1.7.1 1.21.2 sys.version_info(major=3, minor=9, micro=7, releaselevel=‘final’, serial=0)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:14 (1 by maintainers)
Top Results From Across the Web
BUG: handle inconsistencies in factorial functions and their ...
BUG: Docs (or implementation) for negative inputs to factorial2 are incorrect #15246. Closed. This was referenced on Mar 6.
Read more >Testing-intro
Program testing can be used to show the presence of bugs, but never to show ... factorial2(x) == factorial(x), \ "My factorial function...
Read more >SciPy 1.9.0 Release Notes — SciPy v1.9.3 Manual
Unlike other reduction functions, stats.mode didn't consume the axis being operated on and failed for negative axis inputs. Both the bugs have been...
Read more >Mailman 3 ANN: SciPy 1.9.0 - NumPy-Discussion - python.org
Several BSpline methods now raise an error if inputs have ``ndim > 1``. ... DOC: False information in docs - scipy.stats.ttest_1samp * `#15700 ......
Read more >Source code for sympy.functions.combinatorial.factorials
[docs]class factorial(CombinatorialFunction): r"""Implementation of ... is positive for every nonnegative input, and for # every odd negative input which is ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think this can be closed gh-15592 changed the docstring to match the implementation and gh-15600 is discussing the current inconsistencies and any possible extensions.
Hello is there someone who can guide me to solve this issue. I really want to do this, It will be my first contribution, Please guide me I’m a newbie