-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Unify Type
with Python's type system
#1207
base: main
Are you sure you want to change the base?
Conversation
Type
with Python type systemType
with Python's type system
4e5add1
to
d51271f
Compare
I just rebased and pushed to this branch. In general, if you ever want to update a branch/PR in this repo, rebasing (e.g. onto |
d51271f
to
94c6a00
Compare
This initial commit appears to locally expose a Mypy issue with an |
I again committed with |
457ebf4
to
b1d4098
Compare
This branch still has major issues, but it's in a good enough place to have a conversation about it. The key change in this branch so far was to make
|
It seems like we need to use This stuff starts to get pretty confusing right about here, especially when the Python/ Regarding the first point, it would be great if we could obtain (cached) subclasses via a |
in https://github.com/markusschmaus/Documents/blob/main/aesara_typing_demo.py But given these limitations, I think there needs to be a more flexible
This |
This should prevent errors when the input is already a Numba scalar, and it will use Numba's type information to selectively apply the scalar conversion.
Using the `auto_name` values will result in cache misses when caching is based on the generated source code, so we're not going to use it.
Co-authored-by: Ricardo Vieira <28983449+ricardoV94@users.noreply.github.com>
I asked about |
I'm looking at the class hierarchy of (1) There are two
(2) While the two kinds of random types (
(4) The more interesting case is that of types like
This leaves @brandonwillard, is my understanding correct? How does the suggested interface look like to you? Am I missing something? Should the interface be different? |
Yeah, that all sounds consistent enough to use. Here's something else to keep in mind: constants don't need to be a |
Would this make anything here easier? There would still be |
It could, if only because the way that The Mypy issues arise whenever we've attempted to take a parametric approach other than the current one that uses
I haven't thought through all of this yet, but—aside from keeping a few of those types around in some form for backward compatibility—we might be able to remove them. For instance, we wouldn't need a
The real question is how we would like to distinguish between "input" For instance, the Anyway, all this is only broadly related, and hopefully not necessary in any way. Regardless, it might be worth knowing in case there is a concrete way that these changes could help here. |
@@ -35,7 +49,90 @@ class Type(MetaObject, Generic[D]): | |||
The `Type` that will be created by a call to `Type.make_constant`. | |||
""" | |||
|
|||
def in_same_class(self, otype: "Type") -> Optional[bool]: | |||
_prop_names: tuple[str, ...] = tuple() | |||
_subclass_cache: dict[Any, "NewTypeMeta"] = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While not necessarily important right now, we might want to use weak reference dictionaries here; especially when/if we start constructing distinct type/class objects for each Literal
shape value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NewTypeMeta
approach is very interesting, and, as far as I can tell, looks quite promising! It seems like I'll need to run the test suite locally in order to really understand some of the details and implications of these changes (e.g. what's actually working, what's not, and why), though.
Otherwise, there appear to be some merge commits in this branch, so it will need to be rebased. That would also help make it easier to follow the changes via their distinct commits. Looking at the cumulative diffs alone gets too difficult, especially as the number of changes grows.
Also, at some point soon, we'll need to get the tests passing, at least up to the last commit. That way, reviewers can get some concrete understanding of what works, what doesn't, and what needs to be done via the failures in CI.
By the way, that demo is a great illustration, and the FYI: That file would make for a good Gist use-case. |
Ongoing work on #134
Here is my plan of action:
After each of these steps I want Aesara to be in a valid state with all tests passing.
Here are a few important guidelines and requirements to check before your PR can be merged:
pre-commit
is installed and set up.