@@ -1007,36 +1007,52 @@ macro overload_binary_op(op)
1007
1007
)
1008
1008
end
1009
1009
function Base. $op (x:: OutputVar , y:: Real )
1010
- ret_var = copy (x)
1011
- @. ret_var. data = $ op (x. data, y)
1012
- empty! (ret_var. attributes)
1010
+ ret_attributes = empty (x. attributes)
1013
1011
1014
1012
specific_attributes = (" short_name" , " long_name" )
1015
1013
1016
1014
for attr in specific_attributes
1017
1015
if haskey (x. attributes, attr)
1018
- ret_var . attributes [attr] =
1016
+ ret_attributes [attr] =
1019
1017
string (x. attributes[attr], " " , string ($ op), " " , y)
1020
1018
end
1021
1019
end
1022
1020
1023
- return ret_var
1021
+ ret_dims = deepcopy (x. dims)
1022
+ ret_dim_attributes = deepcopy (x. dim_attributes)
1023
+
1024
+ ret_data = @. $ op (x. data, y)
1025
+
1026
+ return OutputVar (
1027
+ ret_attributes,
1028
+ ret_dims,
1029
+ ret_dim_attributes,
1030
+ ret_data,
1031
+ )
1024
1032
end
1025
1033
function Base. $op (x:: Real , y:: OutputVar )
1026
- ret_var = copy (y)
1027
- @. ret_var. data = $ op (x, y. data)
1028
- empty! (ret_var. attributes)
1034
+ ret_attributes = empty (y. attributes)
1029
1035
1030
1036
specific_attributes = (" short_name" , " long_name" )
1031
1037
1032
1038
for attr in specific_attributes
1033
1039
if haskey (y. attributes, attr)
1034
- ret_var . attributes [attr] =
1040
+ ret_attributes [attr] =
1035
1041
string (x, " " , string ($ op), " " , y. attributes[attr])
1036
1042
end
1037
1043
end
1038
1044
1039
- return ret_var
1045
+ ret_dims = deepcopy (y. dims)
1046
+ ret_dim_attributes = deepcopy (y. dim_attributes)
1047
+
1048
+ ret_data = @. $ op (x, y. data)
1049
+
1050
+ return OutputVar (
1051
+ ret_attributes,
1052
+ ret_dims,
1053
+ ret_dim_attributes,
1054
+ ret_data,
1055
+ )
1040
1056
end
1041
1057
end
1042
1058
end
0 commit comments