Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass multiple pre-grouped vectors? #79

Closed
jkrumbiegel opened this issue Aug 17, 2020 · 1 comment · Fixed by #185 or #188
Closed

How to pass multiple pre-grouped vectors? #79

jkrumbiegel opened this issue Aug 17, 2020 · 1 comment · Fixed by #185 or #188

Comments

@jkrumbiegel
Copy link
Member

I have a data transformation pipeline that returns a vector of vectors with floats, and a vector of strings, which name the groups. This doesn't work:

vecs = [randn(100) for _ in 1:10]
names = string.(1:10)

data((vecs = vecs, names = names)) * ...

But concatenating all the vectors into one works. This seems an unnecessary step as it forces me to create a long-format table. Is there a better way?

@piever
Copy link
Collaborator

piever commented Aug 17, 2020

Yes, you don't need to go back to long format (even though naming supported is wip for pregrouped vectors).

The trick is to use the dims() context (i.e., every entry of the array is a trace).

For example:

vecs = [randn(100) for _ in 1:10]
dims() * style(vecs, color=dims(1))

does what you want. Technically, one could have gotten here from this example, but I guess it's better to add an explicit example here. Automatic naming in this scenario is not supported (#64), but should just be a matter of picking an array with named indices. As usual in julia, there's a bunch of packages that do that (I already use NamedDims for named dimensions, so maybe something that builds on that would be nice).

I suspect that dims() could become the default context to be honest, so that just

vecs = [randn(100) for _ in 1:10]
style(vecs, color=dims(1))

works. I need to think whether there are some drawbacks to this (it also depends how common this scenario is).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants