Skip to content

Commit 39a9fac

Browse files
Add data_structures.md to documentation utils
1 parent e231de5 commit 39a9fac

File tree

3 files changed

+49
-23
lines changed

3 files changed

+49
-23
lines changed

docs/source/api_reference/utils.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Utils
22

3-
The {mod}`frouros.utils` module contains auxiliary classes or functions.
3+
The {mod}`frouros.utils` module contains auxiliary classes, functions or exceptions.
44

55
```{toctree}
66
:maxdepth: 2
77
8+
utils/data_structures
89
utils/kernels
910
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Data Structures
2+
3+
The {mod}`frouros.utils.data_structures` module contains auxiliary data structures classes or exceptions.
4+
5+
```{eval-rst}
6+
.. automodule:: frouros.utils.data_structures
7+
:members:
8+
:no-inherited-members:
9+
```

frouros/utils/data_structures.py

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,45 @@
11
"""Data structures module."""
22

3-
from typing import Any, Optional, List, Union
3+
from typing import Any, Optional, List, Union, Dict, Tuple
44

55
import numpy as np # type: ignore
66

77

88
class EmptyQueueError(Exception):
9-
"""Empty queue exception."""
10-
11-
def __init__(self, *args, msg="Queue is empty.", **kwargs) -> None:
12-
"""Init method.
13-
14-
:param msg: exception message
15-
:type msg: str
16-
"""
17-
super().__init__(msg, *args, **kwargs)
9+
"""Empty queue exception.
10+
11+
:param args: exception arguments
12+
:type args: Tuple[Any, ...]
13+
:param msg: exception message, defaults to "Queue is empty."
14+
:type msg: str
15+
:param kwargs: exception keyword arguments
16+
:type kwargs: Dict[str, Dict[str, Any]]
17+
"""
18+
19+
def __init__( # noqa: D107
20+
self,
21+
*args: Tuple[Any, ...],
22+
msg: str = "Queue is empty.",
23+
**kwargs: Dict[str, Dict[str, Any]],
24+
) -> None:
25+
super().__init__(
26+
msg,
27+
*args,
28+
**kwargs,
29+
)
1830

1931

2032
class CircularQueue:
21-
"""Class representing a circular queue."""
33+
"""Class representing a circular queue.
2234
23-
def __init__(self, max_len: int) -> None:
24-
"""Init method.
35+
:param max_len: maximum capacity
36+
:type max_len: int
37+
"""
2538

26-
:param max_len: maximum capacity
27-
:type max_len: int
28-
"""
39+
def __init__( # noqa: D107
40+
self,
41+
max_len: int,
42+
) -> None:
2943
self.count = 0
3044
self.first = 0
3145
self.last = -1
@@ -218,14 +232,16 @@ def __getitem__(self, idx: int) -> Any:
218232

219233

220234
class AccuracyQueue(CircularQueue):
221-
"""Class representing an accuracy queue."""
235+
"""Class representing an accuracy queue.
222236
223-
def __init__(self, max_len: int) -> None:
224-
"""Init method.
237+
:param max_len: maximum capacity
238+
:type max_len: int
239+
"""
225240

226-
:param max_len: maximum capacity
227-
:type max_len: int
228-
"""
241+
def __init__( # noqa: D107
242+
self,
243+
max_len: int,
244+
) -> None:
229245
super().__init__(max_len=max_len)
230246
self.num_true = 0
231247

0 commit comments

Comments
 (0)