def read_partials_file(self, file, partials): # type: (Union[str, etree._ElementTree], Vector) -> None """Read the partials from a given XML file and store them in this `Component`'s variables. Parameters ---------- file : str or :obj:`etree._ElementTree` Path to or :obj:`etree._ElementTree` of a partials XML file. partials : Vector Partials vector of this `Component`. """ output_rename_map = self.output_rename_map _partials = Partials(file) for of, wrts in _partials.get_partials().items(): for wrt, val in wrts.items(): of = xpath_to_param(of) if of in output_rename_map: of = output_rename_map[of][0] wrt = xpath_to_param(wrt) if (of, wrt) in partials: try: partials[of, wrt] = val except Exception as e: print(e.message)
def declare_partials_from_xml(self, partial_xml): # type: (Union[str, etree._ElementTree]) -> None """Declare partials to the `Component` based on a partials XML template file. Parameters ---------- partial_xml : str or :obj:`etree._ElementTree` Path to or an `etree._ElementTree` of a partials XML file. """ self.partials_from_xml.clear() if partial_xml is not None: partials = Partials(partial_xml) self.partials_from_xml = partials.get_partials().copy()
def read_partials_file(self, file, partials): # type: (Union[str, etree._ElementTree], Vector) -> None """Read the partials from a given XML file and store them in this `Component`'s variables. Parameters ---------- file : str or :obj:`etree._ElementTree` Path to or :obj:`etree._ElementTree` of a partials XML file. partials : Vector Partials vector of this `Component`. """ _partials = Partials(file) for src, partial in _partials.get_partials().items(): for tgt, val in partial.items(): if [src, tgt] in partials: try: partials[src, tgt] = val except Exception as e: print(e.message)