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

fix keyword para issue in galpy.orbit.Orbits.Orbit._call_internal #569

Merged
merged 2 commits into from May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions galpy/orbit/Orbits.py
Expand Up @@ -5481,6 +5481,8 @@
2019-02-01 - Started - Bovy (UofT)
2019-02-18 - Written interpolation part - Bovy (UofT)
"""
if len(args) == 0 and "t" in kwargs:
args = [kwargs.pop("t")]

Check warning on line 5485 in galpy/orbit/Orbits.py

View check run for this annotation

Codecov / codecov/patch

galpy/orbit/Orbits.py#L5485

Added line #L5485 was not covered by tests
if len(args) == 0 or (not hasattr(self, "t") and args[0] == 0.0):
return numpy.array(self.vxvv).T
elif not hasattr(self, "t"):
Expand Down
15 changes: 15 additions & 0 deletions tests/test_orbit.py
Expand Up @@ -9475,3 +9475,18 @@ def test_integrate_backwards():
numpy.std(o.Jacobi(times)) / numpy.fabs(numpy.mean(o.Jacobi(times))) < 1e-4
), f"Orbit integration with method {method} does not conserve energy when integrating from a negative time to a positive time"
return None


# Test that Orbit._call_internal(t0) and Orbit._call_internal(t=t0) return the same results
def test_call_internal_kwargs():
from galpy.orbit import Orbit
from galpy.potential import LogarithmicHaloPotential

lp = LogarithmicHaloPotential(normalize=1.0, q=0.9)
o = Orbit([1.0, 0.1, 1.2, 0.3, 0.2, 2.0])
times = numpy.array([0.0, 10.0])
o.integrate(times, lp)
assert numpy.array_equal(
o._call_internal(10.0), o._call_internal(t=10.0)
), "Orbit._call_internal(t0) and Orbit._call_internal(t=t0) return different results"
return None