def ordered_dict_representer(dumper: yaml.Dumper, instance: OrderedDict) -> yaml.Node: # NOTE(ycho): nested list for compatibility with PyYAML's representer node = dumper.represent_sequence("OrderedDict", [list(instance.items())]) return node
def ordered_dict_representer(dumper: yaml.Dumper, instance: OrderedDict) -> yaml.Node: node = dumper.represent_sequence("OrderedDict", instance.items()) return node
def _dump_yaml(cls, dumper: yaml.Dumper, source: "YamlModifier") -> typing.Any: """Convert to a yaml node representation for writing to file.""" if isinstance(source.value, (list, tuple)): return dumper.represent_sequence(source.label(), source.value) return dumper.represent_mapping(source.label(), source.value)
def represent(dumper: yaml.Dumper, data: 'MultiStep'): return dumper.represent_sequence('MultiStep', data.value)
def tensor_representer(dumper: yaml.Dumper, data: Tensor): assert type(data) == Tensor if data.shape: return dumper.represent_sequence("tag:yaml.org,2002:float", data.tolist()) else: return float_representer(dumper, data.item())