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

change binomial registration #1029

Merged
merged 4 commits into from
Dec 31, 2023

Conversation

isaacsas
Copy link
Contributor

Closes #1028.

Uses @ChrisRackauckas's suggestion on how to handle this.

@codecov-commenter
Copy link

codecov-commenter commented Dec 29, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (dc7c7a9) 78.32% compared to head (bdf30c6) 78.04%.

Files Patch % Lines
src/extra_functions.jl 80.00% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1029      +/-   ##
==========================================
- Coverage   78.32%   78.04%   -0.29%     
==========================================
  Files          28       28              
  Lines        3387     3398      +11     
==========================================
- Hits         2653     2652       -1     
- Misses        734      746      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChrisRackauckas
Copy link
Member

  Candidates:
    binomial(n::Num, k::Real)
      @ Symbolics ~/work/Symbolics.jl/Symbolics.jl/src/wrapper-types.jl:142
    binomial(x::Number, k::Integer)
      @ Base intfuncs.jl:1145
  
  Possible fix, define
    binomial(::Num, ::Integer)

@shashi is there a reason why it's missing that dispatch?

@isaacsas
Copy link
Contributor Author

isaacsas commented Dec 30, 2023

This seems to fix the issue for me. The problem is several-fold. First, [Real,Integer] is never actually used by Symbolics in the macro (instead the types of the arguments are used if asserted, and if not Real is used). Even if it was used, however, it wouldn't help with the issue we have as we need a dispatch that allows the second input to be a BasicSymbolic{Real} (even though a user will pass an integer via the parameter map). This is what was previously defined via

@register_symbolic Base.binomial(n, k)::Int

Then there is the issue that we'd basically like to just say

@register_symbolic Base.binomial(n, k)::Int true
@register_symbolic Base.binomial(n, k::Int)::Int false

to get all the definitions, but this leads to overwriting of previous definitions involving Nums and such.

So the best solution I could come up with is to manually take the expressions from the second call to @register_symbolic and manually insert the non-redundant method definitions as I've now included.

@isaacsas
Copy link
Contributor Author

It would be better if the macro could check what methods are already defined, and only output the new subset of method definitions from the set it generates.

@isaacsas
Copy link
Contributor Author

Not sure why MTK tests are failing. binomial is not used anywhere in MTK from what I can see.

@ChrisRackauckas ChrisRackauckas merged commit 006543a into JuliaSymbolics:master Dec 31, 2023
13 of 18 checks passed
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.

binomial of two symbolics no longer works on 1.10
3 participants