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

Unable to overwrite time or component attributes of Trajectory objects #112

Open
LuisAbelRT opened this issue Jun 1, 2023 · 1 comment
Assignees
Labels
feature ✨ New feature or request

Comments

@LuisAbelRT
Copy link

After creating a Trajectory object, traj, it is possible to successfully overwrite traj.r by using +=. For instance:

import yupi
x = [2, 5, 3]
traj = yupi.Trajectory(x)

traj.r += 1
traj.r
# Vector([[3.],
          [6.],
          [4.])

However, one gets an Attribute Error when trying to do the analogous change with time or component attributes, as indicted bellow:

traj.t += 1
# Attribute Error: can't set attribute 't'
traj.r.x += 1
# Attribute Error: can't set attribute 'x'

It would be great if one could overwrite other Trajectory's attributes as well.

@gvieralopez gvieralopez self-assigned this Jun 8, 2023
@gvieralopez gvieralopez added the feature ✨ New feature or request label Jun 8, 2023
@alpelito7
Copy link
Collaborator

alpelito7 commented Feb 19, 2024

I also suggest that when overwriting traj.r with a np.ndarray, yupi automatically converts it to a Vector object in order to prevent attribute errors:

traj = yupi.Trajectory([2, 5, 3])
traj.r = np.array([5,3,4])[:,None]
print(traj.r.x)
# AttributeError: 'numpy.ndarray' object has no attribute 'x'
traj.r = yupi.Vector([5,3,4])[:,None]
print(traj.r.x)
# Vector([5, 3, 4])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants