Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ New Features
Bug fixes
---------

- Fixed ``TimeInterpolatedPotential`` returning zero energy, gradient, and density
after being pickled or deep-copied.

- Fixed ``find_actions_o2gf()`` raising an error whenever any toy action or angle
was NaN. NaN samples are now dropped with a warning, and it raises only if more
than half of the samples are NaN.
Expand Down
2 changes: 1 addition & 1 deletion src/gala/potential/potential/builtin/cytimeinterp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ cdef class TimeInterpolatedWrapper(CPotentialWrapper):
self.interp_state.wrapped_potential = <void*>self.wrapped_potential.cpotential

self.init(
[0.0], # value of G doesn't matter for this wrapper
[G],
np.zeros(n_dim, dtype=np.float64), # placeholder origin
np.eye(n_dim, dtype=np.float64), # placeholder rotation
n_dim=n_dim
Expand Down
8 changes: 7 additions & 1 deletion tests/regression/test_potential_timeinterpolated_539.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ def test_timeinterpolated_pickle(tmpdir):
pickle.dump(pot, f)

with open(tmpdir.join("time_interp_pot.pkl"), "rb") as f:
pot = pickle.load(f)
new_pot = pickle.load(f)

q = [8.0, 1.0, 0.5] * u.kpc
for t in [0.0, 3.3, 10.0] * u.Gyr:
assert u.allclose(new_pot.energy(q, t=t), pot.energy(q, t=t))
assert u.allclose(new_pot.gradient(q, t=t), pot.gradient(q, t=t))
assert u.allclose(new_pot.density(q, t=t), pot.density(q, t=t))