Skip to content

name2dim should accept values as a second input or return only the type #1191

Description

@felixcremer

I wanted to get a dimension from a symbol and then set the values by calling this dimension.
This fails, because the returned dimension from name2dim already has a colon in it.
I think it would be nice to either only return the type instead of an instance with a colon in it or to accept a second input to name2dim with the values to wrap.
We can circumvent the problem via rebuild, but that looks scary as a user.

julia> using DimensionalData

julia> Dimensions.name2dim(:Ti)(1:10)
ERROR: MethodError: objects of type Ti{Colon} are not callable
The object of type `Ti{Colon}` exists, but no method is defined for this combination of argument types when trying to treat it as a callable object.
Stacktrace:
 [1] top-level scope
   @ REPL[116]:1

julia> DD.rebuild(DD.Dimensions.name2dim(:Ti), 1:10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions