skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.4k stars 211 forks source link

Operators for Angle objects. #646

Closed bryan-lunt closed 2 years ago

bryan-lunt commented 2 years ago

It should be possible to add and subtract Angle objects. Also to multiply them by a scalar. Angles are also something like a vector so maybe even an inner product operator would be in order. Thanks.

brandon-rhodes commented 2 years ago

Thank you for the suggestion, but I would prefer for users to take the angle's .radians or .degrees and do math with those. Otherwise, Skyfield will have to implement all the same operators on an Angle that NumPy implements on a numeric array. Not only is that several dozen methods that would need to be added to Skyfield, but they would all be essentially empty of functionality — they would merely forward on the method call to the underlying NumPy method, which is slower than having users simply call the NumPy operator directly.

If there are any Angle maneuvers you've found difficult, describe them and we'll work out something to make them convenient. But let's opt not to turn the units.py classes into huge wrappers around NumPy functionality that I would rather users access directly, which I also think integrates Skyfield better into the Python data and science stack. Thanks!