Skip to content

Commit 4b5fce7

Browse files
committed
Change * and / to be elementwise between OutputVar
1 parent ffb539d commit 4b5fce7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Var.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ macro overload_binary_op(op)
997997
ret_dims = x.dims
998998
ret_dim_attributes = x.dim_attributes
999999

1000-
ret_data = $op(x.data, y.data)
1000+
ret_data = @. $op(x.data, y.data)
10011001

10021002
return OutputVar(
10031003
ret_attributes,

test/test_Var.jl

+7
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ end
154154
@test var1plusvar3.data == data1 .+ data3
155155
@test ClimaAnalysis.short_name(var1plusvar3) == "bob + bula"
156156
@test ClimaAnalysis.long_name(var1plusvar3) == "hi + bob"
157+
158+
# Test for element wise multiplication and division between OutputVars
159+
var_times = var1 * var3
160+
@test var_times.data == var1.data .* var3.data
161+
162+
var_divide = var1 / var3
163+
@test var_divide.data == var1.data ./ var3.data
157164
end
158165

159166
@testset "Reductions (sphere dims)" begin

0 commit comments

Comments
 (0)