Function
safe_setitem
(dest, key: Hashable, value, name: T_Name = None)
Source from the content-addressed store, hash-verified
| 110 | |
| 111 | |
| 112 | def safe_setitem(dest, key: Hashable, value, name: T_Name = None): |
| 113 | if key in dest: |
| 114 | var_str = f" on variable {name!r}" if name else "" |
| 115 | raise ValueError( |
| 116 | f"Key '{key}' already exists in attrs{var_str}, and will not be overwritten. " |
| 117 | "This is probably an encoding field used by xarray to describe " |
| 118 | "how a variable is serialized. To proceed, remove this key from " |
| 119 | "the variable's attributes manually." |
| 120 | ) |
| 121 | dest[key] = value |
| 122 | |
| 123 | |
| 124 | def pop_to( |
Tested by
no test coverage detected
Used in the wild real call sites across dependent graphs
searching dependent graphs…