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

Make DataSample values generic to support shape typing #377

Open
redeboer opened this issue Dec 6, 2021 · 1 comment
Open

Make DataSample values generic to support shape typing #377

redeboer opened this issue Dec 6, 2021 · 1 comment
Labels
⚠️ Interface Breaking changes to the API

Comments

@redeboer
Copy link
Member

redeboer commented Dec 6, 2021

Currently, values of the DataSample dict alias are NumPy arrays. A more backend-agnostic solution might be #131 and the new numpy.typing module, but an alternative might be to use a (possibly bound) TypeVar. This also might also improve deduced types in case there are scalar values in the data sample given to a Function/ParametrizedFunction (currently, this is marked as wrong by mypy/pyright).

Update below: #377 (comment)

@redeboer redeboer added the ⚠️ Interface Breaking changes to the API label Dec 6, 2021
@redeboer redeboer added this to the 0.4.1 milestone Dec 6, 2021
@redeboer redeboer modified the milestones: 0.4.1, 0.4.2 Jan 5, 2022
@redeboer redeboer removed this from the 0.4.2 milestone Feb 25, 2022
@redeboer redeboer changed the title Make value type of DataSample generic Make value type of DataSample generic Apr 11, 2022
@redeboer redeboer added this to the Future milestone Jul 5, 2022
@redeboer redeboer removed this from the Future milestone Apr 27, 2023
@redeboer
Copy link
Member Author

Since Python 3.11, there is TypeVarTuple, which you can use for variadic typing (PEP 646). NumPy does not (and will not?1) be able to type shapes of arrays, but it is possible to do this externally using TypeVarTuple.

Footnotes

  1. NumPy is very strict with its dependencies: it doesn't have any. This means it also does not have typing_extensions and therefore cannot type array shapes with variadics.

@redeboer redeboer changed the title Make value type of DataSample generic Make value type of DataSample generic to support shape typing Jul 26, 2023
@redeboer redeboer changed the title Make value type of DataSample generic to support shape typing Make DataSample values generic to support shape typing Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ Interface Breaking changes to the API
Projects
Status: No status
Development

No branches or pull requests

1 participant