Hello, the title might be confusing, but I will explain the issue in detail. I am building a function that requires me to specify the data type it accepts, as shown below:
function demo(input::ComponentVector{Float64, Vector{Float64}, Tuple{Axis{(a = 1, b = 2)}}})
...
end
In this function, I want to input a variable input that can be both ComponentVector(a=1,b=2) and ComponentVector(a=ones(100),b=ones(100)). However, the constructed function can only accept ComponentVector(a=1,b=2) because the type of ComponentVector(a=ones(100),b=ones(100)) is ComponentVector{Float64, Vector{Float64}, Tuple{Axis{(a = 1:100, b = 101:200)}}}.
Currently, I have a workaround, which is to first convert the ComponentVector to a @NamedTuple type, and the function accepts parameters as:
Hello, the title might be confusing, but I will explain the issue in detail. I am building a function that requires me to specify the data type it accepts, as shown below:
In this function, I want to input a variable
input
that can be bothComponentVector(a=1,b=2)
andComponentVector(a=ones(100),b=ones(100))
. However, the constructed function can only acceptComponentVector(a=1,b=2)
because the type ofComponentVector(a=ones(100),b=ones(100))
isComponentVector{Float64, Vector{Float64}, Tuple{Axis{(a = 1:100, b = 101:200)}}}
.Currently, I have a workaround, which is to first convert the
ComponentVector
to a@NamedTuple
type, and the function accepts parameters as:But converting
ComponentVector
to@NamedTuple
type consumes a lot of computational resources (about 10 times more).