MCPcopy Create free account
hub / github.com/RolnickLab/climart / rsetattr

Function rsetattr

climart/utils/utils.py:116–118  ·  view source on GitHub ↗
(obj, attr, val)

Source from the content-addressed store, hash-verified

114# The following two functions extend setattr and getattr to support chained objects, e.g. rsetattr(cfg, optim.lr, 1e-4)
115# From https://stackoverflow.com/questions/31174295/getattr-and-setattr-on-nested-subobjects-chained-properties
116def rsetattr(obj, attr, val):
117 pre, _, post = attr.rpartition('.')
118 return setattr(rgetattr(obj, pre) if pre else obj, post, val)
119
120
121def rgetattr(obj, attr, *args):

Callers

nothing calls this directly

Calls 1

rgetattrFunction · 0.85

Tested by

no test coverage detected