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

Better typing and checks for index header #83

Open
AKuederle opened this issue Aug 2, 2023 · 1 comment
Open

Better typing and checks for index header #83

AKuederle opened this issue Aug 2, 2023 · 1 comment
Labels
good first issue Good for newcomers

Comments

@AKuederle
Copy link
Member

We should allow users to clearly specify what header values they expect.
This could be used to actively check if get_index is implemented correctly and returns the expected values and it could be used to improve the typing of label and group.

To do that we could allow the user to specify a typing.NamedTuple

class MyDataset(Dataset):
    _INDEX_HEADER = NamedTuple("MyDataset", participant=str, test=str)

Notes:

  • If we use this as return value for group, this will not be correct typing, as group likely only returns a tuple with a subset of these fields. However, I think this is still better than the current typing which is Tuple[str, ...]. At least it allows the IDE to autocomplete the subfields
  • We could set _INDEX_HEADER as default to Tuple[str, ...]
  • When checking the index during creatiion, we should check that our tuple type has the same name as the dataset (otherwise the printed output might be confusing.
  • We should further check of the df returned by get_index has the correct column names AND the correct types per column
@AKuederle AKuederle added the good first issue Good for newcomers label Aug 2, 2023
@AKuederle
Copy link
Member Author

This is partially implemented in #113.

This PR does not yet add a check if the Index matches the header

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

No branches or pull requests

1 participant