RatInABox-Lab / RatInABox

A python package for modelling locomotion in complex environments and spatially/velocity selective cell activity.
MIT License
175 stars 31 forks source link

Fix bug when sampling points in a non-rectangular environment #26

Closed frederikrogge closed 1 year ago

frederikrogge commented 1 year ago

Hey, I figured there was a bug with how points are being sampled randomly in non-rectangular environments. First, points were sampled uniformly within the absolute distance between the extents. Therefore, if the extent in x-direction was -2, 4, only points between 0 and 6 were sampled. Secondly, it should be checked whether points are actually within the boundaries of the environment if the environment is not rectangular. However, the last if-statement checked whether it was rectangular. Both bugs should be fixed with this PR. Feel free to have a look, thanks :)

TomGeorge1234 commented 1 year ago

Hey, thank you so much for catching these! You're absolutely right and the fixes are great.

I recommend you reinstall RatInABox from 1.x branch as there was another small bug regarding concave environments I caught and fixed as a result of studying yours.

Cheers!

frederikrogge commented 1 year ago

No problem, glad it helped.

Cheers!