Skip to content

Commit 0bf5c4f

Browse files
Model annotations (#4)
* annotations to model.py * Annotations of Bicycle.__init__() * Annotation of lyapunov_direct function * Further annotation and pylint optimization of model.py * Further annotations for functions and classes in data.py, callbacks.py, plotting.py and dictlogger.py * Apply suggestions from code review Co-authored-by: Martin Rohbeck <35061428+martinrohbeck@users.noreply.github.com> * Compliance with code review from pull request Model annotations #4 Co-authored-by: Martin Rohbeck <35061428+martinrohbeck@users.noreply.github.com> * Update src/bicycle/model.py Co-authored-by: Martin Rohbeck <35061428+martinrohbeck@users.noreply.github.com> * Compliance with code review. Co-authored-by: Martin Rohbeck <martin.rohbeck@quantco.com> * Compliance with PR #4. Co-authored-by: Martin Rohbeck <martin.rohbeck@quantco.com> * Compliance with PR #4. Co-authored-by: Martin Rohbeck <martin.rohbeck@quantco.com> * minor docstring changes to callbacks.py * minor docstring changes to data.py * Minor docstring edits for plotting.py * Minor docstring edits for training.py * Update model.py Minor docstring updates to model.py * Compliance with PR #4 Co-authored-by: Martin Rohbeck <martin.rohbeck@quantco.com> * Removed comments --------- Co-authored-by: Martin Rohbeck <35061428+martinrohbeck@users.noreply.github.com> Co-authored-by: Martin Rohbeck <martin.rohbeck@quantco.com>
1 parent 7f49ac3 commit 0bf5c4f

6 files changed

Lines changed: 470 additions & 67 deletions

File tree

src/bicycle/callbacks.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,25 @@ def on_validation_end(self, trainer: "pl.Trainer", pl_module: "pl.LightningModul
6565

6666

6767
class GenerateCallback(pl.Callback):
68+
"""
69+
Class for generating a callback at the end of each training epoch of the bicycle model.
70+
Subclasses pytorch_lightnings Callback function.
71+
72+
Notes:
73+
- Calls the plot_training_results function from bicycle.utils.plotting
74+
after each epoch that's a multiple of `plot_epoch_callback`.
75+
"""
6876
def __init__(self, file_name_plot, plot_epoch_callback=10, true_beta=None, labels=None):
77+
"""
78+
Initializes the GenerateCallback function for plotting training results during training.
79+
80+
Args:
81+
file_name_plot (str): containing the file_name for the saved plots.
82+
Can be given with or without the suffix.
83+
plot_epoch_callback (int): specifying the callback interval.
84+
true_beta (Optional|torch.Tensor): containing the ground truth gene adjacency matrix.
85+
labels (Iterable): contains the gene labels.
86+
"""
6987
super().__init__()
7088
self.plot_epoch_callback = plot_epoch_callback
7189
self.true_beta = true_beta

src/bicycle/dictlogger.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def __missing__(self, key):
1414

1515

1616
class DictLogger(Logger):
17+
"""
18+
Class for logging model hyperparameters and metrics.
19+
Subclasses the pytorch_lightning.loggers Logger class.
20+
"""
1721
def __init__(self, version=None):
1822
self._version = version
1923
self.experiment = None

0 commit comments

Comments
 (0)