MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / SimulateDelay

Class SimulateDelay

monai/transforms/utility/array.py:749–780  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

747
748
749class 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
783class Lambda(InvertibleTransform):

Callers 3

__init__Method · 0.90
test_shapeMethod · 0.90
test_valueMethod · 0.90

Calls

no outgoing calls

Tested by 2

test_shapeMethod · 0.72
test_valueMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…