File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
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}
11
11
). ..
12
12
)
13
13
end
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
- return all (
18
- dim -> f ((getfield (arg, dim) for arg in args). .. )
19
- dimension_names
20
- )
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)
24
+ end
25
+ return output
21
26
end
22
27
23
28
Base. float (q:: AbstractQuantity{T} ) where {T<: AbstractFloat } = convert (T, q)
You can’t perform that action at this time.
0 commit comments