✨: HasX attributes#34
Conversation
|
@jorenham @NeilGirdhar @lucascolley this doesn't resolve the current discussion re a |
jorenham
left a comment
There was a problem hiding this comment.
I like the Has* protocols. Optype will cover the CanArray* ones I think. There might be some that can't be expressed because Self can't be passed as generic type argument, but I suppose we can deal with it when needed.
One nit is that ... are not needed when there's a docstring, which already counts as an expression or statement or something.
What do we do about docstrings?
Yes, my pylint is complaining. But IMO empty methods should have |
Hmm good question. Maybe a numpy-esque |
Yea I guess there's something to be said for that. It just looks a bit weird to me to see a |
8096aff to
3793c1f
Compare
cb3dbb3 to
dec1842
Compare
dec1842 to
53ddb98
Compare
53ddb98 to
a5e3d5b
Compare
|
@jorenham I added tests and made the protocols public. |
|
@jorenham This should cover all the array attributes. |
a5e3d5b to
27ef62d
Compare
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
27ef62d to
c65c5d5
Compare
Would you like to be a maintainer, Neil? |
|
@lucascolley Oh, sorry, that wasn't what I was implying! But maybe I'd consider it if this project remains stalled for a many more months 😄 I'm just really excited for this project to be usable 😄 |
|
On the one hand, I am hesitant to endorse any particular way of going about the protocols, as a non-expert. On the other hand, I think going with whatever @nstarman thinks is best would probably be fine for now, as long as we clearly mark that the API is experimental and subject to change. |
|
Sounds great to me!! |
Good idea! Lucas is also very welcome as maintainer as far as I'm concerned. |
|
@lucascolley Done. |
lucascolley
left a comment
There was a problem hiding this comment.
I read through the whole diff, just two comments for you @nstarman, then I think we can merge it.
I also read through the discussion in the open comments. To elaborate on #34 (comment), I think we are fine to proceed in this manner, as I still think we are within our rights to change the API down the line, e.g. to provide a namespace with a restricted set of protocols whereby there is only one obvious way to achieve real use-cases.
I wonder whether, however, we should put the current developments under a sub-namespace of the package before the first release? Something like array_api_typing.experimental or array_api_typing.v0 or array_api_typing.comprehensive. That seems sufficiently non-committal to keep all stakeholders happy?
|
Why do we want to export: Are users going to use these in their own annotations? |
|
There was the suggestion of #34 (comment), but I suppose I'm inclined to the view that we should in the first instance focus on useful annotations of 'array in -> array out' functions, before we branch out to cover other cases. |
|
given the lack of movement here I am going to start merging things and see where it takes us. Don't take this as me asserting I know the best thing for the project — would be good to get all stakeholders back on the same page before making a proper release :) |
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com> Signed-off-by: Lucas Colley <lucas.colley8@gmail.com>
I still don't think we add functionality to the API unless there's an an actual use-case in it in an array-api library. So sorry, but I'm not going to approve this. But don't consider this a hard veto or anything; I'm fine with anyone else approving in my place. |
|
can I convince you to become a maintainer @NeilGirdhar ? |
|
Hi. I'm traveling for collaborations and conferences this past month and will be back at my normal desk in a week and able to engage with PRs and Issues. |
Okay. I'll try to find time to help move this along 😄 |
Awesome!
@kgryte please could you add Neil to the array-api-typing team? |
|
@jorenham does optype do Protocol speedups like beartype for faster isinstance checks? I'm reading https://jorenham.github.io/optype/reference/#isinstance-with-protocols and I don't see anything to indicate so. |
It doesn't, because it's not needed (anymore): beartype/numerary#20 But I'd actually advise against using runtime-checkable protocols because of the many false positives they produce (i.e. they're completely broken) |
|
I had a chance to look at this again. IMO we get this in and work on getting the full suite of Protocols for describing the Array API. |
|
Yes, happy to discuss #34 (comment) in a follow-up or here |
|
Or here is good :). a function that defers to a shape attribute, otherwise trying to use the |
|
to reiterate my take: happy to include these if all agree, but I have a preference for starting off with exposing the minimal public API necessary for helping type 'array in -> array out' functions. 'something similar to an array in -> something else out' can come later IMO. |
Yes, thank you. So my question was who is going to call |
IMO exposed to the user since
I'm happy to start that way as well, but what would that be? Like |
|
basically making https://github.com/data-apis/array-api-extra/blob/main/src/array_api_extra/_lib/_utils/_typing.pyi more accurate/complete |
|
SGTM. Many of these are like `CanAbs = opt.CanAbs[...]`` |
Requires #32. I'll rebase when that's in.Now preceding #32.