File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,18 @@ function map_dimensions(f::F, args::AbstractDimensions...) where {F<:Function}
1111 ). ..
1212 )
1313end
14- function all_dimensions (f:: F , args:: AbstractDimensions... ) where {F<: Function }
15- dimension_type = promote_type (typeof (args). parameters... )
16- dimension_names = static_fieldnames (dimension_type)
17- for dim in dimension_names
18- f ((getfield (arg, dim) for arg in args). .. ) || return false
14+ @generated function all_dimensions (f:: F , args:: AbstractDimensions... ) where {F<: Function }
15+ # Test a function over all dimensions
16+ output = Expr (:&& )
17+ dimension_type = promote_type (args... )
18+ for dim in Base. fieldnames (dimension_type)
19+ f_expr = :(f ())
20+ for i= 1 : length (args)
21+ push! (f_expr. args, :(args[$ i]. $ dim))
22+ end
23+ push! (output. args, f_expr)
1924 end
20- return true
25+ return output
2126end
2227
2328Base. float (q:: AbstractQuantity{T} ) where {T<: AbstractFloat } = convert (T, q)
You can’t perform that action at this time.
0 commit comments