How to use the skorch.utils.Ansi function in skorch

To help you get started, weā€™ve selected a few skorch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skorch-dev / skorch / skorch / callbacks.py View on Github external
"""For a given row from the table, format it (i.e. floating
        points and color if applicable.

        """
        value = row[key]
        if not isinstance(value, Number):
            return value

        # determine if integer value
        is_integer = float(value).is_integer()
        template = '{}' if is_integer else '{:' + self.floatfmt + '}'

        # if numeric, there could be a 'best' key
        key_best = key + '_best'
        if (key_best in row) and row[key_best]:
            template = color + template + Ansi.ENDC.value
        return template.format(value)
github skorch-dev / skorch / skorch / callbacks / logging.py View on Github external
value = row[key]

        if isinstance(value, bool) or value is None:
            return '+' if value else ''

        if not isinstance(value, Number):
            return value

        # determine if integer value
        is_integer = float(value).is_integer()
        template = '{}' if is_integer else '{:' + self.floatfmt + '}'

        # if numeric, there could be a 'best' key
        key_best = key + '_best'
        if (key_best in row) and row[key_best]:
            template = color + template + Ansi.ENDC.value
        return template.format(value)
github skorch-dev / skorch / skorch / callbacks.py View on Github external
"""For a given row from the table, format it (i.e. floating
        points and color if applicable.

        """
        value = row[key]
        if not isinstance(value, Number):
            return value

        # determine if integer value
        is_integer = float(value).is_integer()
        template = '{}' if is_integer else '{:' + self.floatfmt + '}'

        # if numeric, there could be a 'best' key
        key_best = key + '_best'
        if (key_best in row) and row[key_best]:
            template = color + template + Ansi.ENDC.value
        return template.format(value)
github skorch-dev / skorch / skorch / callbacks.py View on Github external
def _yield_keys_formatted(self, row):
        colors = cycle([color.value for color in Ansi if color != color.ENDC])
        color = next(colors)
        for key in self._sorted_keys(row.keys()):
            formatted = self.format_row(row, key, color=color)
            yield key, formatted
            color = next(colors)
github skorch-dev / skorch / skorch / callbacks / logging.py View on Github external
def _yield_keys_formatted(self, row):
        colors = cycle([color.value for color in Ansi if color != color.ENDC])
        for key, color in zip(self._sorted_keys(row.keys()), colors):
            formatted = self.format_row(row, key, color=color)
            if key.startswith('event_'):
                key = key[6:]
            yield key, formatted
github skorch-dev / skorch / skorch / callbacks.py View on Github external
def _yield_keys_formatted(self, row):
        colors = cycle([color.value for color in Ansi if color != color.ENDC])
        color = next(colors)
        for key in self._sorted_keys(row.keys()):
            formatted = self.format_row(row, key, color=color)
            yield key, formatted
            color = next(colors)