Skip to content

Commit

Permalink
gh-167: fix docs style in package
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorOrachyov committed Aug 29, 2023
1 parent 2bc8204 commit 911dcd3
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 194 deletions.
46 changes: 5 additions & 41 deletions python/pyspla/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ def __init__(self, dtype=INT, shape=None, hnd=None, label=None):
"""
Creates new array of specified type and shape.
Parameters
----------
:param dtype: Type.
Type parametrization of a storage.
Expand Down Expand Up @@ -141,9 +138,6 @@ def set(self, index, value):
"""
Set value at specified index.
Parameters
----------
:param index: int.
Index at which value to set.
Expand All @@ -157,16 +151,10 @@ def get(self, index):
"""
Get value at specified index.
Parameters
----------
:param index: int.
Index at which to get value.
Returns
-------
Value at specified index.
:return: Value at specified index.
"""

value = self._dtype._c_type(0)
Expand All @@ -177,9 +165,6 @@ def build(self, view: MemView):
"""
Builds array from a raw memory view resource.
Parameters
----------
:param view: MemView.
View to a memory to build the array content from.
"""
Expand All @@ -190,10 +175,7 @@ def read(self):
"""
Read the content of the array as a MemView.
Returns
-------
MemView object with view to the array content.
:return: MemView object with view to the array content.
"""

view_hnd = ctypes.c_void_p(0)
Expand All @@ -204,9 +186,6 @@ def resize(self, shape=0):
"""
Resizes array to new size with desired num of values specified as shape.
Parameters
----------
:param shape: optional: int. default: 0.
New array capacity.
"""
Expand All @@ -224,10 +203,7 @@ def to_list(self):
"""
Read array data as a python list of values.
Returns
-------
List with values stored in the array.
:return: List with values stored in the array.
"""

buffer = (self.dtype._c_type * self.n_vals)()
Expand All @@ -241,19 +217,13 @@ def from_list(cls, values, dtype=INT):
"""
Creates new array of desired type from list of `values`.
Parameters
----------
:param values: List.
List with values to fill array.
:param dtype: Type.
Type of the array stored value.
Returns
-------
Created array filled with values.
:return: Created array filled with values.
"""

buffer = (dtype._c_type * len(values))(*values)
Expand All @@ -268,9 +238,6 @@ def generate(cls, dtype=INT, shape=0, seed=None, dist=(0, 1)):
Creates new array of desired type and shape and fills its content
with random values, generated using specified distribution.
Parameters
----------
:param dtype: Type.
Type of values array will have.
Expand All @@ -283,10 +250,7 @@ def generate(cls, dtype=INT, shape=0, seed=None, dist=(0, 1)):
:param dist: optional: tuple. default: [0,1].
Optional distribution for uniform generation of values.
Returns
-------
Created array filled with values.
:return: Created array filled with values.
"""

array = Array(dtype=dtype, shape=shape)
Expand Down
18 changes: 18 additions & 0 deletions python/pyspla/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,33 @@ def initialize():


def check(status):
"""
Checks status and converts it into an exception in case of error.
:param status:
Status to check.
"""
if status != 0:
raise _status_mapping[status]


def is_docs():
"""
Check if package in mode for docs generation.
:return: True if generating docs.
"""

global _is_docs
return _is_docs


def backend():
"""
Access to a loaded compiled C library instance.
:return: Library with C functions to call or None.
"""

global _spla
return _spla
6 changes: 0 additions & 6 deletions python/pyspla/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ class Matrix:
"""
Generalized statically-typed sparse storage-invariant matrix primitive.
Attributes
----------
- type : `type` type of stored matrix elements
- shape : `2-tuple` shape of the matrix in form of two integers tuple
Notes
-----
Expand Down
15 changes: 6 additions & 9 deletions python/pyspla/memview.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,22 @@ def __init__(self, label=None, hnd=None, buffer=None, size=None, mutable=None, o
"""
Creates a new memory view from existing hnd or making new for a buffer resource.
Parameters
----------
label: optional: str. default: None.
:param label: optional: str. default: None.
MemView name for debugging.
hnd: optional: ctypes.c_void_p. default: None.
:param hnd: optional: ctypes.c_void_p. default: None.
MemView native void* handle to a C counterpart.
buffer: optional: ctypes.c_void_p. default: None.
:param buffer: optional: ctypes.c_void_p. default: None.
Optional buffer in case making new view.
size: optional: int. default: None.
:param size: optional: int. default: None.
Optional size, must be provided if buffer provided.
mutable: optional: bool. default: None.
:param mutable: optional: bool. default: None.
Optional flag if buffer content is mutable.
owner: optional: Object. default: None.
:param owner: optional: Object. default: None.
Optional owner of a given memory view.
"""

Expand Down
7 changes: 2 additions & 5 deletions python/pyspla/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,10 @@ def __init__(self, label, hnd):
"""
Creates a base spla object class instance with common attributes.
Parameters
----------
label: optional: str. default: None.
:param label: optional: str. default: None.
Object name for debugging.
hnd: optional: ctypes.c_void_p. default: None.
:param hnd: optional: ctypes.c_void_p. default: None.
Object native void* handle to a C counterpart.
"""

Expand Down
50 changes: 19 additions & 31 deletions python/pyspla/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,16 @@ def __init__(self, hnd, name, dtype_res, label=None):
"""
Creates new operation from a native C api object handle.
Parameters
----------
hnd: ctypes.c_void_p.
:param hnd: ctypes.c_void_p.
Mandatory handle to native C object.
name: str.
:param name: str.
Mandatory name of the operation.
dtype_res:
:param dtype_res: Type.
Type of the return value of the operation.
label: optional: str. default: None.
:param label: optional: str. default: None.
Optional debug label to set for the object.
"""

Expand Down Expand Up @@ -111,22 +108,19 @@ def __init__(self, hnd, name, dtype_res, dtype_arg0, label=None):
"""
Creates new unary operation from a native C api object handle.
Parameters
----------
hnd: ctypes.c_void_p.
:param hnd: ctypes.c_void_p.
Mandatory handle to native C object.
name: str.
:param name: str.
Mandatory name of the operation.
dtype_res:
:param dtype_res: Type.
Type of the return value of the operation.
dtype_arg0:
:param dtype_arg0: Type.
Type of the first operation argument.
label: optional: str. default: None.
:param label: optional: str. default: None.
Optional debug label to set for the object.
"""

Expand Down Expand Up @@ -159,25 +153,22 @@ def __init__(self, hnd, name, dtype_res, dtype_arg0, dtype_arg1, label=None):
"""
Creates new binary operation from a native C api object handle.
Parameters
----------
hnd: ctypes.c_void_p.
:param hnd: ctypes.c_void_p.
Mandatory handle to native C object.
name: str.
:param name: str.
Mandatory name of the operation.
dtype_res:
:param dtype_res: Type.
Type of the return value of the operation.
dtype_arg0:
:param dtype_arg0: Type.
Type of the first operation argument.
dtype_arg1:
:param dtype_arg1: Type.
Type of the second operation argument.
label: optional: str. default: None.
:param label: optional: str. default: None.
Optional debug label to set for the object.
"""

Expand Down Expand Up @@ -218,19 +209,16 @@ def __init__(self, hnd, name, dtype_arg0, label=None):
"""
Creates new select operation from a native C api object handle.
Parameters
----------
hnd: ctypes.c_void_p.
:param hnd: ctypes.c_void_p.
Mandatory handle to native C object.
name: str.
:param name: str.
Mandatory name of the operation.
dtype_arg0:
:param dtype_arg0: Type.
Type of the first operation argument.
label: optional: str. default: None.
:param label: optional: str. default: None.
Optional debug label to set for the object.
"""

Expand Down
21 changes: 6 additions & 15 deletions python/pyspla/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,16 @@ def __init__(self, dtype=INT, value=None, hnd=None, label=None):
"""
Creates new scalar of desired type or retains existing C object.
Parameters
----------
dtype: optional: Type. default: INT.
:param dtype: optional: Type. default: INT.
Type of the scalar value.
value: optional: Any. default: None.
:param value: optional: Any. default: None.
Optional value to store in scalar on creation.
hnd: optional: ctypes.c_void_p. default: None.
:param hnd: optional: ctypes.c_void_p. default: None.
Optional handle to C object to retain in this scalar instance.
label: optional: str. default: None.
:param label: optional: str. default: None.
Optional debug label of the scalar.
"""

Expand Down Expand Up @@ -128,10 +125,7 @@ def set(self, value=None):
"""
Set the value stored in the scalar. If no value passed the default value is set.
Parameters
----------
value: optional: Any. default: None.
:param value: optional: Any. default: None.
Optional value to store in scalar.
"""

Expand All @@ -141,10 +135,7 @@ def get(self):
"""
Read the value stored in the scalar.
Returns
-------
Value from scalar.
:return: Value from scalar.
"""

value = self._dtype._c_type(0)
Expand Down
Loading

0 comments on commit 911dcd3

Please sign in to comment.