Skip to content

Commit 8112796

Browse files
committed
imporve main class docstring
1 parent 809e9bb commit 8112796

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

DynamicVector/DynamicVector.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class DynamicVector:
4040
The dynamic vector includes fast appending and popping, like a list,
4141
while retaining numpy array index support and vector operations.
4242
43-
The dynamic vector supports most of the python list and numpy.ndarray methods.
43+
The dynamic vector support the python list methods and numpy.ndarray 1D array methods.
44+
For access to all the numpy methods, a view of the vector as a numpy.ndarray can be returned.
4445
4546
The storage of the vector automatically grows in capacity by doubling it
4647
until the capacity exceeds a certain threshold (`grow_use_add`),
@@ -52,16 +53,16 @@ class DynamicVector:
5253
5354
Args:
5455
dtype (np.dtype, optional): numpy.dtype (data type) of the vector elements. Defaults to np.int32.
55-
capacity (int, optional): Initial capacity of the vector. Defaults to 8.
56+
capacity (int, optional): Initial minimum capacity of the underlying storage vector. Defaults to 8.
5657
grow_use_add (int, optional): Threshold to switch from multiplicative to additive growth. Defaults to 8192.
5758
grow_add (int, optional): Additive increment in additive growth mode. Defaults to 2048.
5859
5960
Attributes:
6061
size (int): The size of the dynamic vector.
61-
view (np.ndarray): A np.ndarray view of the dynamic vector.
62+
view (np.ndarray): A np.ndarray view of the dynamic vector at its current size.
6263
dtype (np.dtype): The numpy.dtype (data type) of the vector.
6364
64-
capacity (int): The capacity of the underlying vector storage.
65+
capacity (int): The capacity of the underlying vector storage (note, `size <= capacity`).
6566
grow_use_add (int): Threshold that growth switches from multiplicative to additive growth.
6667
grow_add (int): Additive increment in additive growth mode.
6768
@@ -182,6 +183,8 @@ class DynamicVector:
182183
Notes:
183184
- The vector automatically resizes when needed, and it uses multiplicative growth until a specified threshold.
184185
- After reaching the threshold, the growth becomes additive.
186+
- A variable set to the view of the vector does not change size when the DynamicVector changes size.
187+
- Size is always less than or equal to capacity.
185188
"""
186189

187190
_size: int # The current number of elements in the vector.
@@ -194,10 +197,10 @@ def __init__(self, dtype=np.int32, capacity=8, *, grow_use_add=None, grow_add=No
194197
Initialize the DynamicVector.
195198
196199
Parameters:
197-
dtype (np.dtype): The data type of the elements (int32 by default).
198-
capacity (int): The initial capacity of the vector. Defaults to 8.
199-
grow_use_add (int, optional): Custom threshold to switch from multiplicative to additive growth.
200-
grow_add (int, optional): Custom value for additive growth.
200+
dtype (np.dtype, optional): numpy.dtype (data type) of the vector elements. Defaults to np.int32.
201+
capacity (int, optional): Initial minimum capacity of the underlying storage vector. Defaults to 8.
202+
grow_use_add (int, optional): Threshold to switch from multiplicative to additive growth. Defaults to 8192.
203+
grow_add (int, optional): Additive increment in additive growth mode. Defaults to 2048.
201204
"""
202205
if grow_use_add is None:
203206
self._grow_use_add = _GROW_USE_ADD

0 commit comments

Comments
 (0)