This is a pass through transform to be used for testing purposes. It allows adding fake behaviors that are useful for testing purposes to simulate how large datasets behave without needing to test on large data sets. For example, simulating slow NFS data transfers, or slow network
| 747 | |
| 748 | |
| 749 | class SimulateDelay(Transform): |
| 750 | """ |
| 751 | This is a pass through transform to be used for testing purposes. It allows |
| 752 | adding fake behaviors that are useful for testing purposes to simulate |
| 753 | how large datasets behave without needing to test on large data sets. |
| 754 | |
| 755 | For example, simulating slow NFS data transfers, or slow network transfers |
| 756 | in testing by adding explicit timing delays. Testing of small test data |
| 757 | can lead to incomplete understanding of real world issues, and may lead |
| 758 | to sub-optimal design choices. |
| 759 | """ |
| 760 | |
| 761 | backend = [TransformBackends.TORCH, TransformBackends.NUMPY] |
| 762 | |
| 763 | def __init__(self, delay_time: float = 0.0) -> None: |
| 764 | """ |
| 765 | Args: |
| 766 | delay_time: The minimum amount of time, in fractions of seconds, |
| 767 | to accomplish this delay task. |
| 768 | """ |
| 769 | super().__init__() |
| 770 | self.delay_time: float = delay_time |
| 771 | |
| 772 | def __call__(self, img: NdarrayOrTensor, delay_time: float | None = None) -> NdarrayOrTensor: |
| 773 | """ |
| 774 | Args: |
| 775 | img: data remain unchanged throughout this transform. |
| 776 | delay_time: The minimum amount of time, in fractions of seconds, |
| 777 | to accomplish this delay task. |
| 778 | """ |
| 779 | time.sleep(self.delay_time if delay_time is None else delay_time) |
| 780 | return img |
| 781 | |
| 782 | |
| 783 | class Lambda(InvertibleTransform): |
no outgoing calls
searching dependent graphs…