haosulab / ManiSkill2-Learn

Apache License 2.0
77 stars 15 forks source link

fix ValueError in share_memory func (#23) #31

Closed Mr-Tony921 closed 2 months ago

Mr-Tony921 commented 2 months ago

This pull request addresses issue #23. I encountered the same error in the share_memory function when using Python 3.10. The error occurs due to incompatible shapes during the comparison of x.base and y.base.

To fix this, I added a shape compatibility check before performing the base comparison. If the shapes are incompatible, the function now safely returns False without attempting the comparison. This prevents the ValueError and ensures the function works correctly across different environments.

xuanlinli17 commented 2 months ago

Thanks! Should "ret = x.base is y.base" be "ret = (x.base == y.base)"?

Mr-Tony921 commented 2 months ago

Thanks! Should "ret = x.base is y.base" be "ret = (x.base == y.base)"?

Yep! I didn't consider the issue with element-wise comparison of numpy arrays. It has been fixed and submitted.