Skip to content

Commit

Permalink
docs format and assertion error
Browse files Browse the repository at this point in the history
  • Loading branch information
dfm committed Apr 25, 2021
1 parent 5dcc78a commit 6192e85
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
10 changes: 5 additions & 5 deletions docs/user/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ the instructions on the relevant documentation pages:
Both of these installation methods will install the required dependencies:

- [numpy](https://numpy.org)
- [astropy](https://www.astropy.org)
- [pymc3](https://docs.pymc.io)
- [exoplanet-core](https://github.com/exoplanet-dev/exoplanet-core)
- [aesara-theano-fallback](https://github.com/exoplanet-dev/aesara-theano-fallback)
- `numpy <https://numpy.org>`_
- `astropy <https://www.astropy.org>`_
- `pymc3 <https://docs.pymc.io>`_
- `exoplanet-core <https://github.com/exoplanet-dev/exoplanet-core>`_
- `aesara-theano-fallback <https://github.com/exoplanet-dev/aesara-theano-fallback>`_


Using conda
Expand Down
20 changes: 18 additions & 2 deletions src/exoplanet/light_curves/limb_dark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import aesara_theano_fallback.tensor as tt
import numpy as np
from aesara_theano_fallback import aesara as theano
from exoplanet_core.pymc import ops

from ..citations import add_citations_to_model
Expand Down Expand Up @@ -47,8 +48,23 @@ def __init__(self, u1, u2=None, model=None):
"using a vector of limb darkening coefficients is deprecated; "
"use u1 and u2 directly"
)
self.u1 = as_tensor_variable(u1[0])
self.u2 = as_tensor_variable(u1[1])

# If a vector is provided, we need to assert that it is 2D
msg = (
"only quadratic limb darkening is supported; "
"use `starry` for more flexibility"
)
try:
assert_op = theano.assert_op.Assert(msg)
except AttributeError:
assert_op = tt.opt.Assert(msg)
u1 = as_tensor_variable(u1)
u1 = assert_op(
u1, tt.and_(tt.eq(u1.ndim, 1), tt.eq(u1.shape[0], 2))
)

self.u1 = u1[0]
self.u2 = u1[1]
else:
self.u1 = as_tensor_variable(u1)
self.u2 = as_tensor_variable(u2)
Expand Down
5 changes: 5 additions & 0 deletions tests/light_curves_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def test_vector_params():
)(u_val)
np.testing.assert_allclose(lc1, lc2)

with pytest.raises(AssertionError):
theano.function(
[], LimbDarkLightCurve([0.3])._compute_light_curve(b, r)
)()


def test_in_transit():
t = np.linspace(-20, 20, 1000)
Expand Down

0 comments on commit 6192e85

Please sign in to comment.