-
Notifications
You must be signed in to change notification settings - Fork 15
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
Simplify state conversions (excludes Crystal environments) #247
Simplify state conversions (excludes Crystal environments) #247
Conversation
Update dev main with public main
… old code is still there.
…old code is still there.
@carriepl I would like to have your advice on how to proceed with this PR. The situation is the following:
I am thinking that an auxiliary branch off |
Is there any obstacle to rebasing this branch (or a copy of this branch, to be safer) over the main and then updating the crystal environments in the rebased version of this branch? |
That's about what I thought you could say. The only obstacle is that I don't feel super at ease with rebasing yet. Would you mind outlining what the steps should be? |
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.
Love this, net -1000 lines of code is a good PR any day of the week!
I wonder whether some of the environment specific conversion logic would be further abstracted into the base class or not, but it does not seem cumbersome to write these few lines of code, so it's not a priority.
Good stuff!
else: | ||
return torch.tensor(x, dtype=torch.long, device=device) | ||
|
||
|
||
def tint(x, device, int_type): | ||
if isinstance(x, list) and torch.is_tensor(x[0]): | ||
return torch.stack(x).type(int_type).to(device) | ||
return torch.stack(x).to(device=device, dtype=int_type) |
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.
Just a note - if you're constantly doing this, it's a performance hazard. As I'm sure you're aware preallocating and filling an empty tensor will perform better than stacking lists, but of course it can lead to more complex code. Might be a good subject for a different PR.
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.
You're right. Rather for another PR indeed.
OK one thing you could do is merge locally I agree that rebasing will work but it's also confusing. To save yourself heartache, make a zip archive of your local repo before you do the |
So I am doing this the way it is easiest and safest to me.
|
fe105d1
into
conversions-simplify-merge
This PR simplifies state conversions in the following ways:
state*2oracle
has been removed as well as other mentions tooracle
. In short, references to the oracle are now unified into references to the proxy.statebatch2proxy
andstatetorch2proxy
are now unified bystates2proxy
statebatch2policy
andstatetorch2policy
are now unified bystates2policy
state2proxy
has been removed from all environments because it is enough with the implementation in the base environment, which callsstates2proxy
.policy2state
has been removed.I have also taken the chance to add richer docstrings. I believe all other changes should be related to the above.
Note: the PR includes some deletion of files, which come from a different branch because I messed up things somehow... 😓 Sorry for that!