MCPcopy Create free account
hub / github.com/TorchSSL/TorchSSL / setattr_cls_from_kwargs

Function setattr_cls_from_kwargs

utils.py:17–23  ·  view source on GitHub ↗
(cls, kwargs)

Source from the content-addressed store, hash-verified

15
16
17def setattr_cls_from_kwargs(cls, kwargs):
18 # if default values are in the cls,
19 # overlap the value by kwargs
20 for key in kwargs.keys():
21 if hasattr(cls, key):
22 print(f"{key} in {cls} is overlapped by kwargs: {getattr(cls, key)} -> {kwargs[key]}")
23 setattr(cls, key, kwargs[key])
24
25
26def test_setattr_cls_from_kwargs():

Callers 2

net_builderFunction · 0.85

Calls

no outgoing calls

Tested by 1