From c79093821df2ed3017cd9c011229e877c4d574d9 Mon Sep 17 00:00:00 2001 From: nicholasbalasus <91984611+nicholasbalasus@users.noreply.github.com> Date: Mon, 27 Dec 2021 05:25:51 -0500 Subject: [PATCH] Add atan support for missings (#43523) Allowing atan to deal with two missing arguments --- base/math.jl | 3 +++ test/missing.jl | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/base/math.jl b/base/math.jl index 9a5e5377cf613..704557adc5f2e 100644 --- a/base/math.jl +++ b/base/math.jl @@ -1318,6 +1318,9 @@ for f in (:sin, :cos, :tan, :asin, :atan, :acos, end @eval $(f)(::Missing) = missing end +atan(::Missing, ::Missing) = missing +atan(::Number, ::Missing) = missing +atan(::Missing, ::Number) = missing exp2(x::AbstractFloat) = 2^x exp10(x::AbstractFloat) = 10^x diff --git a/test/missing.jl b/test/missing.jl index 0be8cb8ec9be4..c20dc21f188d3 100644 --- a/test/missing.jl +++ b/test/missing.jl @@ -109,6 +109,19 @@ end end end +@testset "two-argument functions" begin + two_argument_functions = [atan] + + # All two-argument functions return missing when operating on two missing's + # All two-argument functions return missing when operating on a scalar and an missing + # All two-argument functions return missing when operating on an missing and a scalar + for f in two_argument_functions + @test ismissing(f(missing, missing)) + @test ismissing(f(1, missing)) + @test ismissing(f(missing, 1)) + end +end + @testset "bit operators" begin bit_operators = [&, |, ⊻]