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

Add generic fallback to all scalar functions #71

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

YingboMa
Copy link
Member

No description provided.

@oscardssmith
Copy link
Member

IMO this isn't quite correct. NaNMath says that functions return NaN rather than throwing so we should check if we get an error and return NaN in these fallback methods.

@oscardssmith
Copy link
Member

This also needs tests.

@oameye
Copy link

oameye commented Jan 22, 2025

Can this be merged?

I stumbled upon it when running:

using Symbolics
m = [cos(ψ) -sin(ψ); sin(ψ) cos(ψ)] 
jacfunc = Symbolics.build_function(m, ψ; expression=Val(false))[1]
jacfunc((0+0.1im))

@ChrisRackauckas
Copy link
Member

No because it fails tests. But if someone fixes the ambiguities then it would be good to merge.

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.33%. Comparing base (b351b97) to head (cf61ad0).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/NaNMath.jl 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #71      +/-   ##
==========================================
+ Coverage   96.15%   96.33%   +0.17%     
==========================================
  Files           1        1              
  Lines         104      109       +5     
==========================================
+ Hits          100      105       +5     
  Misses          4        4              

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

@ChrisRackauckas ChrisRackauckas merged commit d766aee into JuliaMath:master Jan 22, 2025
16 of 17 checks passed
@oameye
Copy link

oameye commented Jan 22, 2025

❤️

@devmotion
Copy link
Member

IMO this isn't quite correct. NaNMath says that functions return NaN rather than throwing so we should check if we get an error and return NaN in these fallback methods.

That was not addressed? IMO the definitions in this PR are just wrong. Fallbacks require to check for errors or must be known to be safe (as was the case e.g. for the pow fallbacks before this PR).

@ChrisRackauckas
Copy link
Member

It was addressed when the other PR was related to it though?

@devmotion
Copy link
Member

Which other PR?

@devmotion
Copy link
Member

For instance, this PR added

pow(x, y) = ^(x, y)
to the master branch which is completely unsafe in general. What's safe, however are the fallbacks for integer exponents and complex arguments added in #83.

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.

5 participants