Skip to content

jaxtyping annotations are no longer subclasses of their array type.#309

Merged
patrick-kidger merged 9 commits intomainfrom
no-subclass
Mar 18, 2025
Merged

jaxtyping annotations are no longer subclasses of their array type.#309
patrick-kidger merged 9 commits intomainfrom
no-subclass

Conversation

@patrick-kidger
Copy link
Owner

This has been a subtle point that gets pretty tricky as plenty of classes aren't really designed to be subclassed further, and some may even take steps to ensure this isn't the case (e.g. concrete Equinox modules, or MLX arrays).

I think the only use-case for this is dispatch using plum -- I imagine we can probably find another way to make that happen.

Either way, if you're reading this because your code just broke, and you are relying on the current subclassing behaviour, then please open an issue on jaxtyping.

@patrick-kidger
Copy link
Owner Author

Also tagging @lockwo here -- IIRC you've previously bumped into weird edge cases here, can you give this PR a go and LMK if you hit any issues? If not I'll merge this in the next couple of days.

@gabrieldemarmiesse
Copy link

@patrick-kidger Apologies for the silence on my PR. I have more time now, should I merge this PR (#309) in #301 ? How do you want to proceed?

@patrick-kidger patrick-kidger force-pushed the no-subclass branch 2 times, most recently from f987a10 to e2f7cb3 Compare March 14, 2025 21:53
@lockwo
Copy link

lockwo commented Mar 15, 2025

Also tagging @lockwo here -- IIRC you've previously bumped into weird edge cases here, can you give this PR a go and LMK if you hit any issues? If not I'll merge this in the next couple of days.

Sure, I will test some things out

@patrick-kidger
Copy link
Owner Author

patrick-kidger commented Mar 15, 2025

@patrick-kidger Apologies for the silence on my PR. I have more time now, should I merge this PR (#309) in #301 ? How do you want to proceed?

I think this one supersedes #301! Ah right, you also have some doc updates. I'll pull those into this one now.

All going well I expect to merge this one soon, so MLX support will be there in the next release.

@patrick-kidger patrick-kidger force-pushed the no-subclass branch 2 times, most recently from bf40253 to 13eab3e Compare March 15, 2025 21:57
…ing. In particualr this is useful for better documentation.
This has been a subtle point that gets pretty tricky as plenty of classes aren't really designed to be subclassed further, and some may even take steps to ensure this isn't the case (e.g. concrete Equinox modules, or MLX arrays).

I *think* the only use-case for this is dispatch using plum -- I imagine we can probably find another way to make that happen.

Either way, if you're reading this because your code just broke, and you are relying on the current subclassing behaviour, then please open an issue on jaxtyping.
@lockwo
Copy link

lockwo commented Mar 18, 2025

Sure, I will test some things out

Haven't found any notable issues so far. And checking it against most of my code bases doesn't reveal any problems introduced by this PR :)

@patrick-kidger patrick-kidger merged commit 85f1fe3 into main Mar 18, 2025
4 checks passed
@patrick-kidger patrick-kidger deleted the no-subclass branch March 18, 2025 17:28
@patrick-kidger
Copy link
Owner Author

Awesome! Thanks for your help -- merged!

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

Successfully merging this pull request may close these issues.

3 participants