Skip to content
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

Fix #9. compatibility for tostring and tobytes #10

Merged
merged 3 commits into from
Apr 29, 2016
Merged

Conversation

carpedm20
Copy link
Contributor

No description provided.

@gdb
Copy link
Collaborator

gdb commented Apr 28, 2016

Can we do this without catching the exception? It'd be nicer to know in advance which method we should use, and then just make one attempt. Otherwise we risk catching an unintended error.

@carpedm20
Copy link
Contributor Author

@gdb How about checking the version of numpy? Because tobytes was added after 1.9.0 and it will cause error for numpy<=1.8.2.

@gdb
Copy link
Collaborator

gdb commented Apr 28, 2016

Sounds great!

On Thursday, April 28, 2016, Taehoon Kim [email protected] wrote:

@gdb https://github.com/gdb How about checking the version of numpy?
Because tobytes was added after 1.9.0 and it will cause error for
numpy<=1.8.2.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#10 (comment)

Sent from mobile

@@ -281,7 +281,10 @@ def capture_frame(self, frame):
if frame.dtype != np.uint8:
raise error.InvalidFrame("Your frame has data type {}, but we require uint8 (i.e. RGB values from 0-255).".format(frame.dtype))

self.proc.stdin.write(frame.tobytes())
if np.__version__ >= '1.9.0':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we need to do something more sophisticated here:

>>> '1.10.0' >= '1.9.0'
False

Try using Disutils version parsing, like we do here: https://github.com/openai/mujoco-py/blob/master/mujoco_py/config.py#L45?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should do the work:

distutils.version.StrictVersion(numpy.__version__) >= distutils.version.StrictVersion('1.9.0')

@carpedm20
Copy link
Contributor Author

@gdb: Now the version check is done as:

if distutils.version.StrictVersion(np.__version__) >= distutils.version.StrictVersion('1.9.0'):
    self.proc.stdin.write(frame.tobytes())
else:
    self.proc.stdin.write(frame.tostring())

@gdb gdb merged commit cc0e865 into openai:master Apr 29, 2016
@gdb
Copy link
Collaborator

gdb commented Apr 29, 2016

Thank you!

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