Skip to content

Commit

Permalink
docs: fix docstring examples (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
tilman151 authored Nov 24, 2023
1 parent b32bd85 commit 0219026
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
10 changes: 7 additions & 3 deletions rul_datasets/adaption.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class DomainAdaptionDataModule(pl.LightningDataModule):
>>> source = rul_datasets.RulDataModule(fd1, 32)
>>> target = rul_datasets.RulDataModule(fd2, 32)
>>> dm = rul_datasets.DomainAdaptionDataModule(source, target)
>>> dm.prepare_data()
>>> dm.setup()
>>> train_1_2 = dm.train_dataloader()
>>> val_1, val_2 = dm.val_dataloader()
>>> test_1, test_2 = dm.test_dataloader()
Expand Down Expand Up @@ -231,9 +233,11 @@ class LatentAlignDataModule(DomainAdaptionDataModule):
>>> import rul_datasets
>>> fd1 = rul_datasets.CmapssReader(fd=1, window_size=20)
>>> fd2 = rul_datasets.CmapssReader(fd=2, percent_broken=0.8)
>>> source = rul_datasets.RulDataModule(fd1, 32)
>>> target = rul_datasets.RulDataModule(fd2, 32)
>>> dm = rul_datasets.LatentAlignDataModule(source, target)
>>> src = rul_datasets.RulDataModule(fd1, 32)
>>> trg = rul_datasets.RulDataModule(fd2, 32)
>>> dm = rul_datasets.LatentAlignDataModule(src, trg, split_by_max_rul=125)
>>> dm.prepare_data()
>>> dm.setup()
>>> train_1_2 = dm.train_dataloader()
>>> val_1, val_2 = dm.val_dataloader()
>>> test_1, test_2 = dm.test_dataloader()
Expand Down
2 changes: 2 additions & 0 deletions rul_datasets/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class BaselineDataModule(pl.LightningDataModule):
>>> cmapss = rul_datasets.reader.CmapssReader(fd=1)
>>> dm = rul_datasets.RulDataModule(cmapss, batch_size=32)
>>> baseline_dm = rul_datasets.BaselineDataModule(dm)
>>> baseline_dm.prepare_data()
>>> baseline_dm.setup()
>>> train_fd1 = baseline_dm.train_dataloader()
>>> val_fd1 = baseline_dm.val_dataloader()
>>> test_fd1, test_fd2, test_fd3, test_fd4 = baseline_dm.test_dataloader()
Expand Down
7 changes: 6 additions & 1 deletion rul_datasets/reader/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class AbstractReader(metaclass=abc.ABCMeta):
Examples:
>>> import rul_datasets
>>> class MyReader(rul_datasets.reader.AbstractReader):
... @property
... def dataset_name(self):
... return "my_dataset"
...
... @property
... def fds(self):
... return [1]
...
Expand All @@ -41,7 +46,7 @@ class AbstractReader(metaclass=abc.ABCMeta):
>>> my_reader = MyReader(fd=1)
>>> features, targets = my_reader.load_split("dev")
>>> features[0].shape
torch.Size([100, 2, 30])
(100, 2, 30)
"""

fd: int
Expand Down
2 changes: 2 additions & 0 deletions rul_datasets/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class SemiSupervisedDataModule(pl.LightningDataModule):
>>> labeled = rul_datasets.RulDataModule(fd1, 32)
>>> unlabeled = rul_datasets.RulDataModule(fd1_complement, 32)
>>> dm = rul_datasets.SemiSupervisedDataModule(labeled, unlabeled)
>>> dm.prepare_data()
>>> dm.setup()
>>> train_ssl = dm.train_dataloader()
>>> val = dm.val_dataloader()
>>> test = dm.test_dataloader()
Expand Down

0 comments on commit 0219026

Please sign in to comment.