Skip to content

Commit c14bd51

Browse files
committed
added docstrings
1 parent ce18fbd commit c14bd51

File tree

7 files changed

+40
-6
lines changed

7 files changed

+40
-6
lines changed

pertbio/pertbio/config.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
This module defines the reader for the configuration file
3+
"""
4+
15
import json
26

37

pertbio/pertbio/dataset.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
This module defines the data partitioning for different training schemes,
3+
including single-to-combo (s2c), leave-one-drug-out cross-validations (loo),
4+
and random partition of the dataset.
5+
"""
6+
17
import os
28
import numpy as np
39
import pandas as pd
@@ -181,6 +187,7 @@ def random_partition(cfg):
181187

182188

183189
def npz_to_feedable_arrays(npz):
190+
"""convert sparse matrix to arrays"""
184191
coo = npz.tocoo()
185192
indices = [[i, j] for i, j in zip(coo.row, coo.col)]
186193
values = coo.data

pertbio/pertbio/kernel.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
This module defines the ODE formulations, including the choices of ODE solvers,
3+
degree of ODEs, and the envelope forms
4+
"""
5+
16
import tensorflow as tf
27

38

pertbio/pertbio/model.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
This module defines the structures for different models, including
3+
CellBox, linear regression, and co-expression
4+
"""
5+
16
import numpy as np
27
import tensorflow as tf
38
import pertbio.kernel
@@ -20,11 +25,9 @@ def factory(args):
2025
# elif args.model == 'Bayesian':
2126
# return BN(args).build()
2227
# TODO: baysian model
23-
24-
else:
25-
raise Exception("Illegal model name. Choose from [{}]".format(
26-
'CellBox, CoExp, LinReg, NN, CoExp_nonlinear, Bayesian'
27-
))
28+
raise Exception("Illegal model name. Choose from [{}]".format(
29+
'CellBox, CoExp, LinReg, NN, CoExp_nonlinear, Bayesian'
30+
))
2831

2932

3033
class PertBio:
@@ -142,7 +145,7 @@ def build(self):
142145

143146

144147
class CoExpNonlinear(CoExp):
145-
148+
"""co-expression model with non-linear envelope"""
146149
def get_variables(self):
147150
with tf.compat.v1.variable_scope("initialization", reuse=True):
148151
Ws = tf.Variable(np.zeros([self.args.n_x, self.args.n_x, self.n_x, self.n_x]), dtype=tf.float32)
@@ -166,6 +169,7 @@ def get_variables(self):
166169

167170

168171
class LinReg(PertBio):
172+
"""linear regression model"""
169173
def get_variables(self):
170174
with tf.compat.v1.variable_scope("initialization", reuse=True):
171175
self.params.update({

pertbio/pertbio/train.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
This module defines the training of the model
3+
"""
4+
15
import os
26
import glob
37
import time
@@ -213,6 +217,7 @@ def __init__(self, args, n_iter_buffer):
213217
# initialize verbose
214218
self.summary = {}
215219
self.summary = {}
220+
self.substage_i = []
216221
try:
217222
self.export_verbose = args.export_verbose
218223
# 0: no output, 1: params only, 2: params + prediction, 3: output for each iteration

pertbio/pertbio/utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
This module defines utility functions during training, including the loss function,
3+
the optimizer, the timer, and the md5 key for each configuration
4+
"""
5+
16
import time
27
import hashlib
38
import tensorflow as tf

pertbio/pertbio/version.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
This module defines the version of the package
3+
"""
4+
15
__version__ = '0.1.1'
26
VERSION = __version__
37

0 commit comments

Comments
 (0)