Skip to content

Commit a0d7453

Browse files
committed
Update documentation
1 parent e516aea commit a0d7453

File tree

10 files changed

+75
-18
lines changed

10 files changed

+75
-18
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
processes\_manager
2+
==================
3+
4+
.. automodule:: processes_manager
5+
6+
.. autoclass:: TorchProcsHandler
7+
:members: __init__, __len__, create_and_start, create_process_and_start, join, terminate, join_and_terminate
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
preprocess\_utils
2+
=================
3+
4+
.. automodule:: preprocess_utils
5+
:members: read_csv, replace, change_column_types

docs/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
sys.path.append(os.path.abspath("../../src/exceptions/"))
1919
sys.path.append(os.path.abspath("../../src/spaces/"))
2020
sys.path.append(os.path.abspath("../../src/policies/"))
21+
sys.path.append(os.path.abspath("../../src/parallel/"))
22+
sys.path.append(os.path.abspath("../../src/preprocessor/"))
2123
sys.path.append(os.path.abspath("../../src/maths/"))
2224
sys.path.append(os.path.abspath("../../src/utils/"))
2325
sys.path.append(os.path.abspath("../../src/datasets/"))

docs/source/modules.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ API
2121
API/maths/pytorch_optimizer_config
2222
API/maths/string_distance_calculator
2323
API/networks/a2c_networks
24+
API/parallel/process_manager
2425
API/policies/epsilon_greedy_policy
26+
API/preprocessor/preprocess_utils
2527
API/spaces/actions
2628
API/spaces/action_space
2729
API/spaces/state

src/apps/compare_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from src.datasets.datasets_loaders import MockSubjectsLoader
44
from src.datasets.dataset_wrapper import PandasDSWrapper
5-
from src.preprocessor.cleanup_utils import replace, change_column_types
5+
from src.preprocessor.preprocess_utils import replace, change_column_types
66
from src.maths.numeric_distance_type import NumericDistanceType
77
from src.maths.string_distance_calculator import StringDistanceType
88
from src.maths.distortion_calculator import DistortionCalculationType, DistortionCalculator

src/datasets/dataset_wrapper.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
"""module dataset_wrapper. Utilities
2+
to wrap a DataFrame so that it can be uses
3+
as an environment suitable for RL algorithms
4+
5+
"""
16
from pathlib import Path
27
import abc
38
from typing import Generic, TypeVar
49
import pandas as pd
510
import numpy as np
611

7-
from src.preprocessor.cleanup_utils import read_csv, replace, change_column_types
12+
from src.preprocessor.preprocess_utils import read_csv, replace, change_column_types
813
from src.exceptions.exceptions import InvalidDataTypeException
914

1015
DS = TypeVar("DS")
@@ -13,6 +18,9 @@
1318

1419

1520
class DSWrapper(Generic[DS], metaclass=abc.ABCMeta):
21+
"""Base class for deriving data set wrappers
22+
23+
"""
1624

1725
def __init__(self) -> None:
1826
super(DSWrapper, self).__init__()
@@ -29,8 +37,7 @@ def read(self, filename: Path, **options) -> None:
2937

3038

3139
class PandasDSWrapper(DSWrapper[pd.DataFrame]):
32-
"""
33-
Simple wrapper to a pandas DataFrame object.
40+
"""Simple wrapper to a pandas DataFrame object.
3441
Facilitates various actions on the original dataset
3542
"""
3643

src/maths/numeric_distance_calculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Various methods to calculate distance between numeric vectors
1+
"""module numeric_distance_calculator. Various methods to calculate distance between numeric vectors
22
"""
33
import numpy as np
44
from typing import TypeVar

src/parallel/processes_manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""module process_manager. Utilities for managing
2+
processes
3+
4+
"""
15
from typing import Callable
26

37
import torch.multiprocessing as mp
Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1+
"""module preprocess_utils. Specifies utilities for
2+
preprocessing a data set.
3+
4+
"""
15
import csv
26
import pandas as pd
37
from pathlib import Path
48
from typing import List
59

610

7-
def read_csv(filename: Path, features_drop_names: List[str], names: List[str], delimiter=','):
8-
"""
9-
Read the csv file specified at the given filename
10-
:param filename: The path to the filw to read
11-
:param features_drop_names: Features to drop
12-
:param names: Names of columns
13-
:return:
11+
def read_csv(filename: Path, features_drop_names: List[str], names: List[str], delimiter=',') -> pd.DataFrame:
12+
13+
"""Read the csv file specified at the given filename
14+
15+
Parameters
16+
----------
17+
filename: Filename to read
18+
features_drop_names: Which columns to drop
19+
names: Column names
20+
delimiter: file delimiter
21+
22+
Returns
23+
-------
24+
25+
A pandas DataFrame
1426
"""
1527

28+
1629
df = pd.read_csv(filepath_or_buffer=filename, sep=delimiter, header=0, names=names)
1730

1831
if len(features_drop_names) != 0:
@@ -25,14 +38,20 @@ def read_csv(filename: Path, features_drop_names: List[str], names: List[str], d
2538

2639

2740
def replace(ds: pd.DataFrame, options: dict) -> pd.DataFrame:
28-
"""
29-
Replace the values in the given data set according to the passed
41+
"""Replace the values in the given data set according to the passed
3042
options. The options should specify for each column the values
3143
to be changed and the corresponding values to set
32-
:param ds: The dataframe to replace
33-
:param options:
34-
:return: None
44+
45+
Parameters
46+
----------
47+
ds
48+
options
49+
50+
Returns
51+
-------
52+
3553
"""
54+
3655
for col in options:
3756

3857
# get the values to change for each column
@@ -49,5 +68,16 @@ def replace(ds: pd.DataFrame, options: dict) -> pd.DataFrame:
4968

5069

5170
def change_column_types(ds, column_types) -> pd.DataFrame:
71+
"""Change the column type
72+
73+
Parameters
74+
----------
75+
ds
76+
column_types
77+
78+
Returns
79+
-------
80+
81+
"""
5282
ds = ds.astype(dtype=column_types)
5383
return ds

tests/test_preprocessor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44
from pathlib import Path
55
import pandas as pd
6-
from src.preprocessor.cleanup_utils import read_csv, replace, change_column_types
6+
from src.preprocessor.preprocess_utils import read_csv, replace, change_column_types
77

88

99
class TestPreprocessor(unittest.TestCase):

0 commit comments

Comments
 (0)