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

added repr to orbits and fixed orbitalelements.ipynb #738

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

dtamayo
Copy link
Collaborator

@dtamayo dtamayo commented Jan 12, 2024

Fixed OrbitalElements.ipynb to new syntax of sim.particles[i].orbit().

Also added a repr to the Orbit class so when we finish a cell with e.g.

sim.particles[1].orbit()

it will give us useful information instead of just Orbit object at memory loc X

@hannorein
Copy link
Owner

hannorein commented Jan 12, 2024

Thanks! Couldn't __repr__ just call __str__? I see there is a conceptual difference between the two but we're not making use of it right now. (We could in principle, __str__ could output something like "eccentric orbit" or "hyperbolic orbit" to make it more human-interpretable)

@dtamayo
Copy link
Collaborator Author

dtamayo commented Jan 12, 2024

Good point...I actually just deleted __str__. I just looked up that the behavior is that if there is no __str__, __repr__ gets called (e.g. when doing print(orb)), but it doesn't go the other way (you need a __repr__ to not get blah obj at memory loc X) . So maybe it's less redundant to just define a `__repr__1? Unless like you say, we want to get different output when we end a cell with

ps[1].orbit()

vs

print(ps[1].orbit())

@hannorein
Copy link
Owner

makes sense!

(Don't know why the REBOUNDx trigger fails)

@dtamayo
Copy link
Collaborator Author

dtamayo commented Jan 12, 2024

emailed you

@hannorein hannorein merged commit 2d7f0c8 into hannorein:main Jan 12, 2024
25 of 26 checks passed
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.

2 participants