weldx.WeldxFile.update

WeldxFile.update(mapping=(), **kwargs)

Update this file from mapping or iterable mapping and kwargs.

Parameters
  • mapping (Union[Mapping, Iterable]) – a key, value paired like structure or an iterable of keys.

  • kwargs – any key value pair you can think of.

Notes

Let the mapping parameter denote E, and let the kwargs parameter denote F. If present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

Examples

Let us update one weldx file with another one. >>> a = WeldxFile(tree=dict(x=42), mode=”rw”) >>> b = WeldxFile(tree=dict(x=23, y=0), mode=”rw”)

We pass all data of b to a while adding another key value pair.

>>> a.update(b, foo="bar")

# remove asdf meta data for easy comparision >>> del a[“asdf_library”], a[“history”] >>> a.data {‘x’: 23, ‘y’: 0, ‘foo’: ‘bar’}

Or we can update with an iterable of key, value tuples. >>> data = [(‘x’, 0), (‘y’, -1)] >>> a.update(data) >>> a.data {‘x’: 0, ‘y’: -1, ‘foo’: ‘bar’}

Another possibility is to directly pass keyword arguments. >>> a.update(x=-1, z=42) >>> a.data {‘x’: -1, ‘y’: -1, ‘foo’: ‘bar’, ‘z’: 42}