@@ -116,12 +116,18 @@ end
116116
117117# Define dimensionally-aware evaluation routine:
118118@inline function deg0_eval (
119- x:: AbstractVector{T} , x_units:: Vector{Q} , t:: AbstractExpressionNode{T}
119+ x:: AbstractVector{T} ,
120+ x_units:: Vector{Q} ,
121+ t:: AbstractExpressionNode{T} ,
122+ allow_wildcards:: Bool ,
120123) where {T,R,Q<: AbstractQuantity{T,R} }
121- t. constant && return WildcardQuantity {Q} (Quantity (t. val, R), true , false )
122- return WildcardQuantity {Q} (
123- (@inbounds x[t. feature]) * (@inbounds x_units[t. feature]), false , false
124- )
124+ if t. constant
125+ return WildcardQuantity {Q} (Quantity (t. val, R), allow_wildcards, false )
126+ else
127+ return WildcardQuantity {Q} (
128+ (@inbounds x[t. feature]) * (@inbounds x_units[t. feature]), false , false
129+ )
130+ end
125131end
126132@inline function deg1_eval (
127133 op:: F , l:: W
@@ -149,16 +155,26 @@ end
149155end
150156
151157function violates_dimensional_constraints_dispatch (
152- tree:: AbstractExpressionNode{T} , x_units:: Vector{Q} , x:: AbstractVector{T} , operators
158+ tree:: AbstractExpressionNode{T} ,
159+ x_units:: Vector{Q} ,
160+ x:: AbstractVector{T} ,
161+ operators,
162+ allow_wildcards,
153163) where {T,Q<: AbstractQuantity{T} }
154164 if tree. degree == 0
155- return deg0_eval (x, x_units, tree):: WildcardQuantity{Q}
165+ return deg0_eval (x, x_units, tree, allow_wildcards ):: WildcardQuantity{Q}
156166 elseif tree. degree == 1
157- l = violates_dimensional_constraints_dispatch (tree. l, x_units, x, operators)
167+ l = violates_dimensional_constraints_dispatch (
168+ tree. l, x_units, x, operators, allow_wildcards
169+ )
158170 return deg1_eval ((@inbounds operators. unaops[tree. op]), l):: WildcardQuantity{Q}
159171 else
160- l = violates_dimensional_constraints_dispatch (tree. l, x_units, x, operators)
161- r = violates_dimensional_constraints_dispatch (tree. r, x_units, x, operators)
172+ l = violates_dimensional_constraints_dispatch (
173+ tree. l, x_units, x, operators, allow_wildcards
174+ )
175+ r = violates_dimensional_constraints_dispatch (
176+ tree. r, x_units, x, operators, allow_wildcards
177+ )
162178 return deg2_eval ((@inbounds operators. binops[tree. op]), l, r):: WildcardQuantity{Q}
163179 end
164180end
@@ -186,8 +202,9 @@ function violates_dimensional_constraints(
186202 if X_units === nothing && y_units === nothing
187203 return false
188204 end
205+ allow_wildcards = ! (options. dimensionless_constants_only)
189206 dimensional_output = violates_dimensional_constraints_dispatch (
190- tree, X_units, x, options. operators
207+ tree, X_units, x, options. operators, allow_wildcards
191208 )
192209 # ^ Eventually do this with map_treereduce. However, right now it seems
193210 # like we are passing around too many arguments, which slows things down.
0 commit comments