From 2c928f41afc2f6a0c6201f45b74af5b38fa244ac Mon Sep 17 00:00:00 2001 From: "Olivier J.N. Bertrand" <olivier.bertrand@uni-bielefeld.de> Date: Wed, 10 Oct 2018 10:26:12 +0200 Subject: [PATCH] Avoid overwritting by copying motion vec --- navipy/moving/maths.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/navipy/moving/maths.py b/navipy/moving/maths.py index d2d14da..3a3c3a9 100644 --- a/navipy/moving/maths.py +++ b/navipy/moving/maths.py @@ -41,9 +41,9 @@ def next_pos(motion_vec, move_mode, move_param=None): names=['position', 'orientation']) speed = pd.Series(index=index) - speed['location']['dx'] = motion_vec['location']['dx'] - speed['location']['dy'] = motion_vec['location']['dy'] - speed['location']['dz'] = motion_vec['location']['dz'] + speed.loc[('location', 'dx')] = motion_vec[('location', 'dx')] + speed.loc[('location', 'dy')] = motion_vec[('location', 'dy')] + speed.loc[('location', 'dz')] = motion_vec[('location', 'dz')] # speed = motion_vec.loc[['dx', 'dy', 'dz']] if move_mode == 'on_cubic_grid': # speed in spherical coord @@ -87,7 +87,7 @@ def next_pos(motion_vec, move_mode, move_param=None): # scaling = 1 # <=> dt = 1, user need to scale speed in dt units else: raise ValueError('grid_mode is not supported') - toreturn = motion_vec + toreturn = motion_vec.copy() toreturn.loc[('location', 'x')] += speed['location']['dx'] toreturn.loc[('location', 'y')] += speed['location']['dy'] toreturn.loc[('location', 'z')] += speed['location']['dz'] -- GitLab