MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _transforms_match

Method _transforms_match

monai/transforms/inverse.py:324–342  ·  view source on GitHub ↗

Return whether a traced transform entry matches this transform. Matching succeeds when the traced ID matches this instance, when the ID check is explicitly disabled with ``TraceKeys.NONE``, or when multiprocessing uses ``spawn`` and the traced class name matches this

(self, transform: Mapping)

Source from the content-addressed store, hash-verified

322 )
323
324 def _transforms_match(self, transform: Mapping) -> bool:
325 """Return whether a traced transform entry matches this transform.
326
327 Matching succeeds when the traced ID matches this instance, when the ID
328 check is explicitly disabled with ``TraceKeys.NONE``, or when
329 multiprocessing uses ``spawn`` and the traced class name matches this
330 transform class.
331 """
332 xform_id = transform.get(TraceKeys.ID, "")
333 if xform_id == id(self):
334 return True
335 # TraceKeys.NONE to skip the id check
336 if xform_id == TraceKeys.NONE:
337 return True
338 xform_name = transform.get(TraceKeys.CLASS_NAME, "")
339 # basic check if multiprocessing uses 'spawn' (objects get recreated so don't have same ID)
340 if torch.multiprocessing.get_start_method(allow_none=True) == "spawn" and xform_name == self.__class__.__name__:
341 return True
342 return False
343
344 def get_most_recent_transform(self, data, key: Hashable = None, check: bool = True, pop: bool = False):
345 """

Callers 2

Calls 1

getMethod · 0.80

Tested by

no test coverage detected