MCPcopy
hub / github.com/pyg-team/pytorch_geometric / cast

Method cast

torch_geometric/utils/mixin.py:8–19  ·  view source on GitHub ↗
(cls: T, *args: Any, **kwargs: Any)

Source from the content-addressed store, hash-verified

6class CastMixin:
7 @classmethod
8 def cast(cls: T, *args: Any, **kwargs: Any) -> T:
9 if len(args) == 1 and len(kwargs) == 0:
10 elem = args[0]
11 if elem is None:
12 return None # type: ignore
13 if isinstance(elem, CastMixin):
14 return elem # type: ignore
15 if isinstance(elem, tuple):
16 return cls(*elem) # type: ignore
17 if isinstance(elem, dict):
18 return cls(**elem) # type: ignore
19 return cls(*args, **kwargs) # type: ignore
20
21 def __iter__(self) -> Iterator:
22 return iter(self.__dict__.values())

Callers 15

sample_from_nodesMethod · 0.80
put_edge_idMethod · 0.80
get_edge_idMethod · 0.80
remove_edge_idMethod · 0.80
get_all_tensor_attrsMethod · 0.80
put_tensorMethod · 0.80
get_tensorMethod · 0.80
multi_get_tensorMethod · 0.80
remove_tensorMethod · 0.80
update_tensorMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected