-
Notifications
You must be signed in to change notification settings - Fork 12
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
Term.get_coefficients fails for jax implementation when built from source #75
Comments
Writing an issue is always the most clarifying exercise. I was hitting this error because I was using TermConvolution, which uses this line: celerite2/python/celerite2/jax/terms.py Lines 301 to 310 in e75dd45
but the jax implementation of |
Great question! This is an issue introduced by this PR: #68 I should probably spend some time thinking about how to fix this properly, but one option for the short term (it'll take a minor? performance hit) would be something like: import jax
import jax.numpy as jnp
from celerite2.jax import terms
def custom_sho_get_coeffs(self):
ar, cr = self.get_overdamped_coefficients()
ac, bc, cc, dc = self.get_underdamped_coefficients()
cond = jnp.less(self.Q, 0.5)
selectr = lambda x: jax.lax.cond(cond, lambda y: y, jnp.zeros_like, operand=x)
selectc = lambda x: jax.lax.cond(cond, jnp.zeros_like, lambda y: y, operand=x)
return selectr(ar), selectr(cr), selectc(ac), selectc(bc), selectc(cc), selectc(dc)
terms.SHOTerm.get_coefficients = custom_sho_get_coeffs
sho = terms.SHOTerm(S0=1, w0=3000, Q=0.6)
sho.get_coefficients() |
I can confirm the fix above works for me for now. Thanks Dan! |
Hi @dfm,
Today I've built celerite2 from source following the recommendations on the install docs. I'm trying to do something simple, like this
but I'm getting the following error
At first I thought this could be an accident of the multiple
SHOTerm
implementations, for example, herecelerite2/python/celerite2/jax/terms.py
Lines 473 to 478 in e75dd45
and here
celerite2/python/celerite2/jax/terms.py
Line 481 in e75dd45
but commenting the first one out doesn't solve the problem.
Any ideas? Thanks!
The text was updated successfully, but these errors were encountered: