Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor gamma cleanups. #62

Merged
merged 2 commits into from
Oct 25, 2022
Merged

minor gamma cleanups. #62

merged 2 commits into from
Oct 25, 2022

Conversation

oscardssmith
Copy link
Member

This should arguably should use Base.@assume_effects :terminates_locally but that only exists on 1.8+.

This should arguably should use `Base.@assume_effects :terminates_locally` but that only exists on 1.8+.
@codecov
Copy link

codecov bot commented Oct 24, 2022

Codecov Report

Base: 94.70% // Head: 94.53% // Decreases project coverage by -0.16% ⚠️

Coverage data is based on head (c264d27) compared to base (6aa49b7).
Patch coverage: 57.89% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
- Coverage   94.70%   94.53%   -0.17%     
==========================================
  Files          18       18              
  Lines        1963     1957       -6     
==========================================
- Hits         1859     1850       -9     
- Misses        104      107       +3     
Impacted Files Coverage Δ
src/gamma.jl 72.22% <57.89%> (-11.12%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@heltonmc
Copy link
Member

Awesome! I'm wondering if we should go ahead and solve #58 here.

Essentially, that issue can be solved by having some check if x is an integer and (x < 21) to just return the base factorial lookup table.... I'd honestly be fine just to have a different dispatch for it. So you would only hit that branch if you input an integer nu but I guess we could also check for it within the routines... but it seems way easier to do it here than update all of the functions. Something like

function gamma(x::Integer)
    if x < 21
        if x > 0
            return float(factorial(x - 1))
        elseif x < 0
            return DomainError...
        else
            return Float64(Inf)
        end
    else
        return gamma(Float64(x))
    end
end

@heltonmc
Copy link
Member

Looking at how SpecialFunctions.jl handles it..

https://github.com/JuliaMath/SpecialFunctions.jl/blob/36c547b4a270b6089b1baf7bec05707e9fb8c7f9/src/gamma.jl#L567-L575

Which might be cleaner than what I just posted

@heltonmc
Copy link
Member

Great - I'll merge and test if this solves that issue.

@heltonmc heltonmc merged commit 325cb5b into master Oct 25, 2022
@oscardssmith oscardssmith deleted the oscardssmith-gamma-cleanup branch October 25, 2022 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants