Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] Cleanup sphinx doc warnings for 0.15 #2649

Merged
Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
- PR #2634: singlegpu build option fixes
- PR #2651: AutoARIMA Python bug fix
- PR #2654: Fix for vectorizer concatenations
- PR #2655: Fix C++ RF predict function access of rows/samples array
- PR #2649: Cleanup sphinx doc warnings for 0.15
- PR #2669: Revert PR 2655 Revert "Fixes C++ RF predict function"

# cuML 0.14.0 (03 Jun 2020)
Expand Down
23 changes: 23 additions & 0 deletions docs/source/_static/references.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

/* Fix references to not look like parameters */
dl.citation > dt.label {
display: unset !important;
float: left !important;
border: unset !important;
background: unset !important;
padding: unset !important;
margin: unset !important;
font-size: unset !important;
line-height: unset !important;
padding-right: 0.5rem !important;
}

/* Add opening bracket */
dl.citation > dt.label > span::before {
content: "[";
}

/* Add closing bracket */
dl.citation > dt.label > span::after {
content: "]";
}
4 changes: 3 additions & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Model Selection and Data Splitting
Feature and Label Encoding (Single-GPU)
---------------------------------------

.. autoclass:: cuml.preprocessing.LabelEncoder
.. autoclass:: cuml.preprocessing.LabelEncoder.LabelEncoder
:members:

.. autoclass:: cuml.preprocessing.LabelBinarizer
Expand Down Expand Up @@ -248,12 +248,14 @@ Nearest Neighbors Classification

.. autoclass:: cuml.neighbors.KNeighborsClassifier
:members:
:noindex:

Nearest Neighbors Regression
----------------------------

.. autoclass:: cuml.neighbors.KNeighborsRegressor
:members:
:noindex:

Clustering
==========
Expand Down
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,6 @@


def setup(app):
app.add_css_file('copybutton.css')
app.add_css_file('params.css')
app.add_css_file('references.css')
2 changes: 1 addition & 1 deletion python/cuml/cluster/dbscan.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class DBSCAN(Base):
neighbours.

Examples
---------
--------

.. code-block:: python

Expand Down
47 changes: 17 additions & 30 deletions python/cuml/common/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ class CumlArray(Buffer):
"""
Array represents an abstracted array allocation. It can be instantiated by
itself, creating an rmm.DeviceBuffer underneath, or can be instantiated by
__cuda_array_interface__ or __array_interface__ compliant arrays, in which
case it'll keep a reference to that data underneath. Also can be created
from a pointer, specifying the characteristics of the array, in that case
the owner of the data referred to by the pointer should be specified
explicitly.
``__cuda_array_interface__`` or ``__array_interface__`` compliant arrays,
in which case it'll keep a reference to that data underneath. Also can be
created from a pointer, specifying the characteristics of the array, in
that case the owner of the data referred to by the pointer should be
specified explicitly.

Parameters
----------

data : rmm.DeviceBuffer, cudf.Buffer, array_like, int, bytes, bytearray or
data : rmm.DeviceBuffer, cudf.Buffer, array_like, int, bytes, bytearray or\
memoryview
An array-like object or integer representing a
device or host pointer to pre-allocated memory.
Expand Down Expand Up @@ -71,23 +71,7 @@ class CumlArray(Buffer):
strides : tuple of ints
Strides of the data
__cuda_array_interface__ : dictionary
__cuda_array_interface__ to interop with other libraries.

Object Methods
--------------

to_output : Convert the array to the appropriate output format.

Class Methods
-------------

Array.empty : Create an empty array, allocating a DeviceBuffer.
Array.full : Create an Array with allocated DeviceBuffer initialized with
a particular value.
Array.ones : Create an Array with allocated DeviceBuffer initialized with
ones.
Array.zeros : Create an Array with allocated DeviceBuffer initialized with
zeros.
``__cuda_array_interface__`` to interop with other libraries.

Notes
-----
Expand Down Expand Up @@ -204,16 +188,19 @@ def to_output(self, output_type='cupy', output_dtype=None):
----------
output_type : string
Format to convert the array to. Acceptable formats are:
'cupy' - to cupy array
'numpy' - to numpy (host) array
'numba' - to numba device array
'dataframe' - to cuDF DataFrame
'series' - to cuDF Series
'cudf' - to cuDF Series if array is single dimensional, to
DataFrame otherwise

- 'cupy' - to cupy array
- 'numpy' - to numpy (host) array
- 'numba' - to numba device array
- 'dataframe' - to cuDF DataFrame
- 'series' - to cuDF Series
- 'cudf' - to cuDF Series if array is single dimensional, to
DataFrame otherwise

output_dtype : string, optional
Optionally cast the array to a specified dtype, creating
a copy if necessary.

"""
if output_dtype is None:
output_dtype = self.dtype
Expand Down
4 changes: 2 additions & 2 deletions python/cuml/common/kernel_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def cuda_kernel_factory(nvrtc_kernel_str, dtypes, kernel_name=None):
included in the kernel string. These will be added by this function and
the function name will be made unique, based on the given dtypes.

Example
-------
Examples
--------

The following kernel string with dtypes = [float, double, int]

Expand Down
2 changes: 0 additions & 2 deletions python/cuml/common/logger.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def set_level(level):

.. code-block:: python


# regular usage of setting a logging level for all subsequent logs
# in this case, it will enable all logs upto and including `info()`
logger.set_level(logger.level_info)
Expand Down Expand Up @@ -147,7 +146,6 @@ def set_pattern(pattern):

.. code-block:: python


# regular usage of setting a logging pattern for all subsequent logs
logger.set_pattern("--> [%H-%M-%S] %v")

Expand Down
123 changes: 63 additions & 60 deletions python/cuml/common/memory_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def rmm_cupy_ary(cupy_fn, *args, **kwargs):

Function to call CuPy functions with RMM memory management


Parameters
----------
cupy_fn : cupy function,
Expand All @@ -76,13 +75,13 @@ def rmm_cupy_ary(cupy_fn, *args, **kwargs):
Keyword named arguments to pass to the CuPy function


Note: this function should be used if the result of cupy_fn creates
.. note:: this function should be used if the result of cupy_fn creates
a new array. Functions to create a new CuPy array by reference to
existing device array (through __cuda_array_interface__) can be used
directly.

Examples
---------
--------

.. code-block:: python

Expand Down Expand Up @@ -242,30 +241,32 @@ def set_global_output_type(output_type):
output_type : {'input', 'cudf', 'cupy', 'numpy'} (default = 'input')
Desired output type of results and attributes of the estimators.

'input' will mean that the parameters and methods will mirror the
format of the data sent to the estimators/methods as much as
possible. Specifically:

Input type -> Output type

cuDF DataFrame or Series -> cuDF DataFrame or Series

NumPy arrays -> NumPy arrays

Pandas DataFrame or Series -> NumPy arrays

Numba device arrays -> Numba device arrays

CuPy arrays -> CuPy arrays

Other __cuda_array_interface__ objects -> CuPy arrays

'cudf' will return cuDF Series for single dimensional results and
DataFrames for the rest.

'cupy' will return CuPy arrays.

'numpy' will return NumPy arrays.
* ``'input'`` will mean that the parameters and methods will mirror the
format of the data sent to the estimators/methods as much as
possible. Specifically:

+---------------------------------------+--------------------------+
| Input type | Output type |
+=======================================+==========================+
| cuDF DataFrame or Series | cuDF DataFrame or Series |
+---------------------------------------+--------------------------+
| NumPy arrays | NumPy arrays |
+---------------------------------------+--------------------------+
| Pandas DataFrame or Series | NumPy arrays |
+---------------------------------------+--------------------------+
| Numba device arrays | Numba device arrays |
+---------------------------------------+--------------------------+
| CuPy arrays | CuPy arrays |
+---------------------------------------+--------------------------+
| Other `__cuda_array_interface__` objs | CuPy arrays |
+---------------------------------------+--------------------------+

* ``'cudf'`` will return cuDF Series for single dimensional results and
DataFrames for the rest.

* ``'cupy'`` will return CuPy arrays.

* ``'numpy'`` will return NumPy arrays.

Examples
--------
Expand All @@ -288,7 +289,7 @@ def set_global_output_type(output_type):

Output:

.. code-block:: python
.. code-block::

cuML output type
0 0
Expand All @@ -299,10 +300,11 @@ def set_global_output_type(output_type):

Notes
-----
'cupy' and 'numba' options (as well as 'input' when using Numba and CuPy
ndarrays for input) have the least overhead. cuDF add memory consumption
and processing time needed to build the Series and DataFrames. 'numpy' has
the biggest overhead due to the need to transfer data to CPU memory.
``'cupy'`` and ``'numba'`` options (as well as ``'input'`` when using Numba
and CuPy ndarrays for input) have the least overhead. cuDF add memory
consumption and processing time needed to build the Series and DataFrames.
``'numpy'`` has the biggest overhead due to the need to transfer data to
CPU memory.

"""
if isinstance(output_type, str):
Expand Down Expand Up @@ -330,30 +332,32 @@ def using_output_type(output_type):
output_type : {'input', 'cudf', 'cupy', 'numpy'} (default = 'input')
Desired output type of results and attributes of the estimators.

'input' will mean that the parameters and methods will mirror the
format of the data sent to the estimators/methods as much as
possible. Specifically:

Input type -> Output type

cuDF DataFrame or Series -> cuDF DataFrame or Series

NumPy arrays -> NumPy arrays

Pandas DataFrame or Series -> NumPy arrays

Numba device arrays -> Numba device arrays

CuPy arrays -> CuPy arrays

Other __cuda_array_interface__ objects -> CuPy arrays

'cudf' will return cuDF Series for single dimensional results and
DataFrames for the rest.

'cupy' will return CuPy arrays.

'numpy' will return NumPy arrays.
* ``'input'`` will mean that the parameters and methods will mirror the
format of the data sent to the estimators/methods as much as
possible. Specifically:

+---------------------------------------+--------------------------+
| Input type | Output type |
+=======================================+==========================+
| cuDF DataFrame or Series | cuDF DataFrame or Series |
+---------------------------------------+--------------------------+
| NumPy arrays | NumPy arrays |
+---------------------------------------+--------------------------+
| Pandas DataFrame or Series | NumPy arrays |
+---------------------------------------+--------------------------+
| Numba device arrays | Numba device arrays |
+---------------------------------------+--------------------------+
| CuPy arrays | CuPy arrays |
+---------------------------------------+--------------------------+
| Other `__cuda_array_interface__` objs | CuPy arrays |
+---------------------------------------+--------------------------+

* ``'cudf'`` will return cuDF Series for single dimensional results and
DataFrames for the rest.

* ``'cupy'`` will return CuPy arrays.

* ``'numpy'`` will return NumPy arrays.

Examples
--------
Expand All @@ -370,7 +374,7 @@ def using_output_type(output_type):
dbscan_float = cuml.DBSCAN(eps=1.0, min_samples=1)
dbscan_float.fit(ary)

print("cuML output inside `with` context")
print("cuML output inside 'with' context")
print(dbscan_float.labels_)
print(type(dbscan_float.labels_))

Expand All @@ -384,16 +388,15 @@ def using_output_type(output_type):

Output:

.. code-block:: python
.. code-block::

cuML output inside `with` context
cuML output inside 'with' context
0 0
1 1
2 2
dtype: int32
<class 'cudf.core.series.Series'>


cuML default output
[0 1 2]
<class 'cupy.core.core.ndarray'>
Expand Down
4 changes: 2 additions & 2 deletions python/cuml/common/opg_data_utils_mg.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def build_rank_size_pair(parts_to_sizes, rank):
parts_to_sizes: array of tuples in the format: [(rank,size)]
rank: rank to be mapped

Returns:
Returns
--------
ptr: vector pointer of the RankSizePair*
"""
Expand Down Expand Up @@ -162,7 +162,7 @@ def build_part_descriptor(m, n, rank_size_t, rank):
building the part descriptor
rank: rank to be mapped

Returns:
Returns
--------
ptr: PartDescriptor object
"""
Expand Down
3 changes: 2 additions & 1 deletion python/cuml/common/sparsefuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def _insert_zeros(ary, zero_indices):
Create a new array of len(ary + zero_indices) where zero_indices
indicates indexes of 0s in the new array. Ary is used to fill the rest.

Example:
Examples
--------
_insert_zeros([1, 2, 3], [1, 3]) => [1, 0, 2, 0, 3]
"""
if len(zero_indices) == 0:
Expand Down
Loading