Skip to content

Commit

Permalink
docs: tweaks to make docs build on Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed Apr 1, 2021
1 parent 3e980a7 commit c473fde
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ formats:

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
version: 3.8
install:
- requirements: docs/requirements.txt
10 changes: 10 additions & 0 deletions docs/jax.profiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ profiling features.

device_memory_profile
save_device_memory_profile

Deprecated functions
--------------------

.. autosummary::
:toctree: _autosummary

trace_function
TraceContext
StepTraceContext
6 changes: 4 additions & 2 deletions jax/_src/numpy/lax_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1928,10 +1928,12 @@ def _isposneginf(infinity, x, out):
return full_like(x, False, dtype=bool_)

isposinf = _wraps(np.isposinf, skip_params=['out'])(
lambda x, out=None: _isposneginf(inf, x, out))
lambda x, out=None: _isposneginf(inf, x, out)
)

isneginf = _wraps(np.isneginf, skip_params=['out'])(
lambda x, out=None: _isposneginf(-inf, x, out))
lambda x, out=None: _isposneginf(-inf, x, out)
)

@_wraps(np.isnan)
def isnan(x):
Expand Down
5 changes: 5 additions & 0 deletions jax/_src/numpy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
_section_break = re.compile(r"\n(?=[^\n]{3,15}\n-{3,15})", re.MULTILINE)
_numpy_signature_re = re.compile(r'^([\w., ]+=)?\s*[\w\.]+\([\w\W]*?\)$', re.MULTILINE)
_versionadded = re.compile(r'^\s+\.\.\s+versionadded::', re.MULTILINE)
_docreference = re.compile(r':doc:`(.*?)\s*<.*?>`')

class ParsedDoc(NamedTuple):
"""
Expand Down Expand Up @@ -48,6 +49,10 @@ def _parse_numpydoc(docstr: Optional[str]) -> ParsedDoc:
if docstr is None or not docstr.strip():
return ParsedDoc(docstr)

# Remove any :doc: directives in the docstring to avoid sphinx errors
docstr = _docreference.sub(
lambda match: f"{match.groups()[0]}", docstr)

signature, body = "", docstr
match = _numpy_signature_re.match(body)
if match:
Expand Down

0 comments on commit c473fde

Please sign in to comment.