-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Type classes for lazy resampling #5418
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
Conversation
Signed-off-by: Ben Murray <[email protected]>
…able class Signed-off-by: Ben Murray <[email protected]>
…uire set_random_state Signed-off-by: Ben Murray <[email protected]>
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.
Hi @wyli @atbenmurray , I see you 2 experts submitted several PRs today, I was busy with other tasks, will try to review all of them tomorrow. Thanks. |
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.
May I know why use the class name with "XXXType"? LazyTransform
may be enough? Like other classes in the codebase.
Thanks.
Initially, I was going to call it ILazyTransform as this is a convention in other languages, but @ericspod requested that I rename it. I could see any of the following working:
I could do 3. but then we would be changing RandomizableTransform -> RandomizableTransformBase and I think that would cause problems, so I went with 2. |
numpy and pytorch defines the |
This kind of dispatch method is certainly a useful way of solving issues with operator overloading, but it doesn't solve every problem with subtyping ndarrays or tensors. For example, I would have preferred to solve the multi sampling issue by having metatensor keep an internal data tensor that could be shared between multiple metatensor instances, which would be possible with a TensorType interface to inherit from but not possible as metatensor is a tensor, rather than just appearing to be a tensor (this is IMO a shortcoming of pytorch that they don't provide a pure type signature). I agree that a pure duck typing approach is quite pythonic, but the big libraries use isinstance a lot to validate their inputs which means that you can't get away with a class that walks and quacks like a tensor but isn't of Tensor type. I think people are generally more used to that than they are that checking whether a method has certain attributes or not. |
Hi @ericspod , May I know your opinion about this naming question? Thanks in advance. |
…lt implementation for subclassing where appropriate Signed-off-by: Ben Murray <[email protected]>
/black |
Signed-off-by: Ben Murray <[email protected]>
Signed-off-by: Ben Murray <[email protected]>
Signed-off-by: Ben Murray <[email protected]>
Signed-off-by: Ben Murray <[email protected]>
/build |
It is saying the blossom-ci is failing, but when I check it, is says that it succeeded, but I suspect part of it is not running |
I guess torch 1.13 released a few hours ago changed some of the typing. probably unrelated to this PR... |
Signed-off-by: Wenqi Li <[email protected]>
/build |
Nice! |
Signed-off-by: Ben Murray <[email protected]> Fixes # . ### Description A few sentences describing the changes proposed in this pull request. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [x] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: Ben Murray <[email protected]> Signed-off-by: KumoLiu <[email protected]>
Signed-off-by: Ben Murray <[email protected]> Fixes # . ### Description A few sentences describing the changes proposed in this pull request. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [x] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: Ben Murray <[email protected]> Signed-off-by: Yiheng Wang <[email protected]>
Signed-off-by: Ben Murray [email protected]
Fixes # .
Description
A few sentences describing the changes proposed in this pull request.
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.