Method
log
(self, log_dict=None, **log_items)
Source from the content-addressed store, hash-verified
| 16 | return d |
| 17 | |
| 18 | def log(self, log_dict=None, **log_items): |
| 19 | if log_items: |
| 20 | if log_dict: |
| 21 | raise TypeError('Cannot pass both positional and keyword arguments.') |
| 22 | |
| 23 | log_dict = log_items |
| 24 | |
| 25 | for key, value in log_dict.items(): |
| 26 | if key not in self: |
| 27 | self[key] = [] |
| 28 | |
| 29 | try: |
| 30 | self[key].append(value.item()) |
| 31 | except AttributeError: |
| 32 | self[key].append(value) |
| 33 | except ValueError: |
| 34 | raise ValueError('Only scalar values can be logged.') |
| 35 | |
| 36 | self._log_length += 1 |
| 37 | |
| 38 | def to_dict(self): |
| 39 | return self.data.copy() |