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

Method to_xml

dm_control/mjcf/element.py:751–783  ·  view source on GitHub ↗

Generates an etree._Element corresponding to this MJCF element. Args: prefix_root: (optional) A `NameScope` object to be treated as root for the purpose of calculating the prefix. If `None` then no prefix is included. debug_context: (optional) A `debugging.DebugConte

(self, prefix_root=None, debug_context=None,
             *,
             precision=constants.XML_DEFAULT_PRECISION,
             zero_threshold=0, filename_with_hash=True)

Source from the content-addressed store, hash-verified

749 return all_children
750
751 def to_xml(self, prefix_root=None, debug_context=None,
752 *,
753 precision=constants.XML_DEFAULT_PRECISION,
754 zero_threshold=0, filename_with_hash=True):
755 """Generates an etree._Element corresponding to this MJCF element.
756
757 Args:
758 prefix_root: (optional) A `NameScope` object to be treated as root
759 for the purpose of calculating the prefix.
760 If `None` then no prefix is included.
761 debug_context: (optional) A `debugging.DebugContext` object to which
762 the debugging information associated with the generated XML is written.
763 This is intended for internal use within PyMJCF; users should never need
764 manually pass this argument.
765 precision: (optional) Number of digits to output for floating point
766 quantities.
767 zero_threshold: (optional) When outputting XML, floating point quantities
768 whose absolute value falls below this threshold will be treated as zero.
769 filename_with_hash: (optional) A boolean, whether to append a hash string
770 to the name of a file when it is registered in MuJoCo's VFS.
771
772 Returns:
773 An etree._Element object.
774 """
775 prefix_root = prefix_root or self.namescope
776 xml_element = etree.Element(self._spec.name)
777 self._attributes_to_xml(xml_element, prefix_root, debug_context,
778 precision=precision, zero_threshold=zero_threshold,
779 filename_with_hash=filename_with_hash)
780 self._children_to_xml(xml_element, prefix_root, debug_context,
781 precision=precision, zero_threshold=zero_threshold,
782 filename_with_hash=filename_with_hash)
783 return xml_element
784
785 def _attributes_to_xml(self, xml_element, prefix_root, debug_context=None,
786 *, precision, zero_threshold, filename_with_hash):

Callers 6

to_xml_stringMethod · 0.95
_children_to_xmlMethod · 0.45
to_xmlMethod · 0.45
to_xmlMethod · 0.45
to_xmlMethod · 0.45
_children_to_xmlMethod · 0.45

Calls 2

_attributes_to_xmlMethod · 0.95
_children_to_xmlMethod · 0.95

Tested by

no test coverage detected