Skip to content

Commit 3abd9f6

Browse files
authored
Add more UnaryOperations with @unary (#4142)
* Update AbstractOperations.jl * Update test_computed_field.jl * Update test_computed_field.jl * Update AbstractOperations.jl * Update AbstractOperations.jl * Update AbstractOperations.jl * Fix docstring
1 parent 9ece0be commit 3abd9f6

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/AbstractOperations/AbstractOperations.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ include("show_abstract_operations.jl")
6767
# Make some operators!
6868

6969
# Some operators:
70-
import Base: sqrt, sin, cos, exp, tanh, abs, -, +, /, ^, *
71-
import Base: abs
70+
import Base: -, +, /, ^, *
71+
import Base: sqrt, sin, cos, exp, tanh, abs
72+
import Base: log10, log, tan, sinh, cosh
7273

73-
@unary sqrt sin cos exp tanh abs
74+
@unary sqrt sin cos exp tanh abs log10 log tan sinh cosh
7475
@unary -
7576
@unary +
7677

src/AbstractOperations/unary_operations.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,22 @@ julia> square_it(x) = x^2
5656
square_it (generic function with 1 method)
5757
5858
julia> @unary square_it
59-
Set{Any} with 10 elements:
59+
Set{Any} with 15 elements:
6060
:+
61-
:sqrt
62-
:square_it
61+
:log10
62+
:interpolate_identity
6363
:cos
6464
:exp
65-
:interpolate_identity
66-
:-
6765
:tanh
68-
:sin
6966
:abs
67+
:log
68+
:cosh
69+
:square_it
70+
:-
71+
:sqrt
72+
:tan
73+
:sinh
74+
:sin
7075
7176
julia> c = CenterField(RectilinearGrid(size=(1, 1, 1), extent=(1, 1, 1)));
7277

test/test_computed_field.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,10 @@ for arch in archs
364364

365365
@testset "Unary computations [$A, $G]" begin
366366
@info " Testing correctness of compute! unary operations..."
367-
for unary in (sqrt, sin, cos, exp, tanh)
367+
dont_test = tuple(:interpolate_identity)
368+
operators_to_test = filter(op -> !(op dont_test), Oceananigans.AbstractOperations.unary_operators)
369+
for unary_symbol in operators_to_test
370+
unary = eval(unary_symbol)
368371
@test compute_unary(unary, model)
369372
end
370373
end

0 commit comments

Comments
 (0)