This repository has been archived by the owner on Dec 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add constraint comparison utility to
world.utils
. (#542)
Summary: Pull Request resolved: #542 This adds an equality testing utility for `torch.constraint` objects/classes, so that these comparisons can be consolidated within a single utility function `is_constraint_eq`. Usage: ``` is_constraint_eq(dist.support, (constraints.real, constraints.greater_than)) ``` , instead of: ``` isinstance(dist.support, (constraints._Real, constraints._GreaterThan)) ``` , or the more obfuscatory ``` dist.support is constraints.real or isinstance(dist.support, constraints.greater_than) ``` See pytorch/pytorch#50616 for more details (note that the changes suggested in the issue are complementary). - This avoids usage of the non-public constraint classes (like `constraints._Real`, `constraints._Interval`). - Makes it possible to consolidate future changes (e.g. those arising out of the introduction of an `Independent` constraint - pytorch/pytorch#50547) within a single function. This is a pre-requisite to some other fixes that are currently blocking D25918330. I will add these small fixes when I merge D25918330. Differential Revision: D25935106 fbshipit-source-id: f585562b0f627f9b9669a54bcb2b45b05d560fe9
- Loading branch information
1 parent
a178589
commit 89fde5c
Showing
7 changed files
with
124 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters