MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / __setattr__

Method __setattr__

dm_control/mjcf/element.py:681–697  ·  view source on GitHub ↗
(self, name, value)

Source from the content-addressed store, hash-verified

679 raise AttributeError('object has no attribute: {}'.format(name))
680
681 def __setattr__(self, name, value):
682 # If this name corresponds to a descriptor for a slotted attribute or
683 # settable property then try to invoke the descriptor to set the attribute
684 # and return if successful.
685 klass_attr = getattr(type(self), name, None)
686 if klass_attr is not None:
687 try:
688 return klass_attr.__set__(self, value)
689 except AttributeError:
690 pass
691 # If we did not find a settable descriptor then we look in the attribute
692 # spec to see if there is a MuJoCo attribute matching this name.
693 attribute_name = name if name != constants.DCLASS else constants.CLASS
694 if attribute_name in self._spec.attributes:
695 self._set_attribute(attribute_name, value)
696 else:
697 raise AttributeError('can\'t set attribute: {}'.format(name))
698
699 def __delattr__(self, name):
700 if name in self._spec.children:

Callers

nothing calls this directly

Calls 1

_set_attributeMethod · 0.95

Tested by

no test coverage detected