A wrong variable name in the documentation
ruochengzhai opened this issue · 6 comments
Dear developers, I found the "enum REB_STATUS status" in the "Variables" section might be wrong. "status" is the name of a function, while "_status" is the variable name in the source code.
Besides, perhaps it will be helpful to introduce more about the values of this variable and the errors it can raise in the documentation. Thanks.
Thanks for opening an issue. I believe you are talking about python versus C variables. The variable is called _status
in python because it should not be accessed directly. REBOUND's python API makes use of exception and therefore a user doesn't need the status
variable. There is a status()
function in python giving some status information, but not in C. Wheres maybe not ideally named, I don't think there is a bug or type. Maybe a note in the documentation would help!
Thank you so much for your reply. I'm curious if it is designed to be able to raise exceptions in the customized collision_solve function in Python, which seems to cause some errors. This is why I am using _status
.
If you want to raise a python exception from within the collision resolve function, you can set r->status=REB_STATUS_COLLISION
in the collision resolve function. See for example: https://github.com/hannorein/rebound/blob/main/src/collision.c#L725
Now I am using Python only so I try to use a custom function like the example in https://rebound.readthedocs.io/en/latest/collisions/#__tabbed_9_2. In this case, I find it is a must to access _status
to raise an exception. Is this true? Thank you!
That's correct. That's a python limitation. You can't raise an exception in a function that gets called via a c function. And REBOUND is using C internally because of speed.
I got it. I appreciate your answering my questions!