question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Aperiodic error when computing xo.orbits.KerplerianOrbit

See original GitHub issue

Describe the bug When creating an instance of the xo.orbits.KeplerianOrbit object, I sometimes incur an error that reports ValueError: Cannot compute test value ... missing default value. [see full traceback below].

I always provide the exact same values every time; but every ~5th try, Theano triggers this error.

The behaviour of xo.orbits.KeplerianOrbit is such that we can either enter the inclination, impact parameter, or transit duration; but only one a time. [this is built in; no problem]

The problem arises that I’ve tried this exact same code on 3 machines, and ~10 times per machine. Depending on the machine and time of day (i.e. randomness), the KeplerianOrbit object does not accept the form of one or more values in the set [inclination, impact parameter, duration] that I provide. Note that I always give it the exact same values every time [see example code below].

If I comment out the inclination and uncomment either the duration or impact parameter line [or vice versa], then the code will work for ~5 more attempts; at some point, it will fail again with the related error. At which point, I would permute through the list and KeplerianOrbit nominally works again.

Note that the exact form of the error changes related to the kwarg used [inc, b, dur]; but 99% of the error is identical to the traceback below.

To Reproduce

import exoplanet as xo
import numpy as np

def build_synthetic_model(min_phase=-0.1, max_phase=0.1, size=1000, u=[0.0]):
    ''' Create synthetic transit light curve by grabbing data from exo.mast
         and populating xo.orbits.KeplerianOrbit with that

        min_phase (float): minimum value for the transit light curve phase
        max_phase (float): maximum value for the transit light curve phase
        size (int): number of data points
        u (list): limb darkening coefficients; default: no limb darkening
    '''
    # Planetary orbital parameters
    t0 = 54278.93671400007
    period = 2.21857567
    Rp_Rs = 0.1546877455085016
    deg2rad = np.pi / 180

    orbit = xo.orbits.KeplerianOrbit(
        t0=t0,
        period=period,
        a=8.83602,
        # b=0.6631,
        # incl=1.4959217018843398,
        duration=0.0759722,
        ecc=0.0,
        omega=1.5707963267948966  # == pi/2
    )
    star = xo.LimbDarkLightCurve(u)
    phase = np.linspace(min_phase, max_phase, size)
    times = phase * period + t0
    lightcurve = star.get_light_curve(
        r=Rp_Rs,
        orbit=orbit,
        t=times)

    lightcurve = lightcurve.eval().flatten()

    return times, lightcurve, orbit

if __name__ == '__main__':
    times, lightcurve, orbit = build_synthetic_model()

Expected behavior I expect to generate a transit model, via KeplerianOrbit, every time I run the code above.

Your setup (please complete the following information):

  • Version of exoplanet: 0.2.6.dev1+gcc717ef
  • Operating system: Ubuntu 18.04 (Linux 5.3.0-40-generic #32~18.04.1-Ubuntu x86_64)
  • Python version & installation method (pip, conda, etc.): Python 3.7.6 Conda version: 4.8.2 Method: exoplanet install through github repo; all dependencies through conda

Additional context In writing this issue, I realized that I am using the word model inside the function; but that I call this function inside a PyMC3 wrapper which includes with pm.Model() as model. This could easily be the issue. I will report back after changing the variable name that I store the xo.LimbDarkLightCurve(u).get_light_curve instance.

Note that the tracback for this error points to the KeplerianOrbit; but I will change the instance name and respond if I do not receive the error again.

Full Traceback

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
    624                 try:
--> 625                     storage_map[ins] = [self._get_test_value(ins)]
    626                     compute_map[ins] = [True]

7 frames
/usr/local/lib/python3.6/dist-packages/theano/gof/op.py in _get_test_value(cls, v)
    580         detailed_err_msg = utils.get_variable_trace_string(v)
--> 581         raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
    582 

AttributeError: Elemwise{mul,no_inplace}.0 has no test value  
Backtrace when that variable is created:

  File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2718, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2822, in run_ast_nodes
    if self.run_code(code, result):
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2882, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-9-866db5884fd4>", line 2, in <module>
    times, synthetic_eclipse, orbit = build_synthetic_model(size=n_pts)
  File "<ipython-input-5-cb8f0767a3aa>", line 25, in build_synthetic_model
    omega=1.5707963267948966  # == pi/2
  File "/usr/local/lib/python3.6/dist-packages/exoplanet/orbits/keplerian.py", line 207, in __init__
    self.cos_incl = self.dcosidb * self.b


During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-16-93c8d291cba6> in <module>()
      2                                                 log_Q=np.log(1 / np.sqrt(2)),
      3                                                 tune=tune, draws=draws,
----> 4                                                 target_accept=0.9)

<ipython-input-4-92c977bcc44c> in run_pymc3_with_gp(times, data, dataerr, orbit, log_Q, tune, draws, target_accept, u)
     30             return pm.math.sum(light_curves, axis=-1) + mean
     31 
---> 32         light_curves = lc_model(times)
     33 
     34         # The likelihood function assuming known Gaussian uncertainty

<ipython-input-4-92c977bcc44c> in lc_model(times)
     24             # Compute the model light curve using starry
     25             light_curves = xo.LimbDarkLightCurve(u).get_light_curve(
---> 26                 orbit=orbit, r=r, t=times
     27             )
     28 

/usr/local/lib/python3.6/dist-packages/exoplanet/light_curves.py in get_light_curve(self, orbit, r, t, texp, oversample, order, use_in_transit)
    103                 tt.zeros_like(r), t.ndim
    104             ) + tt.shape_padright(tt.zeros_like(t), r.ndim)
--> 105             inds = orbit.in_transit(t, r=r, texp=texp)
    106             t = t[inds]
    107 

/usr/local/lib/python3.6/dist-packages/exoplanet/orbits/keplerian.py in in_transit(self, t, r, texp)
    605                 self.cos_omega,
    606                 self.sin_omega,
--> 607                 self.cos_incl + z,
    608                 self.sin_incl + z,
    609                 R + r,

/usr/local/lib/python3.6/dist-packages/theano/tensor/var.py in __add__(self, other)
    126     def __add__(self, other):
    127         try:
--> 128             return theano.tensor.basic.add(self, other)
    129         # We should catch the minimum number of exception here.
    130         # Otherwise this will convert error when Theano flags

/usr/local/lib/python3.6/dist-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
    637                         raise ValueError(
    638                             'Cannot compute test value: input %i (%s) of Op %s missing default value. %s' %
--> 639                             (i, ins, node, detailed_err_msg))
    640                     elif config.compute_test_value == 'ignore':
    641                         # silently skip test

ValueError: Cannot compute test value: input 0 (Elemwise{mul,no_inplace}.0) of Op Elemwise{add,no_inplace}(Elemwise{mul,no_inplace}.0, Elemwise{second,no_inplace}.0) missing default value.  
Backtrace when that variable is created:

  File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2718, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2822, in run_ast_nodes
    if self.run_code(code, result):
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2882, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-9-866db5884fd4>", line 2, in <module>
    times, synthetic_eclipse, orbit = build_synthetic_model(size=n_pts)
  File "<ipython-input-5-cb8f0767a3aa>", line 25, in build_synthetic_model
    omega=1.5707963267948966  # == pi/2
  File "/usr/local/lib/python3.6/dist-packages/exoplanet/orbits/keplerian.py", line 207, in __init__
    self.cos_incl = self.dcosidb * self.b

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
dfmcommented, Apr 9, 2020

I figured this out. It happens because PyMC3 changes Theano’s behavior. You can get your code to run by adding the following at the top of the notebook:

import theano
theano.config.compute_test_value = "raise"

In that case, all of the test values are propagated properly.

(note: that there are other issues, like negative uncertainties, that make the results nonsense, but this was the issue causing the crash 😄)

1reaction
dfmcommented, Mar 13, 2020

Can you try to make a minimal example that reproduces this error message without everything else that’s going on. This error always happens when you have some dependence on a pymc3 object in your call so something is happening with the objects outside the scope being overwritten. There’s too much going on in your colab to really track it down so please try to make a smaller example and we’ll figure it out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data & models - exoplanet
The KeplerianOrbit object defines a set of independent (but possibly massive) bodies orbiting a central body on Keplerian trajectories. These orbits are ...
Read more >
Description of Kepler Data Validation One-Page Summary ...
Period: The orbital period of the planetary candidate in days. The measurement error is shown in brackets. Epoch: The epoch (i.e., the central...
Read more >
The Masses and Orbital Dynamics of Exoplanets
the Kepler Mission has discovered over 4000 exoplanets, enabling detailed studies ... positions of small planets, it is necessary to compute bulk densities ......
Read more >
exoplanet/data-and-models.md at main - GitHub
Given a KeplerianOrbit , users of exoplanet can evaluate things like the positions ... as plt import exoplanet as xo # Define the...
Read more >
The Lindstedt-Poincaré Technique as an Algorithm ... - JSTOR
upon this technique for computing periodic orbits of dynamical systems. The algorithm, ... computing a periodic orbit is to pick a point close...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found