-
Notifications
You must be signed in to change notification settings - Fork 126
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 trigonometric functions to not raise on f32 inputs #1051
Fix trigonometric functions to not raise on f32 inputs #1051
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved pending the precision issues with the tan
test.
It looked like they were off by a single decimal place 🙄. Let us know if they persist.
Precision issues will happen on different machines, OSes and architectures. So one option is to compare that they are within certain delta. |
@josevalim Do we have a helper somewhere that acts like |
We don't but it should be easy to implement. Subtract two series, compute the absolute, see if they are within delta and return true if all true. |
Agreed. It'd be generally helpful too. pi = :math.pi()
radians_list = [-2 * pi, -pi, -pi / 2, 0, pi / 2, pi, 2 * pi]
degrees_list = [-360.0, -180.0, -90.0, 0.0, 90.0, 180.0, 360.0]
radians = Series.from_list(radians_list, dtype: :f32)
degrees = Series.from_list(degrees_list, dtype: :f32)
result = Series.degrees(radians)
assert all_close?(result, degrees)
assert Series.dtype(result) == {:f, 64}
# ...
defp all_close?(%Series{} = a, %Series{} = b, tol \\ 1.0e-8) do
Series.subtract(a, b)
|> Series.abs()
|> Series.less_equal(tol)
|> Series.all?()
end |
@billylanchantin fixed the test. |
Thanks, @sasikumar87! |
Fixes #1047