-
Notifications
You must be signed in to change notification settings - Fork 275
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
Dependent types: is it possible to have array sizes and dimensions declared in the types? #308
Comments
Hey sorry for the delay replying to this (we've been travelling for PyCon Colombia). It's a good question and one we thought quite a lot about. We'd love to have something like that working well, but we decided the complexity it would introduce with extra Exploring the sizes in the arrays would be a nice side-project if someone wants to take it on. My suggestion would be to have the sizes specified in reverse order. So an array One option for the library would be to add spaces for the types, without using them in layer signatures. This might allow us to avoid introducing complexity for users, while giving us the option of using the types or allowing users to use them. I'm not sure. There are other ways we could have done the type-system. Possibly we'd be better off having a type-variable for the floats vs ints distinction. Currently we have a problem where it's hard to say "If it takes a floats array, it returns a floats array (but of different dimension)". You have to use an overload for that, not a type variable. If the types also specified the sizes, this situation would arise even more. So maybe we want |
Is it possible to have array sizes in the types?
Something like:
and have that type check the definitions of the models and composition of layers to guarantee everything fits?
For example, making this an explicit type error:
If thinc doesn't support this today, is it something that is even implementable in Python's type annotation system?
The text was updated successfully, but these errors were encountered: