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

python interface for Vec3d #92

Closed
wants to merge 3 commits into from
Closed

python interface for Vec3d #92

wants to merge 3 commits into from

Conversation

hannorein
Copy link
Collaborator

Don't merge this yet! I've been playing around to simplify the python syntax when working with vectors. The changes here are a bit of a hack, but they allow the user to set and get params that are 3-vectors in a nicer way:

Instead of

particles.params['sx']  = 1
particles.params['sy']  = 2
particles.params['sz']  = 3

This would allow you to do

particles.params['Vec3d_s']  = [1,2,3]

Similarly, getter returns a Vec3d:

v = particles.params['Vec3d_s']

No changes on the c side are necessary but one could implement the same hack there.

We've talked about this sort of thing many times before. So I'm probably ignoring a ton of side effects.

Can you remind me, what was the reason not to implement a three vector type as an option for a param?

Side note: Unfortunately numpy doesn't convert Vec3d to a sensible numpy array when using np.array(v), so it can't easily be used in assignments. I have narrowed down the issue, but can't seem to find a workaround. The getter could just return a python list instead of a Vec3d to fix that.

@hannorein hannorein changed the base branch from ode to newpr91 January 7, 2023 16:53
@dtamayo
Copy link
Owner

dtamayo commented Jan 7, 2023

I think all the complications came from trying to allow for lists of arbitrary shapes. I don't think there's any problem at all with using vec_3d as a rebx_type, and I do think that would actually give a much nicer interface...

@hannorein
Copy link
Collaborator Author

That makes sense. I guess before we had spin, there was little reason to give priority to a 3 vector, over say, a 3x3 matrix. But now there might be an argument to be made to add Vec3d. Well, not urgent...

@dtamayo
Copy link
Owner

dtamayo commented Jan 7, 2023

Too many things to work on, too little time! :) This would be nice to get in for this effect. I have an all day meeting tomorrow at AAS...this might be the perfect mindless work for parts of it that don't really apply to the DDA :)

@hannorein
Copy link
Collaborator Author

Do you want me to do it? I have one more day before teaching starts ;-)

@dtamayo
Copy link
Owner

dtamayo commented Jan 7, 2023 via email

@hannorein hannorein closed this Jan 11, 2023
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