You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to run one of the example notebooks (Generating_waveforms.ipynb) and ran into a couple of issues.
Firstly, it seems that all calls of IMRPhenomD.gen_IMRPhenomD need updating to take in f_ref. Once this issue is resolved, the actual function IMRPhenomD.gen_IMRPhenomD doesn't like the way the frequencies are passed in when defining h0_simple. Using jax 0.4.10 the shapes of fs[0] and fs[:1] are () and (1,0) resp., and the former raises an IndexError:
---------------------------------------------------------------------------IndexErrorTraceback (mostrecentcalllast)
CellIn[33], line107h0_simple=lambdatheta: IMRPhenomD.gen_IMRPhenomD(fs[0], theta, fs[0]).real9h0_grad=grad(h0_simple)
--->10print(h0_grad(theta_ripple_h0))
[... skippinghidden10frame]
CellIn[33], line7, in (theta)
1# Finally, lets take some derivatives!2# We start by writing a simple lambda function to make something that only depends3# on the intrinsic parameters45# Note here that JAX is expecting a scalar output to compute derivatives6# We therefore just select a single frequency point to make this easy---->7h0_simple=lambdatheta: IMRPhenomD.gen_IMRPhenomD(fs[0], theta, f_ref).real9h0_grad=grad(h0_simple)
10print(h0_grad(theta_ripple_h0))
File [~/miniconda3/envs/systematics/lib/python3.10/site-packages/ripple/waveforms/IMRPhenomD.py:582](https://file+.vscode-resource.vscode-cdn.net/Users/jthompson/projects/systematics/systematics-git/notebooks/~/miniconda3/envs/systematics/lib/python3.10/site-packages/ripple/waveforms/IMRPhenomD.py:582), ingen_IMRPhenomD(f, params, f_ref)
579theta_extrinsic=jnp.array([params[4], params[5], params[6]])
581coeffs=get_coeffs(theta_intrinsic)
-->582h0=_gen_IMRPhenomD(f, theta_intrinsic, theta_extrinsic, coeffs, f_ref)
583returnh0
...
4537f"non-None[/Ellipsis](https://file+.vscode-resource.vscode-cdn.net/Ellipsis) indices for dim {arr_ndim}.")
4538ellipses= (ifori, eltinenumerate(idx) ifeltisEllipsis)
4539ellipsis_index=next(ellipses, None)
IndexError: Toomanyindicesforarray: 1non-None[/Ellipsis](https://file+.vscode-resource.vscode-cdn.net/Ellipsis) indicesfordim0.
Changing to fs[:1] resolves this but now the function outputs an array (of length 1) that breaks grad. In the end I got things to work by changing h0_simple to this (and propagating the changes to the rest of the notebook):
Also because of the way vmap passes the frequency array by individual value into the polarization functions, the following hack was also needed for the polarization gradient functions, e.g.
Just wanted to raise awareness in case this change to the passed frequency array was unexpectedly caused by upstream changes to the code. There's probably a more elegant solution to fix this error!
The text was updated successfully, but these errors were encountered:
Thanks for catching this! I pushed a small fix with your changes so that the notebook now runs. At the moment I'm not sure there is a more elegant way round this without changing the phenomD code. I'll look into if there is something we can do in the next release though.
Hi!
I tried to run one of the example notebooks (
Generating_waveforms.ipynb
) and ran into a couple of issues.Firstly, it seems that all calls of
IMRPhenomD.gen_IMRPhenomD
need updating to take inf_ref
. Once this issue is resolved, the actual functionIMRPhenomD.gen_IMRPhenomD
doesn't like the way the frequencies are passed in when definingh0_simple
. Usingjax 0.4.10
the shapes offs[0]
andfs[:1]
are()
and(1,0)
resp., and the former raises an IndexError:Changing to
fs[:1]
resolves this but now the function outputs an array (of length 1) that breaksgrad
. In the end I got things to work by changingh0_simple
to this (and propagating the changes to the rest of the notebook):Also because of the way
vmap
passes the frequency array by individual value into the polarization functions, the following hack was also needed for the polarization gradient functions, e.g.Just wanted to raise awareness in case this change to the passed frequency array was unexpectedly caused by upstream changes to the code. There's probably a more elegant solution to fix this error!
The text was updated successfully, but these errors were encountered: