From b8a3ff1b20277379e89e5fa96f1e5d7fe191ce34 Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Wed, 10 Nov 2021 16:58:55 -0500 Subject: [PATCH 01/10] Transform sorting functions from md to rst file --- spec/API_specification/sorting_functions.md | 81 -------------------- spec/API_specification/sorting_functions.rst | 78 +++++++++++++++++++ 2 files changed, 78 insertions(+), 81 deletions(-) delete mode 100644 spec/API_specification/sorting_functions.md create mode 100644 spec/API_specification/sorting_functions.rst diff --git a/spec/API_specification/sorting_functions.md b/spec/API_specification/sorting_functions.md deleted file mode 100644 index fd205fbe9..000000000 --- a/spec/API_specification/sorting_functions.md +++ /dev/null @@ -1,81 +0,0 @@ -# Sorting Functions - -> Array API specification for sorting functions. - -A conforming implementation of the array API standard must provide and support the following functions adhering to the following conventions. - -- Positional parameters must be [positional-only](https://www.python.org/dev/peps/pep-0570/) parameters. Positional-only parameters have no externally-usable name. When a function accepting positional-only parameters is called, positional arguments are mapped to these parameters based solely on their order. -- Optional parameters must be [keyword-only](https://www.python.org/dev/peps/pep-3102/) arguments. -- Unless stated otherwise, functions must support the data types defined in {ref}`data-types`. - -```{note} -For floating-point input arrays, the sort order of NaNs and signed zeros is unspecified and thus implementation-dependent. - -Implementations may choose to sort signed zeros (`-0 < +0`) or may choose to rely solely on value equality (`==`). - -Implementations may choose to sort NaNs (e.g., to the end or to the beginning of a returned array) or leave them in-place. Should an implementation sort NaNs, the sorting convention should be clearly documented in the conforming implementation's documentation. - -While defining a sort order for IEEE 754 floating-point numbers is recommended in order to facilitate reproducible and consistent sort results, doing so is not currently required by this specification. -``` - -## Objects in API - - - -(function-argsort)= -### argsort(x, /, *, axis=-1, descending=False, stable=True) - -Returns the indices that sort an array `x` along a specified axis. - -#### Parameters - -- **x**: _<array>_ - - - input array. - -- **axis**: _int_ - - - axis along which to sort. If set to `-1`, the function must sort along the last axis. Default: `-1`. - -- **descending**: _bool_ - - - sort order. If `True`, the returned indices sort `x` in descending order (by value). If `False`, the returned indices sort `x` in ascending order (by value). Default: `False`. - -- **stable**: _bool_ - - - sort stability. If `True`, the returned indices must maintain the relative order of `x` values which compare as equal. If `False`, the returned indices may or may not maintain the relative order of `x` values which compare as equal (i.e., the relative order of `x` values which compare as equal is implementation-dependent). Default: `True`. - -#### Returns - -- **out**: _<array>_ - - - an array of indices. The returned array must have the same shape as `x`. The returned array must have the default array index data type. - -(function-sort)= -### sort(x, /, *, axis=-1, descending=False, stable=True) - -Returns a sorted copy of an input array `x`. - -#### Parameters - -- **x**: _<array>_ - - - input array. - -- **axis**: _int_ - - - axis along which to sort. If set to `-1`, the function must sort along the last axis. Default: `-1`. - -- **descending**: _bool_ - - - sort order. If `True`, the array must be sorted in descending order (by value). If `False`, the array must be sorted in ascending order (by value). Default: `False`. - -- **stable**: _bool_ - - - sort stability. If `True`, the returned array must maintain the relative order of `x` values which compare as equal. If `False`, the returned array may or may not maintain the relative order of `x` values which compare as equal (i.e., the relative order of `x` values which compare as equal is implementation-dependent). Default: `True`. - -#### Returns - -- **out**: _<array>_ - - - a sorted array. The returned array must have the same data type and shape as `x`. diff --git a/spec/API_specification/sorting_functions.rst b/spec/API_specification/sorting_functions.rst new file mode 100644 index 000000000..f59fe16ed --- /dev/null +++ b/spec/API_specification/sorting_functions.rst @@ -0,0 +1,78 @@ +Sorting Functions +================= + + Array API specification for sorting functions. + +A conforming implementation of the array API standard must provide and support the following functions adhering to the following conventions. + +* Positional parameters must be `positional-only `_ parameters. Positional-only parameters have no externally-usable name. When a function accepting positional-only parameters is called, positional arguments are mapped to these parameters based solely on their order. +* Optional parameters must be `keyword-only `_ arguments. +* Unless stated otherwise, functions must support the data types defined in :ref:`data-types`. + +.. note:: + + For floating-point input arrays, the sort order of NaNs and signed zeros is unspecified and thus implementation-dependent. + + Implementations may choose to sort signed zeros (``-0 < +0``) or may choose to rely solely on value equality (``==``). + + Implementations may choose to sort NaNs (e.g., to the end or to the beginning of a returned array) or leave them in-place. Should an implementation sort NaNs, the sorting convention should be clearly documented in the conforming implementation's documentation. + + While defining a sort order for IEEE 754 floating-point numbers is recommended in order to facilitate reproducible and consistent sort results, doing so is not currently required by this specification. + +Objects in API +-------------- + +.. + NOTE: please keep the functions in alphabetical order + +.. _function-argsort: + +argsort(x, /, *, axis=-1, descending=False, stable=True) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Returns the indices that sort an array ``x`` along a specified axis. + +**Parameters** + +* **x**: ** + * input array. + +* **axis**: *int* + * axis along which to sort. If set to ``-1``, the function must sort along the last axis. Default: ``-1``. + +* **descending**: *bool* + * sort order. If ``True``, the returned indices sort ``x`` in descending order (by value). If ``False``, the returned indices sort ``x`` in ascending order (by value). Default: ``False``. + +* **stable**: *bool* + * sort stability. If ``True``, the returned indices must maintain the relative order of ``x`` values which compare as equal. If ``False``, the returned indices may or may not maintain the relative order of ``x`` values which compare as equal (i.e., the relative order of ``x`` values which compare as equal is implementation-dependent). Default: ``True``. + +**Returns** + +* **out**: ** + * an array of indices. The returned array must have the same shape as ``x``. The returned array must have the default array index data type. + +.. _function-sort: + +sort(x, /, *, axis=-1, descending=False, stable=True) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Returns a sorted copy of an input array ``x``. + +**Parameters** + +* **x**: ** + * input array. + +* **axis**: *int* + * axis along which to sort. If set to ``-1``, the function must sort along the last axis. Default: ``-1``. + +* **descending**: *bool* + * sort order. If ``True``, the array must be sorted in descending order (by value). If ``False``, the array must be sorted in ascending order (by value). Default: ``False``. + +* **stable**: *bool* + * sort stability. If ``True``, the returned array must maintain the relative order of ``x`` values which compare as equal. If ``False``, the returned array may or may not maintain the relative order of ``x`` values which compare as equal (i.e., the relative order of ``x`` values which compare as equal is implementation-dependent). Default: ``True``. + +**Returns** + +* **out**: ** + * a sorted array. The returned array must have the same data type and shape as ``x``. From 61836cb563f827b1f4d6a628f4fdcbdc7cc4a682 Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Wed, 10 Nov 2021 17:08:51 -0500 Subject: [PATCH 02/10] Fix the warning message --- spec/API_specification/sorting_functions.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/API_specification/sorting_functions.rst b/spec/API_specification/sorting_functions.rst index f59fe16ed..991f1c71f 100644 --- a/spec/API_specification/sorting_functions.rst +++ b/spec/API_specification/sorting_functions.rst @@ -27,8 +27,8 @@ Objects in API .. _function-argsort: -argsort(x, /, *, axis=-1, descending=False, stable=True) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +argsort(x, /, \*, axis=-1, descending=False, stable=True) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Returns the indices that sort an array ``x`` along a specified axis. @@ -53,8 +53,8 @@ Returns the indices that sort an array ``x`` along a specified axis. .. _function-sort: -sort(x, /, *, axis=-1, descending=False, stable=True) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +sort(x, /, \*, axis=-1, descending=False, stable=True) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Returns a sorted copy of an input array ``x``. From 96e2c375ae9ad26d10ebca27e81d2c563c6717b7 Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Mon, 15 Nov 2021 14:08:12 -0500 Subject: [PATCH 03/10] Add autosummary with signatures for the sorting functions --- .gitignore | 2 + spec/API_specification/signatures/__init__.py | 0 .../signatures/_sorting_functions.py | 43 ++++++++++++++ spec/API_specification/sorting_functions.rst | 57 ++----------------- spec/conf.py | 12 ++-- 5 files changed, 59 insertions(+), 55 deletions(-) create mode 100644 spec/API_specification/signatures/__init__.py create mode 100644 spec/API_specification/signatures/_sorting_functions.py diff --git a/.gitignore b/.gitignore index a740a2929..dfedda47f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ spec/_build/ build/ .vscode/ node_modules/ +__pycache__/ +*.pyc \ No newline at end of file diff --git a/spec/API_specification/signatures/__init__.py b/spec/API_specification/signatures/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/spec/API_specification/signatures/_sorting_functions.py b/spec/API_specification/signatures/_sorting_functions.py new file mode 100644 index 000000000..ac05a5fff --- /dev/null +++ b/spec/API_specification/signatures/_sorting_functions.py @@ -0,0 +1,43 @@ +def argsort(x, /, *, axis:int = -1, descending:bool = False, stable:bool = True): + """ + Returns the indices that sort an array ``x`` along a specified axis. + + Parameters + ---------- + x : array + input array. + axis: int + axis along which to sort. If set to ``-1``, the function must sort along the last axis. Default: ``-1``. + descending: bool + sort order. If ``True``, the returned indices sort ``x`` in descending order (by value). If ``False``, the returned indices sort ``x`` in ascending order (by value). Default: ``False``. + stable: bool + sort stability. If ``True``, the returned indices must maintain the relative order of ``x`` values which compare as equal. If ``False``, the returned indices may or may not maintain the relative order of ``x`` values which compare as equal (i.e., the relative order of ``x`` values which compare as equal is implementation-dependent). Default: ``True``. + + Returns + ------- + out: array + an array of indices. The returned array must have the same shape as ``x``. The returned array must have the default array index data type. + """ + pass + +def sort(x, /, *, axis:int = -1, descending:bool = False, stable: bool = True): + """ + Returns a sorted copy of an input array ``x``. + + Parameters + ---------- + x: array + input array. + axis: int + axis along which to sort. If set to ``-1``, the function must sort along the last axis. Default: ``-1``. + descending: bool + sort order. If ``True``, the array must be sorted in descending order (by value). If ``False``, the array must be sorted in ascending order (by value). Default: ``False``. + stable: bool + sort stability. If ``True``, the returned array must maintain the relative order of ``x`` values which compare as equal. If ``False``, the returned array may or may not maintain the relative order of ``x`` values which compare as equal (i.e., the relative order of ``x`` values which compare as equal is implementation-dependent). Default: ``True``. + + Returns + ------- + out: array + a sorted array. The returned array must have the same data type and shape as ``x``. + """ + pass diff --git a/spec/API_specification/sorting_functions.rst b/spec/API_specification/sorting_functions.rst index 991f1c71f..c4c673b29 100644 --- a/spec/API_specification/sorting_functions.rst +++ b/spec/API_specification/sorting_functions.rst @@ -19,60 +19,15 @@ A conforming implementation of the array API standard must provide and support t While defining a sort order for IEEE 754 floating-point numbers is recommended in order to facilitate reproducible and consistent sort results, doing so is not currently required by this specification. +.. currentmodule:: signatures._sorting_functions + Objects in API -------------- - .. NOTE: please keep the functions in alphabetical order -.. _function-argsort: - -argsort(x, /, \*, axis=-1, descending=False, stable=True) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Returns the indices that sort an array ``x`` along a specified axis. - -**Parameters** - -* **x**: ** - * input array. - -* **axis**: *int* - * axis along which to sort. If set to ``-1``, the function must sort along the last axis. Default: ``-1``. - -* **descending**: *bool* - * sort order. If ``True``, the returned indices sort ``x`` in descending order (by value). If ``False``, the returned indices sort ``x`` in ascending order (by value). Default: ``False``. - -* **stable**: *bool* - * sort stability. If ``True``, the returned indices must maintain the relative order of ``x`` values which compare as equal. If ``False``, the returned indices may or may not maintain the relative order of ``x`` values which compare as equal (i.e., the relative order of ``x`` values which compare as equal is implementation-dependent). Default: ``True``. - -**Returns** - -* **out**: ** - * an array of indices. The returned array must have the same shape as ``x``. The returned array must have the default array index data type. - -.. _function-sort: - -sort(x, /, \*, axis=-1, descending=False, stable=True) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Returns a sorted copy of an input array ``x``. - -**Parameters** - -* **x**: ** - * input array. - -* **axis**: *int* - * axis along which to sort. If set to ``-1``, the function must sort along the last axis. Default: ``-1``. - -* **descending**: *bool* - * sort order. If ``True``, the array must be sorted in descending order (by value). If ``False``, the array must be sorted in ascending order (by value). Default: ``False``. - -* **stable**: *bool* - * sort stability. If ``True``, the returned array must maintain the relative order of ``x`` values which compare as equal. If ``False``, the returned array may or may not maintain the relative order of ``x`` values which compare as equal (i.e., the relative order of ``x`` values which compare as equal is implementation-dependent). Default: ``True``. - -**Returns** +.. autosummary:: + :toctree: generated -* **out**: ** - * a sorted array. The returned array must have the same data type and shape as ``x``. + argsort + sort diff --git a/spec/conf.py b/spec/conf.py index ffb1e94a2..04daf5ab3 100644 --- a/spec/conf.py +++ b/spec/conf.py @@ -10,11 +10,10 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - +import os +import sys import sphinx_material +sys.path.insert(0, os.path.abspath('./API_specification')) # -- Project information ----------------------------------------------------- @@ -38,8 +37,13 @@ 'sphinx.ext.todo', 'sphinx_markdown_tables', 'sphinx_copybutton', + 'sphinx.ext.autosummary', + 'sphinx.ext.autodoc', + 'sphinx.ext.napoleon', ] +autosummary_generate = True + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] From 58f3984fa3de972e71b9c4de077da76c0fefbd3d Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Mon, 15 Nov 2021 14:22:28 -0500 Subject: [PATCH 04/10] Bump CI python to 3.8 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cb1031906..829dcbb64 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ _defaults: &defaults docker: # CircleCI maintains a library of pre-built images # documented at https://circleci.com/docs/2.0/circleci-images/ - - image: circleci/python:3.7.0 + - image: circleci/python:3.8.0 working_directory: ~/repo jobs: From 31d01f0b8a2ef8e9887b026d794d824fa2f3f434 Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Mon, 22 Nov 2021 12:24:18 -0500 Subject: [PATCH 05/10] Complete signatures and add types files --- spec/API_specification/signatures/_types.py | 40 +++++++++++++++++++ ...ting_functions.py => sorting_functions.py} | 10 +++-- spec/API_specification/sorting_functions.rst | 2 +- 3 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 spec/API_specification/signatures/_types.py rename spec/API_specification/signatures/{_sorting_functions.py => sorting_functions.py} (88%) diff --git a/spec/API_specification/signatures/_types.py b/spec/API_specification/signatures/_types.py new file mode 100644 index 000000000..6c0b5b85a --- /dev/null +++ b/spec/API_specification/signatures/_types.py @@ -0,0 +1,40 @@ +""" +This file defines the types for type annotations. + +The type variables should be replaced with the actual types for a given +library, e.g., for NumPy TypeVar('array') would be replaced with ndarray. +""" + +from dataclasses import dataclass +from typing import Any, List, Literal, Optional, Sequence, Tuple, TypeVar, Union + +array = TypeVar('array') +device = TypeVar('device') +dtype = TypeVar('dtype') +SupportsDLPack = TypeVar('SupportsDLPack') +SupportsBufferProtocol = TypeVar('SupportsBufferProtocol') +PyCapsule = TypeVar('PyCapsule') +# ellipsis cannot actually be imported from anywhere, so include a dummy here +# to keep pyflakes happy. https://github.com/python/typeshed/issues/3556 +ellipsis = TypeVar('ellipsis') + +@dataclass +class finfo_object: + bits: int + eps: float + max: float + min: float + smallest_normal: float + +@dataclass +class iinfo_object: + bits: int + max: int + min: int + +# This should really be recursive, but that isn't supported yet. +NestedSequence = Sequence[Sequence[Any]] + +__all__ = ['Any', 'List', 'Literal', 'NestedSequence', 'Optional', +'PyCapsule', 'SupportsBufferProtocol', 'SupportsDLPack', 'Tuple', 'Union', +'array', 'device', 'dtype', 'ellipsis', 'finfo_object', 'iinfo_object'] \ No newline at end of file diff --git a/spec/API_specification/signatures/_sorting_functions.py b/spec/API_specification/signatures/sorting_functions.py similarity index 88% rename from spec/API_specification/signatures/_sorting_functions.py rename to spec/API_specification/signatures/sorting_functions.py index ac05a5fff..8cbdc257c 100644 --- a/spec/API_specification/signatures/_sorting_functions.py +++ b/spec/API_specification/signatures/sorting_functions.py @@ -1,4 +1,6 @@ -def argsort(x, /, *, axis:int = -1, descending:bool = False, stable:bool = True): +from ._types import array + +def argsort(x: array, /, *, axis: int = -1, descending: bool = False, stable: bool = True) -> array: """ Returns the indices that sort an array ``x`` along a specified axis. @@ -18,9 +20,8 @@ def argsort(x, /, *, axis:int = -1, descending:bool = False, stable:bool = True) out: array an array of indices. The returned array must have the same shape as ``x``. The returned array must have the default array index data type. """ - pass -def sort(x, /, *, axis:int = -1, descending:bool = False, stable: bool = True): +def sort(x: array, /, *, axis: int = -1, descending: bool = False, stable: bool = True) -> array: """ Returns a sorted copy of an input array ``x``. @@ -40,4 +41,5 @@ def sort(x, /, *, axis:int = -1, descending:bool = False, stable: bool = True): out: array a sorted array. The returned array must have the same data type and shape as ``x``. """ - pass + +__all__ = ['argsort', 'sort'] \ No newline at end of file diff --git a/spec/API_specification/sorting_functions.rst b/spec/API_specification/sorting_functions.rst index c4c673b29..5f4d50b09 100644 --- a/spec/API_specification/sorting_functions.rst +++ b/spec/API_specification/sorting_functions.rst @@ -19,7 +19,7 @@ A conforming implementation of the array API standard must provide and support t While defining a sort order for IEEE 754 floating-point numbers is recommended in order to facilitate reproducible and consistent sort results, doing so is not currently required by this specification. -.. currentmodule:: signatures._sorting_functions +.. currentmodule:: signatures.sorting_functions Objects in API -------------- From 2bb72cc539e8b2814828cac92a7bd777ed2b699f Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Mon, 22 Nov 2021 12:57:56 -0500 Subject: [PATCH 06/10] Remove module names and add autodoc typehints --- spec/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/conf.py b/spec/conf.py index 04daf5ab3..69ec8397a 100644 --- a/spec/conf.py +++ b/spec/conf.py @@ -43,6 +43,8 @@ ] autosummary_generate = True +add_module_names = False +autodoc_typehints = 'both' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] From bdf41eb1e378c52903394509b0c44d2e3064488b Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Mon, 22 Nov 2021 13:05:32 -0500 Subject: [PATCH 07/10] Bump Sphinx version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5df0b2504..4741c6dc8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -sphinx==3.1.1 +sphinx==4.3.0 sphinx-material==0.0.30 myst-parser sphinx_markdown_tables From 3bd71a978135f549543b8993e3a8a6f9b1aa6bab Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Mon, 22 Nov 2021 13:47:16 -0500 Subject: [PATCH 08/10] Remove module import from signature and return annonation --- spec/conf.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spec/conf.py b/spec/conf.py index 69ec8397a..49efbc970 100644 --- a/spec/conf.py +++ b/spec/conf.py @@ -38,13 +38,13 @@ 'sphinx_markdown_tables', 'sphinx_copybutton', 'sphinx.ext.autosummary', - 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', + 'sphinx.ext.autodoc', ] autosummary_generate = True -add_module_names = False autodoc_typehints = 'both' +add_module_names = False # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -151,3 +151,14 @@ "dudir": ("http://docutils.sourceforge.net/docs/ref/rst/" "directives.html#%s", ""), "pypa": ("https://packaging.python.org/%s", ""), } + + +def process_signature(app, what, name, obj, options, signature, return_annotation): + if signature: + signature = signature.replace("signatures._types.", "") + if return_annotation: + return_annotation = return_annotation.replace("signatures._types.", "") + return signature, return_annotation + +def setup(app): + app.connect("autodoc-process-signature", process_signature) \ No newline at end of file From 7c80b2cee32a8f126a9399365aa33b6c68543130 Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Mon, 22 Nov 2021 15:54:21 -0500 Subject: [PATCH 09/10] Add jinja template for autosummary --- spec/API_specification/sorting_functions.rst | 1 + spec/_templates/method.rst | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 spec/_templates/method.rst diff --git a/spec/API_specification/sorting_functions.rst b/spec/API_specification/sorting_functions.rst index 5f4d50b09..da0ff99d1 100644 --- a/spec/API_specification/sorting_functions.rst +++ b/spec/API_specification/sorting_functions.rst @@ -28,6 +28,7 @@ Objects in API .. autosummary:: :toctree: generated + :template: method.rst argsort sort diff --git a/spec/_templates/method.rst b/spec/_templates/method.rst new file mode 100644 index 000000000..3a85f2879 --- /dev/null +++ b/spec/_templates/method.rst @@ -0,0 +1,5 @@ +.. currentmodule:: {{ module }} + +{{ name.split('.')[-1] | underline }} + +.. autofunction:: {{ name }} From 5b1ec764f4ec2f94bf1ef0db1696f494671f226b Mon Sep 17 00:00:00 2001 From: Stephannie Jimenez Date: Wed, 1 Dec 2021 13:11:17 -0500 Subject: [PATCH 10/10] Put return section style as parameters and remove return type section --- spec/API_specification/signatures/sorting_functions.py | 4 ++-- spec/conf.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/API_specification/signatures/sorting_functions.py b/spec/API_specification/signatures/sorting_functions.py index 8cbdc257c..715a3e817 100644 --- a/spec/API_specification/signatures/sorting_functions.py +++ b/spec/API_specification/signatures/sorting_functions.py @@ -17,7 +17,7 @@ def argsort(x: array, /, *, axis: int = -1, descending: bool = False, stable: bo Returns ------- - out: array + out : array an array of indices. The returned array must have the same shape as ``x``. The returned array must have the default array index data type. """ @@ -38,7 +38,7 @@ def sort(x: array, /, *, axis: int = -1, descending: bool = False, stable: bool Returns ------- - out: array + out : array a sorted array. The returned array must have the same data type and shape as ``x``. """ diff --git a/spec/conf.py b/spec/conf.py index 49efbc970..5370da268 100644 --- a/spec/conf.py +++ b/spec/conf.py @@ -43,8 +43,9 @@ ] autosummary_generate = True -autodoc_typehints = 'both' +autodoc_typehints = 'signature' add_module_names = False +napoleon_custom_sections = [('Returns', 'params_style')] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates']