[ANN] MetaArrays: Add metadata to your arrays

Hello all,

I have just made a small package available in the General registry: MetaArrays. It provides a generic means of adding additional meta-data to an array, (typically) using a NamedTuple. (It is perhaps similar in spirit to ImagesMetadata.jl, but takes a slightly different approach). I have found it handy in my own projects, and thought others might as well.

It’s probably easiest to demonstrate with an example (also found in README.md)

julia> y = meta(rand(10,10),val1="value1")
julia> x = meta(rand(10,10),val2="value2")

julia> z = x.*y
julia> z.val1
"value1"

The main advantage I find in working with this particular approach is that I can:

1.) Specialize methods over the type of the array, or the type of the particular metadata.

2.) Readily leverage the broadcasting and array tooling for a new array type, without having to think through all of the methods I have to overwrite. I’ve already done that work once, within MetaArrays, and don’t have to re-think through it each time.

Check out the README.md for more details.

I would appreciate any feedback (positive or negative) about the package.

10 Likes

Neat! I’ve been thinking about something like this for tables (e.g. TypedTables.Table), to allow for plotting recipes for different kinds of tables without type piracy.

Interesting! I’m not sure I understand. Is the idea that you would be able to attach some set of attributes to a table that plotting could use? How would you deal with the fact that data.column_name is a very natural way to access columns of table. Seems like you would need a different spelling to get at the attributes.

you would be able to attach some set of attributes to a table that plotting could use

No, I was thinking more like metadata that indicates the “type” of the table and that a plotting recipe can specialize on.

A new version of MetaArrays (v0.2.6) is now available. It fixes a few bugs and improves the README a bit.