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

Utility function for retrieving component names #61

Open
sethaxen opened this issue May 13, 2021 · 1 comment
Open

Utility function for retrieving component names #61

sethaxen opened this issue May 13, 2021 · 1 comment

Comments

@sethaxen
Copy link

Currently the only way I can find to retrieve the names of the components of ds::KeyedDataset is with keys(ds.data). As noted on slack, it's not safe to access ds.data directly, as its implementation might change. Is there another way to get the components list with an API function? Alternatively, an API function like components(ds::KeyedDataset) = collect(keys(ds.data)) would be useful.

Similarly, am I correct that given a component name k::Symbol, getproperty(ds::KeyedDataset, k) is the intended way to access the corresponding KeyedArray?

@rofinn
Copy link
Member

rofinn commented May 13, 2021

Is there another way to get the components list with an API function?

No, that's why we want to implement #60, so the interface will just be like any other dictionary with Tuple keys.

Similarly, am I correct that given a component name k::Symbol, getproperty(ds::KeyedDataset, k) is the intended way to access the corresponding KeyedArray?

Yes, if your keys are just single symbols then you can access the components with ds.train/ds[:train]/ds[(:train,)]. Internally, keys are stores as "path" tuples to handle hierarchical data, in which case you access the component with ds[(:train, :input, :foo)]

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

No branches or pull requests

2 participants