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

Fix method ambiguity error of NaNMath.pow #690

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ end
@number_methods(BasicSymbolic{<:Number}, term(f, a), term(f, a, b), skipbasics)
@number_methods(BasicSymbolic{<:LiteralReal}, term(f, a), term(f, a, b), onlybasics)

# Fix method ambiguity issue in NaNMath >= 1.0.2
NaNMath.pow(x::BasicSymbolic{<:Number}, y::Integer) = x^y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NaNMath.pow(x::BasicSymbolic{<:Number}, y::Integer) = x^y
NaNMath.pow(x::BasicSymbolic{<:Number}, y::Integer) = maketerm(typeof(x), NaNMath.pow, [x, y], metadata(x))

Copy link
Contributor Author

@devmotion devmotion Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to avoid NaNMath in that case in NaNMath < 1.0.2 and on NaNMath >= 1.0.2 an Integer as second argument falls back to ^ anyway. So I think using ^ is the better and safer approach, regardless of the NaNMath version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then can we add this to @number_methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did but I guess incorrectly. The original error is gone but it seems it causes https://github.com/JuliaSymbolics/SymbolicUtils.jl/actions/runs/12708708876/job/35426212172?pr=690#step:6:885.


for f in vcat(diadic, [+, -, *, \, /, ^])
@eval promote_symtype(::$(typeof(f)),
T::Type{<:Number},
Expand Down
Loading