Skip to content

Constructor for Axis #84

@baggepinnen

Description

@baggepinnen

I'm struggling to figure out how to properly create an Axis

From a vector of symbols, state_names, I want to create an axis that can be used for the variable x and the matrix A in

x' = A*x

I guess it would be possible to have a slurping constructor that accepts something like the following

julia>     ax_x = Axis(state_names...)
FlatAxis()

and internally dispatches to the NamedTuple so I do not have to figure out this awkward way of constructing such an Axis.

julia> ax_x = Axis((; (state_names .=> (1:sys.nx))...))
Axis(x1 = 1,)

Indeed, if I define

function ComponentArrays.Axis(names::Symbol...)
    Axis((; (names .=> (1:length(names)))...))
end

julia>     ax_x = Axis(state_names...)
Axis(x1 = 1,)

I seem to get what I want :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions