Skip to content

Commit b23ada6

Browse files
committed
Updating some docstrings
1 parent 10bdc61 commit b23ada6

File tree

13 files changed

+69
-24
lines changed

13 files changed

+69
-24
lines changed

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
]
1515

1616
autoapi_dirs = ["../src"]
17+
autoapi_ignore = ["*/experimental/*", "*_version*", "*/types*"]
1718
autoapi_options = [
1819
"members",
1920
"undoc-members",
@@ -23,6 +24,7 @@
2324
"special-members",
2425
# "imported-members",
2526
]
27+
suppress_warnings = ["autoapi.python_import_resolution"]
2628

2729
myst_enable_extensions = ["dollarmath", "colon_fence"]
2830
source_suffix = {

docs/tutorials.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ directly.
1818
```{toctree}
1919
:maxdepth: 1
2020
21+
tutorials/getting-started.ipynb
2122
tutorials/autodiff.ipynb
22-
tutorials/orbits.ipynb
2323
tutorials/transit.ipynb
2424
tutorials/rv.ipynb
2525
tutorials/starry.ipynb

docs/tutorials/autodiff.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
],
226226
"metadata": {
227227
"kernelspec": {
228-
"display_name": "exo4jax",
228+
"display_name": "Python 3 (ipykernel)",
229229
"language": "python",
230230
"name": "python3"
231231
},
@@ -243,5 +243,5 @@
243243
}
244244
},
245245
"nbformat": 4,
246-
"nbformat_minor": 2
246+
"nbformat_minor": 4
247247
}

docs/tutorials/core-from-scratch.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"id": "0",
66
"metadata": {},
77
"source": [
8+
"(core-from-scratch)=\n",
9+
"\n",
810
"# Jaxoplanet core from scratch\n",
911
"\n",
1012
"Inspired by the [autodidax tutorial](https://jax.readthedocs.io/en/latest/autodidax.html) from the JAX documentation, in this tutorial we work through implementing some of the core `jaxoplanet` functionality from scratch, to demonstrate and discuss the choices made within the depths of the codebase.\n",

docs/tutorials/orbits.ipynb renamed to docs/tutorials/getting-started.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"id": "0",
66
"metadata": {},
77
"source": [
8+
"(getting-started)=\n",
9+
"\n",
810
"# Getting Started"
911
]
1012
},

docs/tutorials/rv.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7+
"(rv)=\n",
8+
"\n",
79
"# Radial Velocities Fitting"
810
]
911
},
@@ -253,7 +255,7 @@
253255
],
254256
"metadata": {
255257
"kernelspec": {
256-
"display_name": "jaxoplanet_docs",
258+
"display_name": "Python 3 (ipykernel)",
257259
"language": "python",
258260
"name": "python3"
259261
},
@@ -267,9 +269,9 @@
267269
"name": "python",
268270
"nbconvert_exporter": "python",
269271
"pygments_lexer": "ipython3",
270-
"version": "3.10.13"
272+
"version": "3.10.10"
271273
}
272274
},
273275
"nbformat": 4,
274-
"nbformat_minor": 2
276+
"nbformat_minor": 4
275277
}

docs/tutorials/starry.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7+
"(starry)=\n",
8+
"\n",
9+
"# Starry light curve\n",
10+
"\n",
711
"```{warning}\n",
812
"Experimental features!\n",
913
"```\n",
@@ -12,8 +16,6 @@
1216
"Notebook under construction!\n",
1317
"```\n",
1418
"\n",
15-
"# Starry light curve\n",
16-
"\n",
1719
"*jaxoplanet* aims to match the features of starry, a framework to compute the light curves of systems made of of non-uniform spherical bodies. In this small tutorial we demonstrate some of these features.\n",
1820
"\n",
1921
"\n",

src/jaxoplanet/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__all__ = ["core", "light_curves", "orbits", "units"]
2+
13
from jaxoplanet import (
24
core as core,
35
light_curves as light_curves,

src/jaxoplanet/core/kepler.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
"""This module provides the core functionality to solve Kepler's equation in JAX. For
2+
more details, see the :ref:`core-from-scratch` tutorial.
3+
"""
4+
5+
__all__ = ["kepler"]
6+
17
import jax
28
import jax.numpy as jnp
39
from jax.interpreters import ad
410

511
from jaxoplanet.types import Array
612

713

14+
@jax.jit
815
def kepler(M: Array, ecc: Array) -> tuple[Array, Array]:
916
"""Solve Kepler's equation to compute the true anomaly
1017

src/jaxoplanet/core/limb_dark.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""This module provides the functions needed to compute a limb darkened light curve as
2+
described by `Agol et al. (2020) <https://arxiv.org/abs/1908.03222>`_.
3+
"""
4+
5+
__all__ = ["light_curve"]
6+
17
from functools import partial
28
from typing import Callable
39

@@ -12,6 +18,24 @@
1218

1319
@partial(jax.jit, static_argnames=("order",))
1420
def light_curve(u: Array, b: Array, r: Array, *, order: int = 10):
21+
"""Compute the light curve for arbitrary polynomial limb darkening
22+
23+
See `Agol et al. (2020) <https://arxiv.org/abs/1908.03222>`_ for more technical
24+
details. Unlike in that paper, here we don't evaluate all the solution vector
25+
integrals in closed form. Instead, for all but the lowest order terms, we numerically
26+
integrate the relevant 1D line integral using Gauss-Legendre quadrature at fixed
27+
order ``order``.
28+
29+
30+
Args:
31+
u (Array): The coefficients of the polynomial limb darkening model
32+
b (Array): The center-to-center distance between the occultor and the occulted
33+
body
34+
r (Array): The radius ratio between the occultor and the occulted body
35+
order (int): The quadrature order to use when numerically computing the the 1D
36+
line integral
37+
"""
38+
1539
u = jnp.asarray(u)
1640
assert u.ndim == 1
1741
if u.shape[0] == 0:

src/jaxoplanet/light_curves/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""This module contains models for computing and transforming light curve models"""
2+
13
from jaxoplanet.light_curves import exposure_time as exposure_time
24
from jaxoplanet.light_curves.limb_dark import (
35
limb_dark_light_curve as limb_dark_light_curve,

src/jaxoplanet/light_curves/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__all__ = ["vectorize"]
2+
13
from functools import wraps
24
from typing import Any, Union
35

@@ -9,6 +11,19 @@
911

1012

1113
def vectorize(func: LightCurveFunc) -> LightCurveFunc:
14+
"""Vectorize a scalar light curve function to work with array inputs
15+
16+
Like ``jax.numpy.vectorize``, this automatically wraps a function which operates on a
17+
scalar to handle array inputs. Unlike that function, this handles ``Quantity`` inputs
18+
and outputs, but it only broadcasts the first input (``time``).
19+
20+
Args:
21+
func: A function which takes a scalar ``Quantity`` time as the first input
22+
23+
Returns:
24+
An updated function which can operate on ``Quantity`` times of any shape
25+
"""
26+
1227
@wraps(func)
1328
def wrapped(time: Quantity, *args: Any, **kwargs: Any) -> Union[Array, Quantity]:
1429
if is_quantity(time):

src/jaxoplanet/utils.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
1-
from functools import wraps
2-
from typing import Optional, Union
1+
__all__ = ["get_dtype_eps", "zero_safe_sqrt"]
32

43
import jax
54
import jax.numpy as jnp
6-
from jax.typing import ArrayLike
7-
8-
9-
@wraps(jnp.where)
10-
def where(
11-
condition: ArrayLike,
12-
x: Optional[ArrayLike],
13-
y: Optional[ArrayLike],
14-
*,
15-
size: Optional[int] = None,
16-
fill_value: Optional[Union[jax.Array, tuple[ArrayLike]]] = None,
17-
) -> jax.Array:
18-
"""A properly typed version of jnp.where"""
19-
return jnp.where(condition, x, y, size=size, fill_value=fill_value) # type: ignore
205

216

227
def get_dtype_eps(x):

0 commit comments

Comments
 (0)