Set/modify postfix (additional stats) with automatic formatting based on datatype. Parameters ---------- ordered_dict : dict or OrderedDict, optional refresh : bool, optional Forces refresh [default: True]. kwargs : dict, optio
(self, ordered_dict=None, refresh=True, **kwargs)
| 1400 | self.refresh() |
| 1401 | |
| 1402 | def set_postfix(self, ordered_dict=None, refresh=True, **kwargs): |
| 1403 | """ |
| 1404 | Set/modify postfix (additional stats) |
| 1405 | with automatic formatting based on datatype. |
| 1406 | |
| 1407 | Parameters |
| 1408 | ---------- |
| 1409 | ordered_dict : dict or OrderedDict, optional |
| 1410 | refresh : bool, optional |
| 1411 | Forces refresh [default: True]. |
| 1412 | kwargs : dict, optional |
| 1413 | """ |
| 1414 | # Sort in alphabetical order to be more deterministic |
| 1415 | postfix = OrderedDict([] if ordered_dict is None else ordered_dict) |
| 1416 | for key in sorted(kwargs.keys()): |
| 1417 | postfix[key] = kwargs[key] |
| 1418 | # Preprocess stats according to datatype |
| 1419 | for key in postfix.keys(): |
| 1420 | # Number: limit the length of the string |
| 1421 | if isinstance(postfix[key], Number): |
| 1422 | postfix[key] = self.format_num(postfix[key]) |
| 1423 | # Else for any other type, try to get the string conversion |
| 1424 | elif not isinstance(postfix[key], str): |
| 1425 | postfix[key] = str(postfix[key]) |
| 1426 | # Else if it's a string, don't need to preprocess anything |
| 1427 | # Stitch together to get the final postfix |
| 1428 | self.postfix = ', '.join(key + '=' + postfix[key].strip() |
| 1429 | for key in postfix.keys()) |
| 1430 | if refresh: |
| 1431 | self.refresh() |
| 1432 | |
| 1433 | def set_postfix_str(self, s='', refresh=True): |
| 1434 | """ |
no test coverage detected